[R-sig-ME] separate variance-covariance matrix for each level of grouping variable

Thomas MERKLING thom@@merk||ng00 @end|ng |rom gm@||@com
Thu Aug 22 12:10:33 CEST 2019


Hi all,

I'm interested in modeling a separate variance-covariance matrix for
different levels of a factor variable. I have a SAS example (using the
epilepsy from the brms package as an example):

proc mixed data = epilepsy method = reml;
                  class patient Trt;
                  model count = Trt /s ddfm = satterth;
                 random int zAge / type = un subject=patient group=Trt;
run;

The gr argument in the brms package seems to enable to do that too, as the
group-level effects correspond to a random intercept and slope and a
covariance between the two estimated separately for each level of the Trt
variable.

fit3 <- brm(count ~ Trt + (zAge|gr(patient, by = Trt)), data = epilepsy)

Group-Level Effects:
~patient (Number of levels: 59)
                              Estimate Est.Error l-95% CI u-95% CI
Eff.Sample Rhat
sd(Intercept:Trt0)                7.86      1.41     5.39    10.91
1071 1.00
sd(zAge:Trt0)                     4.14      2.62     0.25     9.97
 546 1.00
sd(Intercept:Trt1)                9.23      1.96     5.37    13.31
 691 1.00
sd(zAge:Trt1)                     7.60      2.24     3.92    12.54
 586 1.01
cor(Intercept:Trt0,zAge:Trt0)     0.57      0.42    -0.60     0.99
1252 1.00
cor(Intercept:Trt1,zAge:Trt1)    -0.85      0.15    -1.00    -0.45
 594 1.00

How do I need to specify the random effect part of the model in lme4 or
glmmTMB to get the same results?

I have tried: fit4 <- glmmTMB(count ~ Trt + (0 + Trt*zAge | patient), data
= epilepsy)
but it seems to calculate correlations between each pair of random
intercept and slope and not only within a factor level.

Random effects:

Conditional model:
 Groups   Name      Variance  Std.Dev.    Corr
 patient    Trt0           56.221   7.498
                Trt1          103.601  10.178    -0.92
                  zAge       15.793   3.974       0.94 -0.97
            Trt1:zAge        6.443   2.538       0.78 -0.92  0.80
 Residual                   32.211   5.675

Thanks in advance for your help,
Thomas

	[[alternative HTML version deleted]]



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