[R] Confidence Intervals for slopes

David Orme d.orme at imperial.ac.uk
Mon Mar 29 16:44:00 CEST 2004


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




More information about the R-help mailing list