Negative binomial regression, model development and model validation quetion.

Dear all,
I really need your help with negative binomial regression (outcome is a count data, range 1- 122 days, i have checked assumptions and variance is larger than mean so NB is appropriate), namely how to test my model.

The code i have written is as follows:

library(caret)
library(MASS)
set.seed(2022)
covid_df <- data.frame(df_covid)
df_covid_inTraining <- createDataPartition(covid_df$Sick_leave_scale, p = .80, list = FALSE)
df_covid_training <- covid_df[df_covid_inTraining,]
df_covid_testing <- covid_df[-df_covid_inTraining,]

model development:

model_nb_train_sel <- glm.nb(Sick_leave_scale ~ v1 + v2 + v3 + v4, data = df_covid_training, init.theta = 4.44, link = "log")
summary(model_nb_train_sel)
model_nb_train_sel$AIC
est_model_nb_train <- cbind(Estimate = coef(model_nb_train_sel), confint(model_nb_train_sel))
exp(model_nb_train_sel)

model testing:

predict(model_nb_train_sel, newdata = df_covid_testing)

However this does not work and i DO NOT UNDESTAND how to test "model_nb_train_sel" on my testing dataset. I get very vierd results that i can not interpret.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.