brm_simulate_prior {brms.mmrm} | R Documentation |
Prior predictive draws.
Description
Simulate the outcome variable from the prior
predictive distribution of an MMRM using brms
.
Usage
brm_simulate_prior(
data,
formula,
prior = brms.mmrm::brm_prior_simple(data = data, formula = formula),
...
)
Arguments
data |
A classed data frame from |
formula |
An object of class |
prior |
A valid |
... |
Named arguments to specific |
Details
brm_simulate_prior()
calls brms::brm()
with
sample_prior = "only"
, which sets the default intercept prior
using the outcome variable and requires at least some elements of the
outcome variable to be non-missing in advance. So to provide feasible and
consistent output, brm_simulate_prior()
temporarily sets the
outcome variable to all zeros before invoking brms::brm()
.
Value
A list with the following elements:
-
data
: a classedtibble
with the outcome variable simulated as a draw from the prior predictive distribution (the final row ofoutcome
in the output). If you simulated a missingness pattern withbrm_simulate_outline()
, then that missingness pattern is applied so that the appropriate values of the outcome variable are set toNA
. -
model
: thebrms
model fit object. -
model_matrix
: the model matrix of the fixed effects, obtained frombrms::make_standata()
. -
outcome
: a numeric matrix with one column per row ofdata
and one row per saved prior predictive draw. -
parameters
: atibble
of saved parameter draws from the prior predictive distribution.
See Also
Other simulation:
brm_simulate_categorical()
,
brm_simulate_continuous()
,
brm_simulate_outline()
,
brm_simulate_simple()
Examples
if (identical(Sys.getenv("BRM_EXAMPLES", unset = ""), "true")) {
set.seed(0L)
data <- brm_simulate_outline()
data <- brm_simulate_continuous(data, names = c("age", "biomarker"))
data$response <- rnorm(nrow(data))
formula <- brm_formula(
data = data,
baseline = FALSE,
baseline_time = FALSE
)
tmp <- utils::capture.output(
suppressMessages(
suppressWarnings(
out <- brm_simulate_prior(
data = data,
formula = formula
)
)
)
)
out$data
}