Thanks Ben for your reply,
I used:
glmmTMB(count ~ Trt + (0 + dummy(Trt, "0") + dummy(Trt, "0"):zAge |
patient) + (0 + dummy(Trt, "1") + dummy(Trt, "1"):zAge | patient), data =
epilepsy)
which gave me similar SDs for the random intercepts and slopes as the brms
output but the correlations were 1 and -1 (see below) which is quite
different from the brms output (0.56 and -0.84).
Given that the correlations were exactly 1 and -1, I'm wondering if it is
the exact same fit as brms (count ~ Trt + (zAge|gr(patient, by = Trt)),
data = epilepsy), or if something differs in how the covariances are
estimated ?
Thomas
Conditional model:
Groups Name Variance Std.Dev. Corr
patient dummy(Trt, "0") 57.57 7.588
dummy(Trt, "0"):zAge 11.60 3.405 1.00
patient.1 dummy(Trt, "1") 103.60 10.178
dummy(Trt, "1"):zAge 38.37 6.194 -1.00
Residual 32.21 5.676
count ~ Trt + (0 + dummy(Trt, "Trt0"):zAge | patient) +
(0 + dummy(Trt, "Trt1"):zAge | patient)
might work in either glmmTMB or lme4. The dummy() function (which is in
the lme4 package, you may need to load it even if you're using glmmTMB)
is 'sugar' for creating a numeric dummy variable. An interaction with a
numeric variable corresponds to multiplying the interacting term by the
variable, so (for example) the first term is zero except for
observations in Trt0.
This hack gets awkward if you have lots of groups (although you can
always construct the formula programmatically).
In lme4 you may have to use lmerControl() to override some of the
checks that there aren't too many random-effects levels.
Ben Bolker
[[alternative HTML version deleted]]