[R] Mixed ANCOVA with between-Ss covariate?
Mike Lawrence
mike at thatmike.com
Tue Feb 10 22:12:05 CET 2009
Hi all,
I have data from an experiment with 3 independent variables, 2 are
within and 1 is between. In addition to the dependent variable, I have
a covariate that is a single measure per subject. Below I provide an
example generated data set and my approach to implementing the ANCOVA.
However the output confuses me; why does the covariate only appear in
the first strata? Presumably it should appear in every strata in which
there can be between-Ss effects or interactions with between-Ss
effects, no?
#generate data
set.seed(1)
a=rbind(
expand.grid(
id=1:20
,iv1 = 1:2
,iv2 = 1:2
)
)
a$group = factor(a$id<11)
a$dv = rnorm(length(a[,1]))
a$covariate = NA
for(i in unique(a$id)){
a$covariate[a$id==i]= rnorm(1)
}
#make sure id, iv1, and iv2 are factorized
a$id=factor(a$id)
a$iv1=factor(a$iv1)
a$iv2=factor(a$iv2)
#run ANCOVA
covariate_aov = aov(dv~covariate+group*iv1*iv2+Error(id/(iv1*iv2)),data=a)
summary(covariate_aov)
--
Mike Lawrence
Graduate Student
Department of Psychology
Dalhousie University
www.thatmike.com
Looking to arrange a meeting? Check my public calendar:
http://www.thatmike.com/mikes-public-calendar
~ Certainty is folly... I think. ~
More information about the R-help
mailing list