[R-sig-ME] What is the appropriate zero-correlation parameter model for factors in lmer?

Maarten Jung M@@rten@Jung @end|ng |rom m@||box@tu-dre@den@de
Wed Oct 16 16:56:33 CEST 2019


Dear list,

After going through the posts [1] and [2] again, I identified the
following nesting structure (arrows indicate nesting) as the one I
want to go with for modelling some new data:

m1 -> m2a/m2b/m2c -> m3 -> m4

library("lme4")
data("Machines", package = "MEMSS")
d <- Machines
mat <- model.matrix(~ 0 + Machine, d)
A <- mat[, 1]
B <- mat[, 2]
C <- mat[, 3]

m1 <- lmer(score ~ Machine + (0 + Machine | Worker), d)

m2a <- lmer(score ~ Machine + (1 | Worker) +
                              (0 + dummy(Machine, "A") | Worker) +
                              (0 + dummy(Machine, "B") | Worker) +
                              (0 + dummy(Machine, "C") | Worker), d)

m2b <- lmer(score ~ Machine + (1 | Worker) + (0 + A + B + C || Worker), d)

m2c <- afex::lmer_alt(score ~ Machine + (1 | Worker) + (0 + Machine ||
Worker), d)

# m2a, m2b, and m2c are equivalent
all.equal(logLik(m2a), logLik(m2b), logLik(m2c))

m3 <- lmer(score ~ Machine + (1 | Worker) + (1 | Worker:Machine), d)

m4 <- lmer(score ~ Machine + (1 | Worker), d)

In my new data there are multiple observations per cell of a (at
least) 2x3 within-subjects design.
I know that m1 (denoting the two factors with f1 and f2, respectively)
would look like

lmer(y ~ f1*f2 + (1 + f1*f2 | subject), data)

and I think that m3 should be

lmer(y ~ f1*f2 + (1 | subject) + (1 | f1:subject) + (1 | f2:subject), data)

but I'm struggling to figure out what m2a (or m2b/m2c) would look like
in the (at least) 2-factorial case.
I would be grateful if someone could provide the appropriate syntax
and even more so if it would be as easy as the one in m2c (which I
think would be much simpler than the one need for m2a or m2b).

Best,
Maarten

[1] https://stat.ethz.ch/pipermail/r-sig-mixed-models/2018q2/026775.html
[2] https://stats.stackexchange.com/questions/345842/what-is-the-appropriate-zero-correlation-parameter-model-for-factors-in-lmer



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