[R] [R-sig-ME] lme nesting/interaction advice
Douglas Bates
bates at stat.wisc.edu
Mon May 12 20:05:14 CEST 2008
On Mon, May 12, 2008 at 11:22 AM, Federico Calboli
<f.calboli at imperial.ac.uk> wrote:
> On 12 May 2008, at 17:09, Douglas Bates wrote:
>
>> I'm entering this discussion late so I may be discussing issues that
>> have already been addressed.
>>
>> As I understand it, Federico, you began by describing a model for data
>> in which two factors have a fixed set of levels and one factor has an
>> extensible, or "random", set of levels and you wanted to fit a model
>> that you described as
>>
>> y ~ effect1 * effect2 * effect3
>>
>> The problem is that this specification is not complete.
>
> My apologies for that, I thought that the above formula was the shorthand
> for what I would call the 'full' model, i.e. the single factors and the 2
> and 3 ways interactions.
As I indicated, the trick is that the interaction of a fixed factor
and a random factor can be defined in more than one way.
It sounds as if what you want is
lmer(y ~ factor1 * factor2 + (1|factor3) + (1|factor1:factor3) +
(1|factor2:factor3) + (1|factor1:factor2:factor3), ...)
but I'm not sure.
>> An interaction of factors with fixed levels and a factor with random
>> levels can mean, in the lmer specification,
>>
>> lmer(y ~ effect1 * effect2 + (1| effect3) + (1|effect1:effect2:effect3),
>> ...)
>>
>> or
>>
>> lmer(y ~ effect1 * effect2 + (effect1*effect2 | effect3), ...)
>>
>> or other variations. When you specify a random effect or an random
>> interaction term you must, either explicitly or implicitly, specify
>> the form of the variance-covariance matrix associated with those
>> random effects.
>
> I'll play around with this and see what I can get.
>>
>> The "advantage" that other software may provide for you is that it
>> chooses the model for you but that, of course, means that you only
>> have the one choice.
>
> I'm more than happy to stick to R, and to put more legwork into my models
>>
>> If you can describe how many variance components you think should be
>> estimated in your model and what they would represent then I think it
>> will be easier to describe how to fit the model.
>
> I'll work on that. Incidentally, what/where is the most comprehensive and up
> to date documentation for lme4? the pdfs coming with the package? I suspect
> knowing which are the right docs will help a lot in keeping me within the
> boundaries of civility and prevent me from annoying anyone (which is not
> something I sent forth to do on purpose).
Documentation for lme4 is pretty sketchy at present. I hope to remedy
that during our summer break.
More information about the R-help
mailing list