[R] confidence interval of a average...
Robert W. Baer, Ph.D.
rbaer at atsu.edu
Wed Nov 24 23:56:00 CET 2004
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
the
> > 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
> same
> > for the taller people. That is bound to be wrong though.
> >
> > Dunc
> >
> > ______________________________________________
> > 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
> >
>
More information about the R-help
mailing list