Returns a tidy summary output for stan models.
tidy_stan(x, prob = 0.89, typical = "median", trans = NULL,
type = c("fixed", "random", "all"), digits = 2)
A stanreg
, stanfit
or brmsfit
object.
Vector of scalars between 0 and 1, indicating the mass within
the credible interval that is to be estimated. See hdi
.
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.
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!
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.
Amount of digits to round numerical values in the output.
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.
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:
The Bayesian point estimate (column estimate, which is by
default the posterior median; other statistics are also possible,
see argument typical
).
The standard error (which is actually the median absolute deviation).
The HDI (see hdi
). Computation for HDI is based on the
code from Kruschke 2015, pp. 727f.
The ratio of effective numbers of samples, neff_ratio, (i.e. effective number of samples divided by total number of samples). This ratio ranges from 0 to 1, and should be close to 1. The closer this ratio comes to zero means that the chains may be inefficient, but possibly still okay.
The Rhat statistics. When Rhat is above 1, it usually indicates that the chain has not yet converged, indicating that the drawn samples might not be trustworthy. Drawing more iteration may solve this issue.
The Monte Carlo standard error (see mcse
). It is defined
as standard deviation of the chains divided by their effective sample
size and “provides a quantitative suggestion of how big the
estimation noise is” (Kruschke 2015, p.187).
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 and 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
# 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))
}
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab