arviz.plot_autocorr

arviz.plot_autocorr(data, var_names=None, max_lag=None, combined=False, figsize=None, textsize=None, ax=None)[source]

Bar plot of the autocorrelation function for a sequence of data.

Useful in particular for posteriors from MCMC samples which may display correlation.

Parameters
dataobj

Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details

var_nameslist of variable names, optional

Variables to be plotted, if None all variable are plotted. Vector-value stochastics are handled automatically.

max_lagint, optional

Maximum lag to calculate autocorrelation. Defaults to 100 or num draws, whichever is smaller

combinedbool

Flag for combining multiple chains into a single chain. If False (default), chains will be plotted separately.

figsizetuple

Figure size. If None it will be defined automatically. Note this is not used if ax is supplied.

textsize: float

Text size scaling factor for labels, titles and lines. If None it will be autoscaled based on figsize.

ax: axes

Matplotlib axes

Returns
axesmatplotlib axes

Examples

Plot default autocorrelation

>>> import arviz as az
>>> data = az.load_arviz_data('centered_eight')
>>> az.plot_autocorr(data)
../_images/arviz-plot_autocorr-1.png

Plot subset variables by specifying variable name exactly

>>> az.plot_autocorr(data, var_names=['mu', 'tau'] )
../_images/arviz-plot_autocorr-2.png

Combine chains collapsing by variable

>>> az.plot_autocorr(data, var_names=['mu', 'tau'], combined=True)
../_images/arviz-plot_autocorr-3.png

Specify maximum lag (x axis bound)

>>> az.plot_autocorr(data, var_names=['mu', 'tau'], max_lag=200, combined=True)
../_images/arviz-plot_autocorr-4.png