[R] Confidence Intervals for slopes
David Orme
d.orme at imperial.ac.uk
Thu Apr 1 13:55:13 CEST 2004
Hi,
Thanks for the pointer - the 'lm(y~x:z)' model does give the slopes
directly and hence confint gives the confidence intervals.
The thing that puzzles me is that my dummy data explicitly sets the
three levels of the factor to have different variances and yet the
standard error is the same for all three parameter estimates in the
summary.lm output - is this a common standard error of the 'x:z' term
in the model? If you fit a separate regression to subsets of the data
for each level in 'z' then the standard errors of the slope reflect
these differences in variance. What I was trying to get was confidence
limits from within a single model that also reflect the difference in
certainty about the three slopes.
I realize that this is a failing of my understanding and more a stats
question than an R question - if anyone can give me any advice or
pointers, that would be great.
Thanks,
David
On 29 Mar 2004, at 20:04, BXC (Bendix Carstensen) wrote:
> You may want:
>
> lm( y ~ x:z )
>
> This is the same model you fitted, but prametrized differently.
> But please check that what you REALLY want is not
>
> lm( y ~ z + x:z )
>
> This is the model with different intercepts as well.
>
> Bendix Carstensen
> ----------------------
> Bendix Carstensen
> Senior Statistician
> Steno Diabetes Center
> Niels Steensens Vej 2
> DK-2820 Gentofte
> Denmark
> tel: +45 44 43 87 38
> mob: +45 30 75 87 38
> fax: +45 44 43 07 06
> bxc at steno.dk
> www.biostat.ku.dk/~bxc
> ----------------------
>
>
>
>
>
>> -----Original Message-----
>> From: r-help-bounces at stat.math.ethz.ch
>> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of David Orme
>> Sent: Monday, March 29, 2004 4:44 PM
>> To: r-help at stat.math.ethz.ch
>> Subject: [R] Confidence Intervals for slopes
>>
>>
>> Hi,
>>
>> I'm trying to get confidence intervals to slopes from a linear model
>> and I can't figure out how to get at them. As a cut 'n' paste example:
>>
>> #################
>> # dummy dataset - regression data for 3 treatments, each
>> treatment with
>> different (normal) variance
>> x <- rep(1:10, length=30)
>> y <- 10 - (rep(c(0.2,0.5,0.8), each=10)*x)+c(rnorm(10, sd=0.1),
>> rnorm(10, sd=0.6),rnorm(10, sd=1.1))
>> z <- gl(3,10)
>> plot(y~x, pch=unclass(z))
>>
>> # model as three slopes with common intercept
>> options(contrasts=c("contr.treatment","contr.poly"))
>> model <- lm(y~x+x:z)
>>
>> # coefficient table in summary gives the intercept, first
>> slope and the
>> difference in slopes
>> summary(model)
>>
>> # confint gives the confidence interval for the intercept and first
>> slope,
>> # and the CIs for the _differences_
>> confint(model)
>> #################
>>
>> What I'd like to report are the actual CI's for the slopes for the
>> second and third treatments, in the same way that confint returns the
>> parameter estimates for the first treatment. Can anyone point
>> me in the
>> right direction?
>>
>> Thanks,
>> David
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://www.stat.math.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