[R] Confidence intervals in ANOVA

Karl Knoblick karlknoblich at yahoo.de
Mon Dec 8 11:33:35 CET 2003


Hallo! 


I have the a model with 3 time points, 2 treatments 
and N subjects. I can calculate an ANOVA but I can not

calculate the CI of the interaction term (time and 
treatment), which I need for a closer look at the 
effect of the treatment to the 3 time points. I do NOT

want to use lme because I can not manage it to 
reproduce text book examples (see my posting [R] lme: 
reproducing example Karl Knoblick (Tue 02 Dec 2003 - 
21:34:54 EST)). 


Here some sample data: 


# Data 
# 35 subjects 
ID<-factor(rep(1:35,each=3)) 
TREAT<-factor(c(rep("A", 60), rep("B", 45))) 
TIME<-factor(rep(1:3, 35)) 
Y<-numeric(length=105) 
set.seed(1234) 
Y<-rnorm(105) 
# want to see an effect:
Y[TREAT=="A" & TIME==2]<-Y[TREAT=="A" & TIME==2] - 1
DF<-data.frame(Y, ID, TREAT, TIME) 


# 2 possible designs: 
# Design 1 with random term 
DF.aov1<-aov(Y ~ TIME*TREAT + Error(TREAT:ID), 
data=DF) 
summary(DF.aov1) 
# Design 2 without random term 
DF.aov2<-aov(Y ~ TIME*TREAT, data=DF) 
summary(DF.aov2) 


I am also not sure about the design - I think design 1

is more appropriate. 


What I have tried is to calculate the CI of the 
coefficients: 
confint(DF.aov1[[2]]) 
confint(DF.aov1[[3]]) 


(or: 
confint(DF.aov2) 
) 


But how can I get the CI for a concrete difference for

example between the treatments at time point 2? 


I really hope, sombody can help! 


Karl




More information about the R-help mailing list