ACF: ACF Plot for Markov chain Monte Carlo

View source: R/export.R

ACFR Documentation

ACF Plot for Markov chain Monte Carlo

Description

Autocorrelation function plots for MCMC data (including multiple chains)

Usage

ACF(x,component = NULL, type = c("correlation", "covariance"),
             plot= TRUE, lag.max = NULL, avg.col = "blue", chain.col   = "red",
             na.action   = na.fail, auto.layout = TRUE, ask = dev.interactive())

Arguments

x

: an ‘Smcmc’ class object or a list of Markov chains or a Markov chain matrix

component

: a vector of integers indicating which components' ACF plots are needed. By default all components are drawn.

type

: the kind of ACF plot: "correlation" or "covariance"

plot

: TRUE if plots are required. If FALSE, raw values are returned

lag.max

: Maximum lag for the ACF plot

chain.col

: color for the ACF of the individual chains.

na.action

: function to be called to handle missing values. ‘na.pass’ can be used.

auto.layout

: logical argument for an automatic layout of plots

ask

: activating interactive plots

avg.col

: color for the overall ACF of each component

Value

returns the autocorrelation function plots of the Markov chains. Uses the more accurate globally-centered ACFs.

References

Agarwal, M., and Vats, D., “Globally-centered autocovariances in MCMC”, arxiv - 2009.01799, 2020.

Examples

# Producing Markov chain
chain <- matrix(0, ncol = 1, nrow = 1e3)
chain[1,] <- 0
err <- rnorm(1e3)
for(i in 2:1e3)
{
  chain[i,] <- .3*chain[i-1,] + err[i]
}
chain <- Smcmc(list(chain))
ACF(chain)


dvats/SimTools documentation built on May 14, 2023, 1:28 p.m.