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

stanreg-draws-formatsR Documentation

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 class 'stanreg'
as_draws(x, ...)

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

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

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

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

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

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.

Value

A draws object from the posterior package. See the posterior package documentation and vignettes for details on working with these objects.

Examples

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))


rstanarm documentation built on May 29, 2024, 5:51 a.m.