Skip to contents

Generic method to run emmeans::emmeans on all MMRM package objects using Kenward-Rogers degrees of freedom calculation. Please see emmeans::emmeans for further documentation.

Usage

mmrm_emmeans(
  obj,
  specs = NULL,
  group = NULL,
  cov.reduce = FALSE,
  nesting = NULL,
  ...
)

Arguments

obj

a fitted MMRM model

specs

A character vector specifying the names of the predictors over which EMMs are desired. See emmeans::emmeans for more details. If omitted, group must be specified, and emmeans and contrasts will be calculated across groups at each time point.

group

the group over which to calculate emmeans and contrasts. If specs is not specified, group must be specified.

cov.reduce

logical indicating whether to average over a continuous variable (usually time points) when calculating emmeans and contrasts. By default, FALSE

Value

see emmeans::emmeans

Details

Support for Kenward-Rogers degrees of freedom calculation is made possible with i) a custom emm_basis function and ii) addition of support for glsObject in the pbkrtest package (currently in a development version gkane26/pbkrtest@nlme).

Kenward-Rogers d.f. calculation is memory and computation time intensive. By default, running this method on a large dataset will throw an error to warn users. To bypass this error, please set the pbkrtest.limit argument to a number larger than the number of observations in the model.

Examples

if (FALSE) {
mmrm_emmeans(
  object = mmrm_object,
  specs = pairwise ~ time | treatment,
  mode = "kenward",
  pbkrtest.limit = emmeans::get_emm_option("pbkrtest.limit")
)
}