Returns a tidy summary output for stan models.
tidy_stan(x, probs = 0.89, typical = "median", trans = NULL,
type = c("fixed", "random", "all"), digits = 3)
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 probs
has more than one element.
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 typical
), the
standard error (which are actually median absolute deviations),
the HDI, the ratio of effective numbers of samples, n_eff,
(i.e. effective number of samples divided by total number of samples)
and Rhat statistics.
The ratio of effective number of samples 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.
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.
Computation for HDI is based on the code from Kruschke 2015, pp. 727f.
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<U+2013>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, probs = c(.89, .5))
}
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab