extract_mmrm_subgroups | R Documentation |
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.
extract_mmrm_subgroups(
fit,
visit,
subgroups = NULL,
groups_lists = list(),
treatment_arm = fit$treatment_levels[1L],
label_all = "All Patients"
)
fit |
( |
visit |
( |
subgroups |
( |
groups_lists |
(named |
treatment_arm |
( |
label_all |
( |
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.
A list with two elements:
estimates
: data.frame
with columns arm
, n
, lsmean
, subgroup
,
var
, var_label
, row_type
, containing the LS means results for
the overall population and the specified subgroups.
contrasts
: data.frame
with columns n_tot
, diff
, lcl
, ucl
,
pval
, subgroup
, var
, var_label
, row_type
. Note
that this has half the number of rows as estimates
.
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.
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")
)
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.