# MMRM structure in R with fixed and random effects

I'm trying to recapitulate a statistical analysis based on a written description of an MMRM used to fit a patient data set.

The description is as follows:

Dependent variable: area (continuous, float)

Independent variables:

1. arm: 2 level factor
2. study_part: 2 level factor
3. m1: 2 level factor
4. m2: 2 level factor
5. m3: 2 level factor
6. visit: 3 level factor | random effect with unstructured correlation
7. Interaction terms between visit and all other factors | random effect

The above needs to be implemented in R, but I'm not as familiar with R syntax.

Currently I've arrived at:

mmrm <- lme(area ~ arm*visit + study_part*vist + m1*visit + m2*visit + m3*visit,
data = data,
method = "REML",
na.action = na.omit,
random = ~visit | pt_id #pt_id is to indicate random effect to be grouped by patient
correlation = corSymm(form = ~visit | pt_id),
weights = varIdent(form = ~1|vist),
control = lmeControl(msMaxIter = 200, opt = "optim")) #optim seems to be the preffered method, though not the default



My question is 3-fold:

1. With the above structure are visit and the related interaction terms being correctly handled as random effects?

2. My understanding of R is that when stating a covariate of the form arm*visit that the packaged will include terms for arm, visit, and arm*visit, where arm will be a fixed effect and the remaining 2 terms will be random - is this correct?

3. If the above structure is not correct - any suggestions on how to more correctly structure would be helpful

• If you write arm*visit that will just be fixed effects. By the way, with MMRM people often mean a model with a particular correlation structure between visits - such as unstructured to reflect that an equal correlation (as you use above) between visits is less likely and visits that are further apart should be "given the option" to be less correlated. People also often want a particular method for the denominator degrees of freedom (such as Kenward-Rogers), anything like that needed? May 16, 2022 at 7:25
• The correlation matrix is specified as unstructured. I believe the Kenward-Rogers method is used. Can you further specify what the right syntax would be then given the totality of the information provided? May 17, 2022 at 14:53
• Here's one version that gets pretty close: linkedin.com/pulse/… - but I think they only managed to figure out how to get the Satterthwaite adjustment for the DDFMs, not KR. May 17, 2022 at 14:58
• If no KR, that's still palatable - my root issue is just wanting to have more confidence that the model has the appropriate syntax for the fit (e.g., am I stating the fixed vs. random effects correctly?) I see in the link you provided they use the | in the main model statement, but they are using lmer vs. lme May 17, 2022 at 16:31
• Is there some reason you need to use a mixed model? From the description, it seems like generalized least squares or a multivariate (multiple-outcome) regression would handle the within-subject correlations at least as well. A multivariate model would effectively do a separate regression for each visit (similar to your variable 7) while accounting for correlations in error estimates.
– EdM
May 24, 2022 at 17:27

## 1 Answer

If you would be ok to use fixed instead of random effects for the visit interaction terms, you could use the new mmrm package:

library(mmrm)
fit <- mmrm(
area ~ arm*visit + study_part*visit + m1*visit + m2*visit + m3*visit + us(visit | pt_id),
data = data,
method = "Kenward-Roger"
)
summary(fit)


Since only have few levels for each of the factor variables that could be a reasonable approach.

Regarding your question 2, yes this would be correct and also apply in the mmrm package use case.