View source: R/blimp_obj_draws.R
| as_draws.blimp_obj | R Documentation |
S3 methods for the posterior::as_draws() family of generics, allowing
blimp_obj to be used anywhere a posterior::draws object is expected.
This is the gateway to the posterior and bayesplot ecosystems:
once converted, the usual summarise_draws(), mcmc_trace(),
mcmc_areas(), etc., all work.
The posterior package must be installed to use these methods. It is
listed in Suggests, so install it explicitly with
install.packages("posterior") if needed.
## S3 method for class 'blimp_obj'
as_draws(x, warmup = c("exclude", "include", "only"), ...)
## S3 method for class 'blimp_obj'
as_draws_array(x, warmup = c("exclude", "include", "only"), ...)
## S3 method for class 'blimp_obj'
as_draws_df(x, warmup = c("exclude", "include", "only"), ...)
x |
A |
warmup |
One of |
... |
Additional arguments (unused). |
All three methods accept a warmup argument with the same semantics as
as.array,blimp_obj-method. Because draws_array objects do not carry
a separate warmup/sampling distinction, the "n_warmup" attribute set by
as.array(x, warmup = "include") is dropped during conversion; users who
need the warmup marker should convert via as.array() and pass the
result to bayesplot::mcmc_trace() directly.
An object of class posterior::draws_array (for as_draws and
as_draws_array) or posterior::draws_df (for as_draws_df).
mydata <- rblimp_sim(
c(
'f ~ normal(0, 1)',
'x1:x5 ~ normal(f, 1)',
'y ~ normal(10 + 0.3*f, 1 - .3^2)'
),
n = 500,
seed = 19723,
variables = c('y', 'x1:x5')
)
model <- rblimp(
list(structure = 'y ~ f', measurement = 'f -> x1:x5'),
mydata,
chains = 4,
seed = 3927,
latent = ~ f
)
draws <- posterior::as_draws_array(model)
posterior::summarise_draws(draws)
## Not run:
if (requireNamespace("bayesplot", quietly = TRUE)) {
bayesplot::mcmc_trace(draws)
bayesplot::mcmc_areas(draws)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.