[R] within-subject factors in lme

Gang Chen gangchen at mail.nih.gov
Wed Aug 22 16:21:43 CEST 2007


Hi Lorenz,

I really appreciate your comments.

> If I understand correctly, you want to include the interactions  
> between the random and fixed terms?

Yes that is exactly I wanted to model.

> This is done like:
>
> model.lme <- lme(Beta ~ Trust*Sex*Freq,
>                  random = ~Trust*Sex*Freq|Subj, Model)
>
> But this needs a lot of observations as quite a few parameters need  
> to be estimated!

Well, I tried this as well, but it seems R kept hanging there and  
never finished the modeling. It is very likely due to some  
singularity as you suspected about the large number of parameters  
needed to estimate. But this is not a problem with aov. So does it  
mean that I can't run a similar model to that in aov with lme?

Sure I can simply run the following model

fit.lme <- lme(Beta ~ Trust*Sex*Freq, random = ~1|Subj, Model)

but I feel this is not good enough to account for cross-subject  
variations for those interactions. Why wouldn't those patterned  
variance-covariance matrix specifications work as I mentioned in my  
previous mail? Any more thoughts and suggestions?

> Possibly, you can not include the variable Sex in this, because I  
> assume that Subj is nested within Sex.

No, Sex is NOT a subject classifying factor. Instead it is a task- 
related within-subject factor.

Again thanks a lot for your help,
Gang

On Aug 22, 2007, at 6:52 AM, <lorenz.gygax at art.admin.ch>  
<lorenz.gygax at art.admin.ch> wrote:

> I don't think, this has been answered:
>
>> I'm trying to run a 3-way within-subject anova in lme with 3
>> fixed factors (Trust, Sex, and Freq), but get stuck with handling
>> the  random effects. As I want to include all the possible random
>> effects in the model, it would be something more or less
>> equivalent to using aov
>>
>>> fit.aov <- aov(Beta ~
>> Trust*Sex*Freq+Error(Subj/(Trust*Sex*Freq)),
>> Model)
>>
>> However I'm not so sure what I should do in lme. Sure
>>
>>> lme(Beta ~ Trust*Sex*Freq, random = ~1|Subj, Model)
>>
>> works fine, but it only models the random effect of the
>> intercept. I tried the following 4 possibilities:
>
> If I understand correctly, you want to include the interactions  
> between the random and fixed terms? This is done like:
>
> model.lme <- lme(Beta ~ Trust*Sex*Freq,
>                  random = ~Trust*Sex*Freq|Subj, Model)
>
> But this needs a lot of observations as quite a few parameters need  
> to be estimated! Possibly, you can not include the variable Sex in  
> this, because I assume that Subj is nested within Sex. If you just  
> refer to within and between subject effects and their corresponding  
> degrees of freedom: you should see this being handled automatically  
> and correctly by lme e.g. in the output of anova (model.lme)
>
> Lorenz
> -
> Lorenz Gygax
> Centre for proper housing of ruminants and pigs
> Agroscope Reckenholz-Tänikon Research Station ART
> Tänikon, CH-8356 Ettenhausen / Switzerland



More information about the R-help mailing list