[R] lme() with two random effects

Mike Lawrence Mike.Lawrence at DAL.CA
Fri May 9 21:09:07 CEST 2008


Hi all,

I have collected response time data from 178 participants ('sub') for  
each combination of 4 within-Ss factors ('con','int','tone','cue').  
Additionally, I have recorded the gender of each participant, so this  
forms a between-Ss factor ('gender'). Normally this would be analyzed  
using aov:

a=read.table('http://tinyurl.com/4pv5mh')
a$sub = factor(a$sub)
aov( #this may take a while!
	x~gender*con*int*tone*cue+Error(sub/(con*int*tone*cue))
	,data=a
)

However, I'd like to also look at any effects of age, recorded in  
months ('age'). Since subjects were randomly sampled, their age should  
be a random effect and it is furthermore an unbalanced factor (N  
varies across levels of age). So I'm seeking the proper formulas to  
use in lme(). The following attempt yields the following error:

library('nlme')
lme(
	x ~ gender*con*int*tone*cue
	, random = ~ 1 | sub*age
	, data = a
)

Error in getGroups.data.frame(dataMix, groups) :
   Invalid formula for groups


I would be very grateful for any suggestions.

Cheers,

Mike

--
Mike Lawrence
Graduate Student, Department of Psychology, Dalhousie University

Website: http://memetic.ca

Public calendar subscribe link for iCal users:
webcal://icalx.com/public/informavore/Public.ics

"The road to wisdom? Well, it's plain and simple to express:
Err and err and err again, but less and less and less."
	- Piet Hein



More information about the R-help mailing list