[R] confidence interval in "predict.lm"

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Nov 15 19:18:56 CET 2002

"Fred Mellender" <fredm at frontiernet.net> writes:

> The book gives the confidence interval as 26.5 <= y <= 39.5.  The book
> defines the confidence interval calculation thus:
>   yp - E <= y <= yp + E
>   Where
>    E = tc*sC *sqrt(1 + 1/n + (x-xBar)^2/SSx)
>    yp is the predicted value from the regression line
>    tc is the value from Student's t distribution for a confidence
>     level, c, using n-2 degrees of freedom,
>    sC is the standard error of estimate
>    SSx is Sum(x^2)-[Sum(x)]^2/n
>    n is the number of data pairs.
> So that even though the model, predicted value, standard error all agree, R
> gives a much smaller confidence
> interval than the book does.
> Thanks for any advice/help.

The book is giving you a prediction interval, aka a tolerance
interval. Some people use the term "confidence interval" a bit too
sloppily. predict() will give you the other kind of interval if you
ask it to. Vice versa, 

E = tc*sC *sqrt(1/n + (x-xBar)^2/SSx) 

would give you the confidence interval for the predicted mean, I think.

   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list