Learn R Programming

bayesSSM (version 0.7.1)

ess: Estimate effective sample size (ESS) of MCMC chains.

Description

Estimate effective sample size (ESS) of MCMC chains.

Usage

ess(chains)

Value

The estimated effective sample size (ESS) if given a matrix, or a named vector of ESS values if given a data frame.

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

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

Run this code
# 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)

Run the code above in your browser using DataLab