Re: [R] predict.lm

From: Christos Hatzis <christos_at_silicoinsights.com>
Date: Wed 03 May 2006 - 05:24:47 EST


I think you got it right.

The mean of the (weighted) sum of a set of random variables is the (weighted) sum of the means and its variance is the (weighted) sum of the individual variances (using squared weights). Here you don't have to worry about weights.

So what you proposed does exactly this.

-Christos

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Bill Szkotnicki Sent: Tuesday, May 02, 2006 2:59 PM
To: 'R-Help help'
Subject: [R] predict.lm

I have a model with a few correlated explanatory variables. i.e.
> m1=lm(y~x1+x2+x3+x4,protdata)
and I have used predict as follows:

> x=data.frame(x=1:36)
> yp=predict(m1,x,se.fit=T)
> tprot=sum(yp$fit) # add up the predictions tprot

tprot is the sum of the 36 predicted values and I would like the se of that prediction.
I think
> sqrt(sum(yp$se.fit^2))
is not correct.

Would anyone know the correct approach?
i.e. How to get the se of a function of predicted values (in this case sum)  

Thanks, Bill



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

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 Received on Wed May 03 06:38:47 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 Wed 03 May 2006 - 08:10:02 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.