[R] lme() with two random effects

Andrew Robinson A.Robinson at ms.unimelb.edu.au
Fri May 9 23:52:23 CEST 2008


Hi Mike,

I strongly suggest that you study Pinheiro and Bates (2000) to help
you make good decisions on the model specification and subsequent
steps.

In the meantime, you might find that exploring

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

is helpful.

Cheers

Andrew


On Fri, May 09, 2008 at 04:09:07PM -0300, Mike Lawrence wrote:
> 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
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Andrew Robinson  
Department of Mathematics and Statistics            Tel: +61-3-8344-6410
University of Melbourne, VIC 3010 Australia         Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/



More information about the R-help mailing list