[R-sig-ME] glmmTMB: fit mixed model with different covariance between two groups

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Tue Nov 17 00:12:00 CET 2020


   The standard way to do this would be to set up a 0/1 dummy variable 
that indicated the arm of the treatment and allow it to interact with 
the random effects, e.g. something like this:

data$g1 <- lme4::dummy(data$group,"0")

data$g2 <- lme4::dummy(data$group,"1")

y ~ time*group + us(0 + g1:time | id) + us(0 + g2:time | id)

The two RE terms appear to be redundant, but each one applies only to individuals in one group (because the effect of constructing an interaction with a numerical (0/1) covariate is essentially to multiply the effects by either 0 or 1).

   I haven't tested this, of course :-)


On 11/16/20 11:26 AM, Noci, Alessandro via R-sig-mixed-models wrote:
> Hi all,
>
> I am interested in fitting a linear mixed model with different unstructured
> covariance between the two arms.
>
> To give you an idea, suppose that I have longitudinal data related to
> patients belonging to two different arms in a clinical trial. The dataset
> has the following variables:
>
>     1. *id*: the id of the patients.
>     2. *group*: 2 levels factor indicating which arm each patient belongs to.
>     3. *time: *time-variable.
>     4. *var1:* baseline covariate.
>     5. *y: *outcome variable.
>
> # simulate data (toy example)
>
> set.seed(123)
> data = data.frame("id" = rep(1:40, each = 4), "group" = factor(rep(c(0,1),
> each = 20*4)), "time" = factor(rep(1:4, 40)), "var1" = rnorm(40*4), "y" =
> rnorm(40*4))
>
> I can fit a linear mixed model with unstructured covariance calling:
>
> # fit model
>
> fit = glmmTMB(y ~ time*group + us(0 + time | id), data = data, dispformula
> = ~0, REML = TRUE, control=
> glmmTMBControl(optimizer=optim,optArgs=list(method="L-BFGS-B")))
>
> However this is assuming that the covariance matrices of the two groups are
> identical. I would like to fit the model assuming a
> different (unstructured) covariance matrix for each arm and extract the two
> estimated covariance matrices. Is it possible to do this?
>
> Best,
> Alessandro
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models



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