[R] Variance of Y_hat in a linear model

Gabor Grothendieck ggrothendieck at gmail.com
Tue Oct 17 19:00:22 CEST 2006


Using the builtin BOD data set try this:

predict(lm(demand ~., BOD), se.fit = TRUE)


On 10/17/06, Li Zhang <zhanglitt at yahoo.com> wrote:
>
>    Y       X     Z
>   42.0    7.0   33.0
>   33.0    4.0   41.0
>   75.0   16.0    7.0
>   28.0    3.0   49.0
>   91.0   21.0    5.0
>   55.0    8.0   31.0
>
>
> data<-read.table("d.txt",header=TRUE)
> mod<-lm(data$Y~data$X+data$Z)
> predict(mod)
>       1        2        3        4        5        6
> 44.69961 34.22997 76.63735 29.32986 91.09000 48.01321
>
>
> In the lm, the predicted(fitted) Y_1_hat is 44.6991,
>
> is there a function to give me the variance of
> y_1_hat?
>
> Neither "anova" nor "summary" gives this value.
>
> Thank You
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list