brm_data {brms.mmrm} | R Documentation |
Create a dataset to analyze with an MMRM.
brm_data(
data,
outcome = "CHG",
role = "change",
baseline = NULL,
group = "TRT01P",
subgroup = NULL,
time = "AVISIT",
patient = "USUBJID",
covariates = character(0L),
missing = NULL,
reference_group = "Placebo",
level_control = NULL,
reference_subgroup = NULL,
reference_time = NULL,
level_baseline = NULL
)
data |
Data frame or tibble with longitudinal data. |
outcome |
Character of length 1, name of the outcome variable. |
role |
Character of length 1. Either |
baseline |
Character of length 1,
name of the baseline response variable.
Only relevant if the response variable is change from baseline.
Supply |
group |
Character of length 1, name of the treatment group variable. Must point to a character vector in the data. Factors are converted to characters. |
subgroup |
Character of length 1, optional name of the a
discrete subgroup variable. Set to |
time |
Character of length 1, name of the discrete time variable. Must point to a character vector in the data. Factors are converted to characters. |
patient |
Character of length 1, name of the patient ID variable. |
covariates |
Character vector of names of other covariates. |
missing |
Character of length 1, name of an optional variable
in a simulated dataset to indicate which outcome values should be missing.
Set to |
reference_group |
Character of length 1, Level of the |
level_control |
Deprecated on 2024-01-11 (version 0.2.0.9002).
Use |
reference_subgroup |
Character of length 1,
level of the |
reference_time |
Character of length 1 or Note: |
level_baseline |
Deprecated on 2024-01-11 (version 0.2.0.9002).
Use |
A classed tibble with attributes which denote features of the data such as the treatment group and discrete time variables.
The preprocessing steps in brm_data()
are as follows:
Perform basic assertions to make sure the data and other arguments are properly formatted.
Convert the group and time columns to character vectors.
Sanitize the levels of the group and time columns using
make.names(unique = FALSE, allow_ = TRUE)
to ensure agreement
between the data and the output of brms
.
For each implicitly missing outcome observation, add explicit row
with the outcome variable equal to NA_real_
.
Arrange the rows of the data by group, then patient, then discrete time.
Select only the columns of the data relevant to an MMRM analysis.
Post-processing in brm_marginal_draws()
names each of the
group-by-time marginal means with the delimiting character string
from Sys.getenv("BRM_SEP", unset = "|")
. Neither the column names
nor element names of the group and time variables can contain
this string. To set a custom string yourself, use
Sys.setenv(BRM_SEP = "YOUR_CUSTOM_STRING")
.
Other data:
brm_data_change()
set.seed(0)
data <- brm_simulate_simple()$data
colnames(data) <- paste0("col_", colnames(data))
data
brm_data(
data = data,
outcome = "col_response",
role = "response",
group = "col_group",
time = "col_time",
patient = "col_patient",
reference_group = "group_1",
reference_time = "time_1"
)