extract_mmrm_subgroups {tern.mmrm}R Documentation

Extraction of MMRM Subgroup Results based on Population Model Definition

Description

[Experimental]

This prepares LS mean estimates and contrasts for a specific visit and treatment arm relative to the reference arm, along with a list of subgroup variables and corresponding (grouped) factor levels.

Usage

extract_mmrm_subgroups(
  fit,
  visit,
  subgroups = NULL,
  groups_lists = list(),
  treatment_arm = fit$treatment_levels[1L],
  label_all = "All Patients"
)

Arguments

fit

(tern_mmrm)
model fit on the total population.

visit

(string)
single visit or name of averages of visits (referring to the averages specified when creating the fit).

subgroups

(character or NULL)
names of subgroup variables to use in the forest plot, these need to be factors.

groups_lists

(named list of list)
optionally contains for each subgroups variable a list, which specifies groups of factor levels, see details.

treatment_arm

(string)
single treatment arm to compare with the reference arm.

label_all

(string)
label for the total population analysis.

Details

The groups_lists argument is handy when you don't want to have subgroups identical to the original levels of the factor variable. This might be the case when you want to merge levels into a single subgroup, define overlapping subgroups or omit levels completely. Then you insert an element into groups_lists with the name of the subgroups variable and containing as a named list the subgroup definitions. See the example below.

Value

A list with two elements:

Note

If the original model vars include covariates which are used here in subgroups then these are dropped from covariates before the corresponding model is fitted.

Examples

mmrm_results <- fit_mmrm(
  vars = list(
    response = "FEV1",
    covariates = "RACE",
    id = "USUBJID",
    arm = "ARMCD",
    visit = "AVISIT"
  ),
  data = mmrm_test_data,
  cor_struct = "compound symmetry",
  weights_emmeans = "equal",
  averages_emmeans = list(
    "VIS1+2" = c("VIS1", "VIS2")
  )
)

extract_mmrm_subgroups(
  fit = mmrm_results,
  visit = "VIS3",
  subgroups = c("RACE", "SEX"),
  groups_lists = list(
    RACE = list(
      A = c("Asian", "White"),
      B = c("Black or African American", "White")
    )
  )
)

[Package tern.mmrm version 0.3.0 Index]