brm_marginal_draws {brms.mmrm} | R Documentation |
Get marginal posterior draws from a fitted MMRM.
brm_marginal_draws(
data,
formula,
model,
transform = brms.mmrm::brm_transform_marginal(data, formula),
effect_size = TRUE,
use_subgroup = NULL,
control = NULL,
baseline = NULL
)
data |
A classed data frame from |
formula |
An object of class |
model |
A fitted model object from |
transform |
Matrix with one row per marginal mean and one column
per model parameter. |
effect_size |
Logical, |
use_subgroup |
Deprecated. No longer used. |
control |
Deprecated. Set the control group level in |
baseline |
Deprecated. Set the control group level in |
A named list of tibbles of MCMC draws of the marginal posterior
distribution of each treatment group and time point. These marginals
are also subgroup-specific if brm_formula()
included fixed effects
that use the subgroup
variable originally declared in brm_data()
.
In each tibble, there is 1 row per posterior sample and one column for
each type of marginal distribution (i.e. each combination of treatment
group and discrete time point. The specific tibble
s in the returned
list are described below:
response
: on the scale of the response variable.
difference_time
: change from baseline: the
response
at a particular time minus the response
at baseline
(reference_time
).
Only returned if the role
argument of brm_data()
was
"response"
. (If role
is "change"
, then response
already
represents change from baseline.)
difference_group
: treatment effect: the
the difference_time
at each active group minus the difference_time
at the control group (reference_group
).
If role
is "change"
, then treatment group
is instead the difference between response
at each active group minus
the response
at the control group.
difference_subgroup
: subgroup differences: the difference_group
at each subgroup level minus the difference_group
at the subgroup
reference level (reference_subgroup
).
effect
: effect size, defined as the treatment difference
divided by the residual standard deviation. Omitted if
the effect_size
argument is FALSE
or if the
brm_formula_sigma()
includes baseline or covariates.
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 marginals:
brm_marginal_data()
,
brm_marginal_draws_average()
,
brm_marginal_probabilities()
,
brm_marginal_summaries()
if (identical(Sys.getenv("BRM_EXAMPLES", unset = ""), "true")) {
set.seed(0L)
data <- brm_data(
data = brm_simulate_simple()$data,
outcome = "response",
role = "response",
group = "group",
time = "time",
patient = "patient",
reference_group = "group_1",
reference_time = "time_1"
)
formula <- brm_formula(
data = data,
baseline = FALSE,
baseline_time = FALSE
)
tmp <- utils::capture.output(
suppressMessages(
suppressWarnings(
model <- brm_model(
data = data,
formula = formula,
chains = 1,
iter = 100,
refresh = 0
)
)
)
)
brm_marginal_draws(data = data, formula = formula, model = model)
}