ACF | R Documentation |
Autocorrelation function plots for MCMC data (including multiple chains)
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())
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 |
returns the autocorrelation function plots of the Markov chains. Uses the more accurate globally-centered ACFs.
Agarwal, M., and Vats, D., “Globally-centered autocovariances in MCMC”, arxiv - 2009.01799, 2020.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.