tabulate_lsmeans {junco} | R Documentation |
Tabulation of Least Square Means Results
Description
These functions can be used to produce tables from LS means, e.g. from fit_mmrm_j()
or fit_ancova()
.
Usage
## S3 method for class 'tern_model'
tidy(x, ...)
s_lsmeans(
df,
.in_ref_col,
alternative = c("two.sided", "less", "greater"),
show_relative = c("reduction", "increase")
)
a_lsmeans(
df,
ref_path,
.spl_context,
...,
.stats = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
Arguments
x |
( |
... |
additional arguments for the lower level functions. |
df |
( |
.in_ref_col |
( |
alternative |
( |
show_relative |
should the 'reduction' ( |
ref_path |
( |
.spl_context |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
Value
for s_lsmeans
, a list containing the same statistics returned by tern.mmrm::s_mmrm_lsmeans,
with the additional diff_mean_est_ci
three-dimensional statistic. For a_lsmeans
,
a VertalRowsSection
as returned by rtables::in_rows.
Functions
-
tidy(tern_model)
: Helper method (forbroom::tidy()
) to prepare adata.frame
from antern_model
object containing the least-squares means and contrasts. -
s_lsmeans()
: Statistics function which is extracting estimates from a tidied least-squares means data frame. -
a_lsmeans()
: Formatted Analysis function to be used asafun
Note
These functions have been forked from the tern.mmrm
package. Additional features
are:
Additional
ref_path
argument for tern.mmrm::summarize_lsmeans().The function is more general in that it also works for LS means results from ANCOVA
Additional statistic
diff_mean_est_ci
is returnedP-value sidedness can be chosen
Examples
result <- fit_mmrm_j(
vars = list(
response = "FEV1",
covariates = c("RACE", "SEX"),
id = "USUBJID",
arm = "ARMCD",
visit = "AVISIT"
),
data = mmrm::fev_data,
cor_struct = "unstructured",
weights_emmeans = "equal"
)
df <- broom::tidy(result)
s_lsmeans(df[8, ], .in_ref_col = FALSE)
s_lsmeans(df[8, ], .in_ref_col = FALSE, alternative = "greater", show_relative = "increase")
dat_adsl <- mmrm::fev_data |>
dplyr::select(USUBJID, ARMCD) |>
unique()
basic_table() |>
split_cols_by("ARMCD") |>
add_colcounts() |>
split_rows_by("AVISIT") |>
analyze(
"AVISIT",
afun = a_lsmeans,
show_labels = "hidden",
na_str = tern::default_na_str(),
extra_args = list(
.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)",
adj_mean_ci = "95% CI",
diff_mean_ci = "95% CI"
),
.formats = c(adj_mean_se = jjcsformat_xx("xx.x (xx.xx)")),
alternative = "greater",
ref_path = c("ARMCD", result$ref_level)
)
) |>
build_table(
df = broom::tidy(result),
alt_counts_df = dat_adsl
)