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.