[R] confidence interval of a average...
Duncan Harris
dunc_harris at hotmail.com
Thu Nov 25 00:05:32 CET 2004
Sorry if this was not clear. This is more of a theoreticla question rather
than a R-coding question. I need to calculate
"The predicted response and 95% prediction interval for a man of average
height"
So I need to predict the average response, which is easily done by taking
the mean height and using the regression formula.
However, "average height" has to be calculated from the sample, and thus I
have confidence in that. Let's say the mean is 163cm, I think that I can't
take the 163cm value and calculate the CI from just the sd of the lung
capacity because that would be too narrow; I think covariance must come into
it somehow, or can I just do a 97.5% CI on the height and take those extreme
values and do a 97.% CI on them?
Dunc
>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
>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