[R-sig-ME] Syntax for nested random effects

Stefan Th. Gries stgries at gmail.com
Tue Dec 17 03:21:40 CET 2013


Hi all

I have some questions regarding how to handle nested effects, which
are related to an earlier one but may be more concise. I hope these
are not too basic but I did look in several places incl. the draft
version of Bates (2010), Crawley (2013), Faraway (2006), and this
discussion <https://stat.ethz.ch/pipermail/r-sig-mixed-models/2007q3/000313.html>.

I am fitting a binomial glmer with some fixed effects (say, a and b)
and some random effects (say, x, y, q, w, and e). Now, the random
effects have the following structure:
- the random effect y is nested into x;
- the random effect e is nested into w, which in turn is nested u

Thus, I thought the formula has to look like this:
m1a <- glmer(Y ~ a + b + (1|x/y) + (1|q/w/e))

## Question 1a: Is that correct?
## Question 1b: following Bates (2010:42) (and Crawley (2013:692), I
should also be able to say this:

m1b <- glmer(Y ~ a + b + (1|x) + (1|y) + (1|q) + (1|w) + (1|e))

However, while the results for the fixed effects differ only just a
bit, the results for the random effects are very different:

> summary(m1a)[[13]]
 Groups                  Name        Std.Dev.
 e:(w:q) (Intercept) 1.082242
 y:x             (Intercept) 0.020518
 x                   (Intercept) 0.016475
 w:q            (Intercept) 0.021113
 q                    (Intercept) 0.435931
> summary(m1b)[[13]]
 Groups   Name        Std.Dev.
 e (Intercept) 1.0906344
 y    (Intercept) 0.0090171
 x    (Intercept) 0.0148924
 w  (Intercept) 0.0034299
 q     (Intercept) 0.4336554

## Question 2a: If I now want to see whether, say, the level of
resolution/granularity e is needed or not, can I do that as follows?
m2 <- glmer(Y ~ a + b + (1|x/y) + 1(q/w))
anova(m1a, m2, test="Chisq")

## Question 2b: If I now want to see whether, say, the level of
resolution/granularity w is needed or not, can I do that as follows?
q_w <- interaction(q,w)
m3 <- glmer(Y ~ a + b + (1|x/y) + 1(q_w/e))

Any input would be much appreciated
STG



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