tabulate_mmrm: Tabulation of 'MMRM' Results

tabulate_mmrmR Documentation

Tabulation of MMRM Results

Description

[Stable]

These functions can be used to produce tables from a fitted MMRM produced with fit_mmrm().

Usage

## S3 method for class 'tern_mmrm'
as.rtable(x, type = c("fixed", "cov", "diagnostic"), ...)

h_mmrm_fixed(x, format = "xx.xxxx")

h_mmrm_cov(x, format = "xx.xxxx")

h_mmrm_diagnostic(x, format = "xx.xxxx")

## S3 method for class 'tern_mmrm'
tidy(x, ...)

s_mmrm_lsmeans(df, .in_ref_col, show_relative = c("reduction", "increase"))

a_mmrm_lsmeans(df, .in_ref_col, show_relative = c("reduction", "increase"))

s_mmrm_lsmeans_single(df)

a_mmrm_lsmeans_single(df)

summarize_lsmeans(
  lyt,
  arms = TRUE,
  ...,
  table_names = "lsmeans_summary",
  .stats = NULL,
  .formats = NULL,
  .indent_mods = NULL,
  .labels = NULL
)

Arguments

x

(tern_mmrm)
the original result from fit_mmrm().

type

(string)
type of table which should be returned.

...

additional argument format for controlling the numeric format.

format

(string)
format for the numbers in the table.

df

(⁠data frame⁠)
data set containing all analysis variables.

.in_ref_col

(logical)
TRUE when working with the reference level, FALSE otherwise.

show_relative

should the "reduction" (control - treatment, default) or the "increase" (treatment - control) be shown for the relative change from baseline?

lyt

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

arms

(flag)
should treatment variable be considered when using summarize_lsmeans layout generating function.

table_names

(character)
this can be customized in case that the same vars are analyzed multiple times, to avoid warnings from rtables.

.stats

(character)
statistics to select for the table.

.formats

(named character or list)
formats for the statistics.

.indent_mods

(named integer)
indent modifiers for the labels.

.labels

(named character)
labels for the statistics (without indent).

Value

as.rtable.tern_mmrm() returns the fixed effects, covariance estimate or diagnostic statistics tables.

Functions

  • as.rtable(tern_mmrm): Produce simple MMRM tables via the generic as.rtable().

  • h_mmrm_fixed(): Helper function to produce fixed effects table.

  • h_mmrm_cov(): Helper function to produce a covariance matrix table.

  • h_mmrm_diagnostic(): Helper function to produce a diagnostic statistics table.

  • tidy(tern_mmrm): Helper method (for broom::tidy()) to prepare a data.frame from an tern_mmrm object containing the least-squares means and contrasts.

  • s_mmrm_lsmeans(): Statistics function which is extracting estimates from a tidied least-squares means data frame.

  • a_mmrm_lsmeans(): Formatted Analysis function which can be further customized by calling rtables::make_afun() on it. It is used as afun in rtables::analyze().

  • s_mmrm_lsmeans_single(): Statistics function which is extracting estimates from a tidied least-squares means data frame when ARM is not considered in the model.

  • a_mmrm_lsmeans_single(): Formatted Analysis function (when ARM is not considered in the model) which can be further customized by calling rtables::make_afun() on it. It is used as afun in rtables::analyze().

  • summarize_lsmeans(): Analyze function for tabulating least-squares means estimates from tidied mmrm results.

Examples

result <- fit_mmrm(
  vars = list(
    response = "FEV1",
    covariates = c("RACE", "SEX"),
    id = "USUBJID",
    arm = "ARMCD",
    visit = "AVISIT"
  ),
  data = mmrm_test_data,
  cor_struct = "unstructured",
  weights_emmeans = "equal"
)
as.rtable(result, type = "cov", format = "xx.x")

result_no_arm <- fit_mmrm(
  vars = list(
    response = "FEV1",
    covariates = c("RACE", "SEX"),
    id = "USUBJID",
    visit = "AVISIT"
  ),
  data = mmrm_test_data,
  cor_struct = "unstructured",
  weights_emmeans = "equal"
)
as.rtable(result_no_arm, type = "cov", format = "xx.x")
df <- broom::tidy(result)
df_no_arm <- broom::tidy(result_no_arm)
s_mmrm_lsmeans(df[8, ], .in_ref_col = FALSE)
s_mmrm_lsmeans_single(df_no_arm[4, ])
library(dplyr)

dat_adsl <- mmrm_test_data %>%
  select(USUBJID, ARMCD) %>%
  unique()
basic_table() %>%
  split_cols_by("ARMCD", ref_group = result$ref_level) %>%
  add_colcounts() %>%
  split_rows_by("AVISIT") %>%
  summarize_lsmeans(
    .stats = c("n", "adj_mean_se", "adj_mean_ci", "diff_mean_se", "diff_mean_ci"),
    .labels = c(adj_mean_se = "Adj. LS Mean (Std. Error)"),
    .formats = c(adj_mean_se = sprintf_format("%.1f (%.2f)"))
  ) %>%
  build_table(
    df = broom::tidy(result),
    alt_counts_df = dat_adsl
  )

basic_table() %>%
  split_rows_by("AVISIT") %>%
  summarize_lsmeans(arms = FALSE) %>%
  build_table(
    df = broom::tidy(result_no_arm),
    alt_counts_df = dat_adsl
  )

tern.mmrm documentation built on Sept. 30, 2024, 9:20 a.m.