Fit an MMRMSource:
mmrm( formula, data, weights = NULL, covariance = NULL, reml = TRUE, control = mmrm_control(...), ... )
the model formula, see details.
the data to be used for the model.
an optional vector of weights to be used in the fitting process. Should be
NULLor a numeric vector.
a covariance structure type definition as produced with
cov_struct(), or value that can be coerced to a covariance structure using
as.cov_struct(). If no value is provided, a structure is derived from the provided formula.
whether restricted maximum likelihood (REML) estimation is used, otherwise maximum likelihood (ML) is used.
fine-grained fitting specifications list created with
arguments passed to
formula typically looks like:
FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID)
so specifies response and covariates as usual, and exactly one special term
defines which covariance structure is used and what are the time point and
subject variables. The covariance structures in the formula can be
The time points have to be unique for each subject. That is, there cannot be time points with multiple observations for any subject. The rationale is that these observations would need to be correlated, but it is not possible within the currently implemented covariance structure framework to do that correctly. Moreover, for non-spatial covariance structures, the time variable must be a factor variable.
When optimizer is not set, first the default optimizer
L-BFGS-B) is used to fit the model. If that converges, this is returned.
If not, the other available optimizers from
tried (in parallel if
n_cores is set and not on Windows).
If none of the optimizers converge, then the function fails. Otherwise
the best fit is returned.
Note that fine-grained control specifications can either be passed directly
mmrm function, or via the
control argument for bundling together
mmrm_control() function. Both cannot be used together, since
this would delete the arguments passed via
mmrm object is also an
mmrm_fit and an
therefore corresponding methods also work (see
Additional contents depend on the choice of the adjustment
If Satterthwaite adjustment is used, the Jacobian information
If Kenward-Roger adjustment is used,
kr_compcontains necessary components and
beta_vcov_adjincludes the adjusted coefficients covariance matrix.
Use of the package
emmeans is supported, see
NA values are always omitted regardless of
When the number of visit levels is large, it usually requires large memory to create the
covariance matrix. By default, the maximum allowed visit levels is 100, and if there are more
visit levels, a confirmation is needed if run interactively.
You can use
options(mmrm.max_visits = <target>) to increase the maximum allowed number of visit
levels. In non-interactive sessions the confirmation is not raised and will directly give you an error if
the number of visit levels exceeds the maximum.
fit <- mmrm( formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID), data = fev_data ) # Direct specification of control details: fit <- mmrm( formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID), data = fev_data, weights = fev_data$WEIGHTS, method = "Kenward-Roger" ) # Alternative specification via control argument (but you cannot mix the # two approaches): fit <- mmrm( formula = FEV1 ~ RACE + SEX + ARMCD * AVISIT + us(AVISIT | USUBJID), data = fev_data, control = mmrm_control(method = "Kenward-Roger") )