# Calculating predictions and confidence intervals from a negative binomial distribution

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[2] CI.lower <- pred$fit[3]


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:

1. How do I get the CI from nb_pred? e.g., the equivalent of pred$fit[2] and pred$fit[3]
2. 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.
-
 Are you sure that offset(y) works with glm.nb? This could why predict isnt working. – probabilityislogic Oct 12 '12 at 5:09 twri.tamu.edu/bret/BretWebSiteDocs/GLMCI.pdf – Roman Luštrik Oct 12 '12 at 6:17