I'm trying to use R's
glm.nb to calculate predictions and confidence intervals.
When I'm using linear models after training a model, e.g., using:
model <- lm(y ~ x)
I can get predictions and CIs using:
pred <- predict(model, new_x, se.fit=T, interval="prediction", level=0.95) CI.upper <- pred$fit CI.lower <- pred$fit
Now I'm using:
nb_model <- glm.nb(z ~ x + offset(y)) nb_pred <- predict(nb_model, new_data=data.frame(x=X, y=Y), type="response", se.fit=T)
My questions are:
- How do I get the CI from nb_pred? e.g., the equivalent of
- The predict function seems to ignore Y - I get the same value from predict with and without providing y=Y. I don't understand why the model seems to ignore the offset variable.