Skip to content

confidence interval of a average...

2 messages · Robert Baer

#
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
the
#
Sorry.  The last code line got destroyed by my emailer and should read:
+ lty=c(1,3,3),col=c('black','red','red'))


----- Original Message ----- 
From: "Robert W. Baer, Ph.D." <rbaer at atsu.edu>
To: <r-help at stat.math.ethz.ch>
Sent: Wednesday, November 24, 2004 4:56 PM
Subject: Re: [R] confidence interval of a average...
matlines(height,predict.lm(lm.vc,interval="p"),lty=c(1,3,3),col=c('black','r
how?
calculate
the
http://www.R-project.org/posting-guide.html