Skip to content
Prev 59785 / 398502 Next

confidence interval of a average...

Then, you want the predition interval on the mean VC which is the thighter 
of the two confidence intervals and does not include the extra variability 
of VC about its mean.  As always with confidence intevals, you are free to 
look at either 95% CI or 97.5% CI depending on what kind of satement you'd 
like to make about your confidence.  I don't not understand you comment 
about covariance at all.

Let me try again with data in your units.  Note that CI varies with height 
and is smallest at the mean height whether you are talking about CI on the 
mean VC or CI on the predicted VC.  For comparison, the red lines are the 
95% CI on mean regression fit VC and the blue lines are 95% CI on 
"predicted" VC.   The simulated data is set to have a mean height that 
varies around 163 cm.


# Make simulated data with mean height near 163
# vc approximately in liter values with scatter
height=sort(rnorm(50,mean=163,sd=35))
vc=0.03*height+.5*rnorm(50)

#Plot the simulated data
plot(vc~height,ylab='vital capacity (l)',xlab='Height (cm)')

# Set up data frame with values of height you wish a ci on
# column heading must be same as for lm() fit x variable
# in this case, dataframe contains only mean height
mean.height.fit.ci=data.frame(height=mean(height))

#print out the mean height
mean.height.fit.ci

# fit the regression model
vc.lm=lm(vc~height)

#Draw 95% confidence intervals on mean vc at various heights(red) (min at 
mean(height)
matlines(height,predict.lm(vc.lm,interval="c"),lty=c(1,2,2), 
col=c('black','red','red'))

#Draw 95% confidence intervals on new vc at various heights(blue) (min again 
at mean(height)
matlines(height,predict.lm(vc.lm,interval="p"),lty=c(1,3,3), 
col=c('black','blue','blue'))

# Determine 95% CI on mean vc at mean height
predict.lm(vc.lm,mean.height.fit.ci,interval="confidence")

# Determine 97.5 5% CI on mean vc at mean height
predict.lm(vc.lm,mean.height.fit.ci,interval="confidence", level=0.975)


You might wish to read a little more about regression CIs in a good 
statistics book.

HTH,
Rob