tabulate_mmrm_subgroups {tern.mmrm}R Documentation

Tabulation of MMRM Subgroups Results

Description

[Experimental]

This function tabulates the results from extract_mmrm_subgroups().

Usage

tabulate_mmrm_subgroups(
  lyt,
  df,
  vars = c("n_tot", "n", "lsmean", "diff", "ci"),
  .formats = list(n = "xx", n_tot = "xx", lsmean = "xx.x", diff = "xx.x", ci =
    "(xx.x, xx.x)", pval = "x.xxxx | (<0.0001)"),
  .labels = list(n = "n", n_tot = "Total n", lsmean = "Mean", diff = "Mean Difference",
    ci = paste0(round(100 * df$contrasts$conf_level[1]), "% CI"), pval = "p-value")
)

Arguments

lyt

(layout)
input layout where analyses will be added to.

df

(list)
of data frames containing all analysis variables, is the result from extract_mmrm_subgroups().

vars

(character)
the name of statistics to be reported among n_tot (total number of patients per group), n (number of patients per treatment arm and group), lsmean (least square mean point estimate), diff (difference of least square mean estimates between treatment and reference arm), ci (confidence interval of difference) and pval (p value of the diff, not adjusted for multiple comparisons). Note, the statistics n_tot, diff and ci are required.

.formats

(named list)
containing the formats for the statistics.

.labels

(named list)
containing the labels for the statistics.

Value

The rtables object.

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")
  )
)

df <- extract_mmrm_subgroups(
  fit = mmrm_results,
  visit = "VIS3",
  subgroups = c("RACE", "SEX")
)

## Table with default columns.
basic_table() %>%
  tabulate_mmrm_subgroups(df)

## Table with selected columns.
tab <- basic_table() %>%
  tabulate_mmrm_subgroups(
    df = df,
    vars = c("n_tot", "diff", "ci", "pval")
  )
tab

## Forest plot can be produced based on this very easily.
g_forest(tab, logx = FALSE, xlim = c(-10, 10), x_at = c(-10, -5, 0, 5, 10), vline = 0)

[Package tern.mmrm version 0.3.0 Index]