[R-sig-ME] [R] lme nesting/interaction advice

Federico Calboli f.calboli at imperial.ac.uk
Mon May 12 12:13:50 CEST 2008

On 12 May 2008, at 10:05, Ken Beath wrote:
> There is only one random effect, so where does the crossing come  
> from ? The fixed effects vary across blocks, but they are fixed so  
> are just covariates. For this type of data the usual model in lme4  
> is y~fixed1+fixed2+1|group and for lme split into fixed and random  
> parts.

First off, whoa, an helpful reply! thanks for that, I hope I won't  
sound sarcastic or aggressive because I do not mean to be either.

Regarding your comment, the experiment was replicated three times, in  
3 different months. I would argue that for the fixed effects to be  
meaningful, they must have an effect over an above the effect:month  
interaction (because each fixed effect, and their interaction, might  
vary between each replicate). I would then argue I need to calculate

1) fixed.effect1:random.effect
2) fixed.effect2:random.effect
3) fixed.effect1:fixed.effect2:random.effect

to test if fixed.effect1 is meaningful (and use 1) as the error); if  
fixed.effect2 has is meaningful (and use 2) as the error);  
fixed.effect1:fixed.effect2 is meaningful (and use 3) as the error).

I'm happy to be correct if I am wrong here.

>> The problems seems to be that you want lme to work in the same way  
>> as an ANOVA table and it doesn't. The secret with lme and lme4 is  
>> to think about the structure of the data and describe with an  
>> equation. Then each term in the equation corresponds to part of  
>> the model definition in R.

I'll try to do that.
>> Once I have sorted how to specify such trivial model I'll face the  
>> horror of the nesting, in any case I attach a toy dataset I  
>> created especially to test how to specify the correct model (silly  
>> me).
> I'm a bit lost with your data file, it has 4 covariates, which is  
> more than enough for 2 fixed effects, assuming block is the  
> grouping and y the outcome.

In the data file, 'selection' and 'males' are fixed effects, and  
'month' is the effect I am using for the model we are discussing  
here. The y was generatde with runif() just to have something, I'm  
not expecting any intersting result, just to understand how to fit  
the right model.

In the dataset 'line' is nested within 'selection' and 'block' is  
nested within 'month'. That's the nesting I will have to take into  
account once I get the more straightforward (sic!) model we're  
discussing right.



Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com

More information about the R-sig-mixed-models mailing list