[R] Can not get a prediction interval from Predict

Sundar Dorai-Raj sdorairaj at gmail.com
Tue Mar 31 19:17:29 CEST 2009


?predict.glm has no "interval" argument. Perhaps you're thinking of
?predict.lm, which is different.

To get intervals in glm, I've used:

example(predict.glm)
pr <- predict(budworm.lg, se.fit = TRUE)
family <- family(budworm.lg)
lower <- family$linkinv(pr$fit - qnorm(0.95) * pr$se.fit)
upper <- family$linkinv(pr$fit + qnorm(0.95) * pr$se.fit)

Note that these are "confidence" limits and not "prediction" limits.
The latter would require more thought.

You could also try RSiteSearch("glm interval").

HTH,

--sundar

On Tue, Mar 31, 2009 at 9:58 AM, Taylor Davis
<taylor.davis at klasresearch.com> wrote:
> I am trying to get a prediction interval from a glm regression.
>
> With newdat being my set of values to be fitted, and glmreg the name of my
> regression, I am using the following code.
>
> predict(glmreg, newdat, se.fit = TRUE, interval = "confidence", level =
> 0.90)
>
> The problem is that I am only getting the standard error and the fitted
> value, not a prediction interval.
>
> Any help would be great! Thanks so much.
>
> _______________________________
> TAYLOR DAVIS    |
> KLAS
> taylor.davis at KLASresearch.com    |    801.734.6279
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list