ess {bayesSSM} | R Documentation |
Estimate effective sample size (ESS) of MCMC chains.
Description
Estimate effective sample size (ESS) of MCMC chains.
Usage
ess(chains)
Arguments
chains |
A matrix (iterations x chains) or a data.frame with a 'chain' column and parameter columns. |
Details
Uses the formula for ESS proposed by Vehtari et al. (2021).
Value
The estimated effective sample size (ess) if given a matrix, or a named vector of ESS values if given a data frame.
References
Vehtari et al. (2021). Rank-normalization, folding, and localization: An improved R-hat for assessing convergence of MCMC. Available at: https://doi.org/10.1214/20-BA1221
Examples
# With a matrix:
chains <- matrix(rnorm(3000), nrow = 1000, ncol = 3)
ess(chains)
# With a data frame:
chains_df <- data.frame(
chain = rep(1:3, each = 1000),
param1 = rnorm(3000),
param2 = rnorm(3000)
)
ess(chains_df)
[Package bayesSSM version 0.5.0 Index]