% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/blimp_obj_draws.R
\name{as_draws.blimp_obj}
\alias{as_draws.blimp_obj}
\alias{as_draws_array.blimp_obj}
\alias{as_draws_df.blimp_obj}
\title{Convert blimp_obj to a posterior draws object}
\usage{
\method{as_draws}{blimp_obj}(x, warmup = c("exclude", "include", "only"), ...)

\method{as_draws_array}{blimp_obj}(x, warmup = c("exclude", "include", "only"), ...)

\method{as_draws_df}{blimp_obj}(x, warmup = c("exclude", "include", "only"), ...)
}
\arguments{
\item{x}{A \code{blimp_obj} object.}

\item{warmup}{One of \code{"exclude"}, \code{"include"}, or \code{"only"}. Default
\code{"exclude"}.}

\item{...}{Additional arguments (unused).}
}
\value{
An object of class \link[posterior:draws_array]{posterior::draws_array} (for \code{as_draws} and
\code{as_draws_array}) or \link[posterior:draws_df]{posterior::draws_df} (for \code{as_draws_df}).
}
\description{
S3 methods for the \code{\link[posterior:draws]{posterior::as_draws()}} family of generics, allowing
\code{blimp_obj} to be used anywhere a \link[posterior:draws]{posterior::draws} object is expected.
This is the gateway to the \strong{posterior} and \strong{bayesplot} ecosystems:
once converted, the usual \code{summarise_draws()}, \code{mcmc_trace()},
\code{mcmc_areas()}, etc., all work.

The \strong{posterior} package must be installed to use these methods. It is
listed in \code{Suggests}, so install it explicitly with
\code{install.packages("posterior")} if needed.
}
\details{
All three methods accept a \code{warmup} argument with the same semantics as
\link{as.array,blimp_obj-method}. Because \code{draws_array} objects do not carry
a separate warmup/sampling distinction, the \code{"n_warmup"} attribute set by
\code{as.array(x, warmup = "include")} is dropped during conversion; users who
need the warmup marker should convert via \code{as.array()} and pass the
result to \code{bayesplot::mcmc_trace()} directly.
}
\examples{
\dontshow{if (has_blimp() && requireNamespace("posterior", quietly = TRUE)) withAutoprint(\{ # examplesIf}
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)

\dontrun{
if (requireNamespace("bayesplot", quietly = TRUE)) {
    bayesplot::mcmc_trace(draws)
    bayesplot::mcmc_areas(draws)
}
}
\dontshow{\}) # examplesIf}
}
