[R] Multilevel model in lme4 and nlme
Ben Bolker
bbolker at gmail.com
Mon Sep 12 22:43:06 CEST 2011
jonas garcia <garcia.jonas80 <at> googlemail.com> writes:
> I am trying to fit some mixed models using packages lme4 and nlme.
>
> I did the model selection using lmer but I suspect that I may have some
> autocorrelation going on in my data so I would like to have a look using the
> handy correlation structures available in nlme.
>
> The problem is that I cannot translate my lmer model to lme:
>
> mod1<- lmer(y~x + (1|a:b) + (1|b:c), data=mydata)
>
> "a", "b" and "c" are factors with "c" nested in "b" and "b" nested in "a"
>
> The best I can do with lme is:
>
> mod2<- lme(y~x, random=list(a=~1, b=~1, c=~1), data=mydata)
>
> which is the same as:
>
> lmer(y~x + (1|a) + (1|a:b) + (1|a:b:c), data=mydata)
>
> I am not at all interested in random effects (1|a) and (1|a:b:c) as they are
> not significant. I just need two random intercepts as specified in mod1. How
> can I translate mod1 into lme language?
>
> Any help on this would be much appreciated.
This would probably be better on the r-sig-mixed-models list.
Does random=list(~1|a:b,~1|b:c) work?
I would be a little bit careful throwing out ~1|a (non-significance
is not necessarily sufficient reason to discard a term from the model --
it depends a lot on your procedure), and with the interpretation of
your nesting. If b is only explicitly and not implicitly nested in a
(i.e. if there a levels of 'b' that occur in more than one level of 'a',
for example if a corresponded to families, b corresponded to individuals,
and you labeled individuals 1..N_b_i in each family) then I'm not
sure how you would actually interpret b:c, as it would be crossed
rather than nested. But assuming that your model specification in
lmer is correct and sensible, I think my suggestion above should (?)
work to get the equivalent in lme.
>
> Jonas
More information about the R-help
mailing list