Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

autocorr

Autocorrelation function for Markov chains


Description

autocorr calculates the autocorrelation function for the Markov chain mcmc.obj at the lags given by lags. The lag values are taken to be relative to the thinning interval if relative=TRUE.

High autocorrelations within chains indicate slow mixing and, usually, slow convergence. It may be useful to thin out a chain with high autocorrelations before calculating summary statistics: a thinned chain may contain most of the information, but take up less space in memory. Re-running the MCMC sampler with a different parameterization may help to reduce autocorrelation.

Usage

autocorr(x, lags = c(0, 1, 5, 10, 50), relative=TRUE)

Arguments

x

an mcmc object

lags

a vector of lags at which to calculate the autocorrelation

relative

a logical flag. TRUE if lags are relative to the thinning interval of the chain, or FALSE if they are absolute difference in iteration numbers

Value

A vector or array containing the autocorrelations.

Author(s)

Martyn Plummer

See Also


coda

Output Analysis and Diagnostics for MCMC

v0.19-4
GPL (>= 2)
Authors
Martyn Plummer [aut, cre, trl], Nicky Best [aut], Kate Cowles [aut], Karen Vines [aut], Deepayan Sarkar [aut], Douglas Bates [aut], Russell Almond [aut], Arni Magnusson [aut]
Initial release
2020-09-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.