[R] lme() direction

Dieter Menne dieter.menne at menne-biomed.de
Sat Feb 7 17:02:00 CET 2009

Mike Lawrence <mike <at> thatmike.com> writes:

Thanks for the excellent reproducible sample set!

> I'm most interested in the interaction between color and type, but I
> know that there is likely an effect of word. Yet since word is not
> completely crossed with type, simply adding it to an aov() won't work.
> A colleague recommended I look into lme() but so far I can't figure
> out the proper call.

Without word, it would be

summary(lme(rt~type*color, data=a,random=~1|id))

With the interaction, the extreme would be 
summary(lme(rt~type*color*word, data=a,random=~1|id))

or, less extreme

summary(lme(rt~type*color+color:word, data=a,random=~1|id))

but all these fail because of the rather degenerate structure 
of you data set. While lmer in package lme4 allows for a wider
set of solutions, I currently do not see how it could help,
but I might be wrong with p=0.5.

               word happy joy sad grumpy
type     color                          
positive white         93  90   0      0
         red           90  88   0      0
         green         88  87   0      0
negative white          0   0  88     95
         red            0   0  91     85
         green          0   0  88     88
> Another issue is whether to collapse across repetition before running
> the stats, particularly since errors will leave unequal numbers of
> observations per cell if it's left in.

That's one of the points where you have little to bother with the lme
approach. Collapsing would give equal weights to unequal numbers of
repeat, and might of minor importance when not too extreme, though.


			,repetition = 1:10
			,repetition = 1:10

#add some fake rt data

#And because people make errors sometimes:
a$error = rbinom(length(a[,1]),1,.1)

#remove error trials because they're not psychologically interesting:

summary(lme(rt~type*color, data=a,random=~1|id))

More information about the R-help mailing list