Re: [R] covariance matrix of predictions

From: Ritwik Sinha <ritwik.sinha_at_gmail.com>
Date: Mon 28 Aug 2006 - 08:54:05 EST

Hi,

If I understand correctly the

Var(X \hat{\beta}) = X (X'X)^{-1}X' \sigma^2, where X will now be "x.pred".

Which should be easily obtained by performing the matrix computation and multiplying it with the estimate of the variance.

For more details about different aspects of the estimate and variance of the predictor refer to page 39 of http://www.stat.lsa.umich.edu/~faraway/book/

Ritwik Sinha

On 8/23/06, Arnab mukherji <arnab@myrealbox.com> wrote:
>
> Hi !
>
> I am trying to get at the covariance of the predictions of a linear model.
> Suppose the we have:
>
> > x<-runif(1000)
> > y<-2 + 25x*x +rnorm(1000)
> > lm1 <-lm(y~x, data = data.frame(y = y, x=x))
> > x.pred <-runif(10)
> > y.hat <- predict(lm1, newdata = data.frame(x=x.pred))
>
> I was wondering how to get an estimate of the covariance of y.hat which
> would be a 10 x 10 matrix telling be the uncertainty in each of the
> predictions.
>
> thanks
>
> Arnab
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

-- 
Ritwik Sinha
Graduate Student
Epidemiology and Biostatistics
Case Western Reserve University

http://darwin.cwru.edu/~rsinha

	[[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch 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.
Received on Mon Aug 28 09:01:26 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 28 Aug 2006 - 10:23:51 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.