mmm_model: Fit a multivariate mixed model using the pairwise fitting...

mmm_modelR Documentation

Fit a multivariate mixed model using the pairwise fitting approach

Description

Takes the stacked data and the user defined formulas for the fixed and random effects. Leverages the future.apply package to parallelize along pairs. Using a different number of workers than pairs may result in problems during the optimization process. The output of the pairwise model fitting is combined and any parameters that have been estimated multiple times are averaged. The procedure takes the individual level contributions to the Maximum Likelihood in order to estimate the standard errors for the parameter estimates with a robust sandwich estimator.

Usage

mmm_model(
  fixed,
  random,
  id,
  data,
  stacked_data,
  pairs,
  model_families,
  iter_EM = 100,
  iter_qN_outer = 10,
  ncores = NULL,
  ...
)

Arguments

fixed

character string with the fixed model part. This is passed to as.formula().

random

character string with the random model part. This is passed to as.formula().

id

The name of the column with subject ids in stacked_data.

data

the original data (in wide, unstacked format).

stacked_data

a list with the stacked data returned by the stack_data() function.

pairs

a character matrix with the pairs returned by the make_pairs() function.

model_families

a list with family names and indicators returned by the test_input_datatypes() function.

iter_EM

(default = 100) EM iterations passed to GLMMadaptive::mixed_model().

iter_qN_outer

(default = 10) outer Quasi Newton iterations passed to GLMMadaptive::mixed_model().

ncores

number of workers for multisession parallel plan.

...

additional arguments passed to GLMMadaptive::mixed_model().

Value

A list of 3 elements including:

  • estimatesA data.frame with the parameter estimates and standard errors

  • vcovThe Variance-Covariance matrix for the random effects

  • corrA correlation matrix for the random effects

Examples

## Not run: 
# enable parallel processing on a Windows machine
future::plan(multisession, workers=2)

# Fit the model
mmm_model(fixed = fixed,
random = random,
id = "id",
data = df,
stacked_data = df_stacked,
pairs = pairs,
model_families = model_info,
iter_EM = 100,
iter_qN_outer = 30,
nAGQ = 7)

# Reset the parallel plan back to its default.
future::plan("default")

## End(Not run)

JanvandenBrand/jmmm documentation built on May 30, 2022, 9:37 a.m.