arviz.plot_autocorr

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.

Parameters:
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.

Returns:
axes : matplotlib 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