Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

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.
share|improve this question
Are you sure that offset(y) works with glm.nb? This could why predict isnt working. – probabilityislogic Oct 12 '12 at 5:09

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.