0
votes

I would like to find the predicted values from my glm.nb model. But it is returning errors. This was not fixed when I made the input dataframe to predict 3 columns of dates called date, date2 and date3. The output I want is a vector of 100 predicted values. Model-fitting data should positive count data and dates.

model_nb <- glm.nb(cases ~ date, date2, date3, data=data)

dates <- seq(50,100,length=100)
preds3 <- predict(model_nb, newdata=data.frame(date=dates), se.fit=TRUE, type='response')

The error message is:

Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : variable lengths differ (found for 'date2')

1
Is your model meant to have three date predictors? If so the syntax should probably be model_nb <- glm.nb(cases ~ date + date2 + date3, data=data). And if this new model syntax is correct then you will need date, date2 and date3 in the newdata in your predict call - user20650
i tried that but it didn't work. can you specify the exact input format of the three variables? - engelbrekt

1 Answers

0
votes

I solved this by reframing the dates in terms of each other in the original model.