[R] covariance matrix of predictions

Arnab mukherji arnab at myrealbox.com
Wed Aug 23 19:28:28 CEST 2006


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



More information about the R-help mailing list