[R-sig-ME] Appropriate model reduction sequence for factorial design in glmmTMB
Maarten Jung
M@@rten@Jung @end|ng |rom m@||box@tu-dre@den@de
Tue Oct 22 22:01:06 CEST 2019
Dear list,
Sorry for basically restating my question here [1], but I think it
might be worth a separate thread as it might well be much easier to
answer with glmmTMB.
After going through the posts [2] and [3] 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 like this in glmmTMB syntax
glmmTMB(y ~ f1*f2 + us(f1*f2 | subject), data, REML = TRUE)
So now I'm struggling to figure out what m2a (or m2b/m2c) and m3 would
look like in the (at least) 2-factorial case.
My guess is that m2 would look like this in glmmTMB syntax
glmmTMB(y ~ f1*f2 + (1 | subject) + diag(0 + f1*f2 | subject), data,
REML = TRUE)
and that this might correspond to the following afex:lmer_alt() model
afex::lmer_alt(y ~ f1*f2 + (1 | subject) + (0 + f1*f2 || subject ), data)
But I'm not sure about m3.
I would be grateful if someone could provide the appropriate glmmTMB
syntax (additionally or alternatively, lmer/afex::lmer_alt syntax is
still welcome in the other thread).
Best,
Maarten
[1] https://stat.ethz.ch/pipermail/r-sig-mixed-models/2019q4/028222.html
[2] https://stat.ethz.ch/pipermail/r-sig-mixed-models/2018q2/026775.html
[3] 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