brm_plot_compare {brms.mmrm} | R Documentation |
Visually compare the marginals of multiple models and/or datasets.
Description
Visually compare the marginals of multiple models and/or datasets.
Usage
brm_plot_compare(
...,
marginal = "response",
compare = "source",
axis = "time",
facet = c("group", "subgroup")
)
Arguments
... |
Named |
marginal |
Character of length 1, which kind of marginal
to visualize. Must be a value in the |
compare |
Character of length 1 identifying the variable to display
using back-to-back interval plots of different colors. This is
the primary comparison of interest. Must be one of
|
axis |
Character of length 1 identifying the quantity to put
on the horizontal axis. Must be be one of |
facet |
Character vector of length 1 or 2 with quantities to
generate facets. Each element must be |
Details
By default, brm_plot_compare()
compares multiple models
and/or datasets side-by-side. The compare
argument selects the primary
comparison of interest, and arguments axis
and facet
control
the arrangement of various other components of the plot.
Value
A ggplot
object.
See Also
Other visualization:
brm_plot_draws()
Examples
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
)
)
)
)
draws <- brm_marginal_draws(model = model, data = data)
suppressWarnings(summaries_draws <- brm_marginal_summaries(draws))
summaries_data <- brm_marginal_data(data)
brm_plot_compare(
model1 = summaries_draws,
model2 = summaries_draws,
data = summaries_data
)
brm_plot_compare(
model1 = summaries_draws,
model2 = summaries_draws,
marginal = "difference"
)
}