From: "Robert W. Baer, Ph.D." <rbaer at atsu.edu>
To: "Duncan Harris" <dunc_harris at hotmail.com>
Subject: Re: [R] confidence interval of a average...
Date: Wed, 24 Nov 2004 16:25:53 -0600
It depends on whether you want to do 95% ocnfidence intervals on the
predicition or the mean vital capacity. Try the following and see if it
gets you started:
#Simulate data
height=48:72
vc=height*10+20*rnorm(72-48+1)
# Do regression
lm.vc=lm(vc~height)
# Confidence interval on mean vc
predict.lm(lm.vc,interval="confidence")
#confidence interval on prediced vc
predict.lm(lm.vc,interval="prediction")
#plot everything
plot(vc~height)
matlines(height,predict.lm(lm.vc,interval="c"), lty=c(1,2,2),col='blue')
matlines(height,predict.lm(lm.vc,interval="p"),lty=c(1,3,3),col=c('black','r
ed','red'))
Rob
----------------------
Fom: "Duncan Harris" <dunc_harris at hotmail.com>
I have a sample of lung capacities from a population measured against
height. I need to know the 95% CI of the lung capacity of a person of
average height.
I have fitted a regression line.
How do I get a minimum and maximum values of the 95% CI?
My thinking was that this has something to do with covariance, but how?
My other thinking was that I could derive the 0.975 (sqrt 0.95) CI for
height. Then I could take the lower height 0.975 CI value and calculate
from that the lower 0.975 value from the lung capacity. And then do the
for the taller people. That is bound to be wrong though.
Dunc