Skip to contents

Simulate a "clinical" dataset according to assumptions of the MMRM. Datasets should have "observations" at a selected number of discrete timepoints. Observations are predicted by:

  • the mean observation at each timepoint

  • the effect of baseline at each timepoint

  • the effect of arm at each timepoint

  • residual covariance matrix

Usage

mmrm_simulate(
  n_per_arm = 50,
  n_timepoints = 5,
  effect_tp = 8,
  effect_baseline = -0.5,
  effect_arm = 2,
  covariance = NULL,
  variance = 10,
  correlation = 0,
  baseline = c(25, 5),
  p_missing = 0.1
)

Arguments

n_per_arm

the number of subjects per arm

n_timepoints

the number of timepoints. If effects are specified as vectors, this is ignored.

effect_tp

mean observation at each timepoint. Either a vector with length equal to the number of timepoints or a scalar.

effect_baseline

effect of baseline value at each timepoint. Either a vector with length equal to the number of timepoints or a scalar.

effect_arm

effect of arm at each timepoint. Either a vector with length equal to the number of timepoints or a scalar.

covariance

full residual covariance matrix. Either covariance of both of variance and correlation should be specified.

variance

variance at each timepoint. Either a vector with length equal to the number of timepoints or a scalar. Either both of variance and correlation or covariance should be specified

correlation

correlation of residuals across timepoints. Should be a scalar or vector with length: timepoints * (timepoints - 1) / 2. Either both of variance and correlation or covariance should be specified.

baseline

mean and variance of baseline scores

p_missing

probability of missing data at each timepoint. Either a vector with length equal to the number of timepoints or a scalar.

Value

data.frame with simulated data in the long format with the following fields:

  • n_subs: the nubmer of subjects

  • subject: subject id

  • arm: the study arm or group

  • base: baseline score

  • time: time point of observation

  • chg: the change score at the given time point (i.e., the outcome)