Learn R Programming

rstanarm (version 2.26.1)

stanreg-draws-formats: Create a draws object from a stanreg object

Description

Convert a stanreg object to a format supported by the posterior package.

Usage

# S3 method for stanreg
as_draws(x, ...)

# S3 method for stanreg as_draws_matrix(x, ...)

# S3 method for stanreg as_draws_array(x, ...)

# S3 method for stanreg as_draws_df(x, ...)

# S3 method for stanreg as_draws_list(x, ...)

# S3 method for stanreg as_draws_rvars(x, ...)

Value

A draws object from the

posterior package. See the

posterior package documentation and vignettes for details on working with these objects.

Arguments

x

A stanreg object returned by one of the rstanarm modeling functions.

...

Arguments (e.g., pars, regex_pars) passed internally to as.matrix.stanreg or as.array.stanreg.

Details

To subset iterations, chains, or draws, use subset_draws after making the draws object. To subset variables use ... to pass the pars and/or regex_pars arguments to as.matrix.stanreg or as.array.stanreg (these are called internally by as_draws.stanreg), or use subset_draws after making the draws object.

Examples

Run this code
fit <- stan_glm(mpg ~ wt + as.factor(cyl), data = mtcars)
as_draws_matrix(fit) # matrix format combines all chains 
as_draws_df(fit, regex_pars = "cyl")
posterior::summarize_draws(as_draws_array(fit))

Run the code above in your browser using DataLab