These functions can be used to produce tables from a fitted MMRM produced with
fit_mmrm().
# 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
)(tern_mmrm)
the original result from fit_mmrm().
(string)
type of table which should be returned.
additional argument format for controlling the numeric format.
(string)
format for the numbers in the table.
(data frame)
data set containing all analysis variables.
(logical)TRUE when working with the reference level, FALSE otherwise.
should the "reduction" (control - treatment, default) or the "increase"
(treatment - control) be shown for the relative change from baseline?
(layout)
input layout where analyses will be added to.
(flag)
should treatment variable be considered when using
summarize_lsmeans layout generating function.
(character)
this can be customized in case that the same vars are analyzed multiple times,
to avoid warnings from rtables.
(character)
statistics to select for the table.
(named character or list)
formats for the statistics.
(named integer)
indent modifiers for the labels.
(named character)
labels for the statistics (without indent).
as.rtable.tern_mmrm() returns the fixed effects, covariance estimate or
diagnostic statistics tables.
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.
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"
)
#> Error in refit_multiple_optimizers(fit = fit, control = control): No optimizer led to a successful model fit. Please try to use a different covariance structure or other covariates.
as.rtable(result, type = "cov", format = "xx.x")
#> Error: object 'result' not found
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"
)
#> Error in refit_multiple_optimizers(fit = fit, control = control): No optimizer led to a successful model fit. Please try to use a different covariance structure or other covariates.
as.rtable(result_no_arm, type = "cov", format = "xx.x")
#> Error: object 'result_no_arm' not found
df <- broom::tidy(result)
#> Error: object 'result' not found
df_no_arm <- broom::tidy(result_no_arm)
#> Error: object 'result_no_arm' not found
s_mmrm_lsmeans(df[8, ], .in_ref_col = FALSE)
#> Error in df[8, ]: object of type 'closure' is not subsettable
s_mmrm_lsmeans_single(df_no_arm[4, ])
#> Error: object 'df_no_arm' not found
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
)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'obj' in selecting a method for function 'last_rowsplit': error in evaluating the argument 'obj' in selecting a method for function 'next_rpos': object 'result' not found
basic_table() %>%
split_rows_by("AVISIT") %>%
summarize_lsmeans(arms = FALSE) %>%
build_table(
df = broom::tidy(result_no_arm),
alt_counts_df = dat_adsl
)
#> Error: object 'result_no_arm' not found