extract_mmrm_subgroups {tern.mmrm} | R Documentation |
Extraction of MMRM Subgroup Results based on Population Model Definition
Description
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.
Usage
extract_mmrm_subgroups(
fit,
visit,
subgroups = NULL,
groups_lists = list(),
treatment_arm = fit$treatment_levels[1L],
label_all = "All Patients"
)
Arguments
fit |
( |
visit |
( |
subgroups |
( |
groups_lists |
(named |
treatment_arm |
( |
label_all |
( |
Details
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.
Value
A list with two elements:
-
estimates
:data.frame
with columnsarm
,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 columnsn_tot
,diff
,lcl
,ucl
,pval
,subgroup
,var
,var_label
,row_type
. Note that this has half the number of rows asestimates
.
Note
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.
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")
)
)
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")
)
)
)