brm_data | R Documentation |
Create a dataset to analyze with an MMRM.
brm_data(
data,
outcome,
baseline = NULL,
group,
subgroup = NULL,
time,
patient,
covariates = character(0L),
missing = NULL,
reference_group,
reference_subgroup = NULL,
reference_time = NULL,
role = NULL,
level_baseline = NULL,
level_control = NULL
)
data |
Data frame or tibble with longitudinal data. |
outcome |
Character of length 1, name of the continuous
outcome variable.
Example possibilities from clinical trial datasets include
|
baseline |
Character of length 1,
name of the baseline response variable (for example, |
group |
Character of length 1, name of the treatment group variable.
Example possibilities from clinical trial datasets include
|
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.
Example possibilities from clinical trial datasets include
Ordinarily, ordered factors automatically use polynomial contrasts from
|
patient |
Character of length 1, name of the patient ID variable.
Example possibilities from clinical trial datasets include
|
covariates |
Character vector of names of other covariates.
All these covariates are assumed to be non-time-varying. For time-varying
covariates, please manually expand the data to the full grid of patients
and time points before you call |
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 |
Atomic value of length 1, Level of the |
reference_subgroup |
Atomic value of length 1,
level of the |
reference_time |
Atomic value of length 1 or If Note: |
role |
Deprecated as unnecessary on 2024-07-11 (version 1.0.1.9007).
Use |
level_baseline |
Deprecated on 2024-01-11 (version 0.2.0.9002).
Use |
level_control |
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_
. Missing values
in the predictors are implicitly filled using zoo::na.locf()
on within each patient, which is not valid for time-varying
covariates. If any covariates are time-varying, please
manually perform this step before calling brm_data()
.
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()
,
brm_data_chronologize()
set.seed(0)
data <- brm_simulate_simple()$data
colnames(data) <- paste0("col_", colnames(data))
data
brm_data(
data = data,
outcome = "col_response",
group = "col_group",
time = "col_time",
patient = "col_patient",
reference_group = "group_1",
reference_time = "time_1"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.