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, ------------------------------------------------------------------- Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE ------------------------------------------------------------------- If you believe in telekinesis, raise my hand.
Sundar Dorai-Raj
2004-Feb-12 19:50 UTC
[R] variances of values predicted using a lm object
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: <quote> Details: '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. </quote> Is this what you need? -sundar
In case you haven't read ?predict.lm, please do, and if you did, please do it yet again. Look for the `se.fit' and `interval' arguments. Andy> From: Rajarshi Guha > > 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, > > ------------------------------------------------------------------- > Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net> > GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE > ------------------------------------------------------------------- > If you believe in telekinesis, raise my hand.------------------------------------------------------------------------------ Notice: This e-mail message, together with any attachments,...{{dropped}}