Skip to content

Mixed ANCOVA with between-Ss covariate?

3 messages · Michael Lawrence, Mark Difford

#
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)
1 day later
#
I'm surprised there were no takers on this query; I thought it would
be an easy answer, particularly where I provided example data set and
code. Did my request run afoul of the list etiquette?
On Tue, Feb 10, 2009 at 5:12 PM, Mike Lawrence <mike at thatmike.com> wrote:

  
    
#
Hi Mike,
The following simplification should help you to answer your own question.

covariate_aov = aov(dv~(covariate+group+iv1+iv2)^2,data=a)

You can find out more about how to specify models in Chap. 11 of the manual
"An Introduction to R."
I don't believe so. You can never be sure that someone who knew the answer
saw your first posting.

Regards, Mark.
Mike Lawrence-7 wrote: