arviz.plot_autocorr(data, var_names=None, max_lag=100, combined=False, figsize=None, textsize=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.

data : obj

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

var_names : list of variable names, optional

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

max_lag : int, optional

Maximum lag to calculate autocorrelation. Defaults to 100.

combined : bool

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

figsize : tuple

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.

axes : matplotlib axes


Plot default autocorrelation

>>> import arviz as az
>>> data = az.load_arviz_data('centered_eight')
>>> az.plot_autocorr(data)

Plot subset variables by specifying variable name exactly

>>> az.plot_autocorr(data, var_names=['mu', 'tau'] )

Combine chains collapsing by variable

>>> az.plot_autocorr(data, var_names=['mu', 'tau'], combined=True)

Specify maximum lag (x axis bound)

>>> az.plot_autocorr(data, var_names=['mu', 'tau'], max_lag=200, combined=True)