tidy_stan {sjstats}R Documentation

Tidy summary output for stan models

Description

Returns a tidy summary output for stan models.

Usage

tidy_stan(x, prob = 0.89, typical = "median", trans = NULL,
  type = c("fixed", "random", "all"), digits = 2)

Arguments

x

A stanreg, stanfit or brmsfit object.

prob

Vector of scalars between 0 and 1, indicating the mass within the credible interval that is to be estimated. See hdi.

typical

The typical value that will represent the Bayesian point estimate. By default, the posterior median is returned. See typical_value for possible values for this argument.

trans

Name of a function or character vector naming a function, used to apply transformations on the estimate and HDI-values. The values for standard errors are not transformed!

type

For mixed effects models, specify the type of effects that should be returned. type = "fixed" returns fixed effects only, type = "random" the random effects and type = "all" returns both fixed and random effects.

digits

Amount of digits to round numerical values in the output.

Details

The returned data frame has an additonal class-attribute, tidy_stan, to pass the result to its own print()-method. The print()-method create a cleaner output, especially for multilevel, zero-inflated or multivariate response models, where - for instance - the conditional part of a model is printed separately from the zero-inflated part, or random and fixed effects are printed separately.

The returned data frame gives information on:

Value

A tidy data frame, summarizing x, with consistent column names. To distinguish multiple HDI values, column names for the HDI get a suffix when prob has more than one element.

References

Kruschke JK. Doing Bayesian Data Analysis: A Tutorial with R, JAGS, and Stan. 2nd edition. Academic Press, 2015

Gelman A, Carlin JB, Stern HS, Dunson DB, Vehtari A, Rubin DB. Bayesian data analysis. 3rd ed. Boca Raton: Chapman & Hall/CRC, 2013

Gelman A, Rubin DB. Inference from iterative simulation using multiple sequences. Statistical Science 1992;7: 457–511

McElreath R. Statistical Rethinking. A Bayesian Course with Examples in R and Stan. Chapman and Hall, 2015

See Also

hdi

Examples

## Not run: 
if (require("rstanarm")) {
  fit <- stan_glm(mpg ~ wt + am, data = mtcars, chains = 1)
  tidy_stan(fit)
  tidy_stan(fit, prob = c(.89, .5))
}
## End(Not run)


[Package sjstats version 0.15.0 Index]