[R] variances of values predicted using a lm object

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Thu Feb 12 20:50:36 CET 2004

Rajarshi Guha wrote:
> Hi,
>   is there a function in R that will give me the variances of a
> predicted values obtained using predict.lm().
> If no function is available I would need to calculate them myself -
> which involves taking the inverse of X'X (' indicating transpose)
> where X is my model matrix. I know that calculating an inverse directly
> is not a good idea in general - could anybody suggest a way around this?
> Thanks,

 From ?predict.lm:


      'predict.lm' produces predicted values, obtained by evaluating the
      regression function in the frame 'newdata' (which defaults to
      'model.frame(object)'.  If the logical 'se.fit' is 'TRUE',
      standard errors of the predictions are calculated.

Is this what you need?


More information about the R-help mailing list