View source: R/brm_plot_compare.R
brm_plot_compare | R Documentation |
Visually compare the marginals of multiple models and/or datasets.
brm_plot_compare(
...,
marginal = "response",
compare = "source",
axis = "time",
facet = c("group", "subgroup")
)
... |
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 |
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.
The subgroup variable is automatically included if and only if
all the supplied marginal summaries have a subgroup column.
A ggplot
object.
Other visualization:
brm_plot_draws()
if (identical(Sys.getenv("BRM_EXAMPLES", unset = ""), "true")) {
set.seed(0L)
data <- brm_data(
data = brm_simulate_simple()$data,
outcome = "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(data = data, formula = formula, model = model)
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"
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.