arviz_plots.plot_autocorr#
- arviz_plots.plot_autocorr(dt, var_names=None, filter_vars=None, group='posterior', coords=None, sample_dims=None, max_lag=None, plot_collection=None, backend=None, labeller=None, aes_by_visuals=None, visuals=None, **pc_kwargs)[source]#
Autocorrelation plots for the given dataset.
Line plot of the autocorrelation function (ACF)
The ACF plots can be used as a convergence diagnostic for posteriors from MCMC samples.
- Parameters:
- dt
xarray.DataTree
Input data
- var_names
str
orlist
ofstr
, optional One or more variables to be plotted. Currently only one variable is supported. Prefix the variables by ~ when you want to exclude them from the plot.
- filter_vars{
None
, “like”, “regex”}, optional, default=None If None (default), interpret var_names as the real variables names. If “like”, interpret var_names as substrings of the real variables names. If “regex”, interpret var_names as regular expressions on the real variables names.
- group
str
, optional Which group to use. Defaults to “posterior”.
- coords
dict
, optional Coordinates to plot.
- sample_dims
str
or sequence of hashable, optional Dimensions to reduce unless mapped to an aesthetic. Defaults to
rcParams["data.sample_dims"]
- max_lag
int
, optional Maximum lag to compute the ACF. Defaults to 100.
- plot_collection
PlotCollection
, optional - backend{“matplotlib”, “bokeh”, “plotly”}, optional
- labeller
labeller
, optional - aes_by_visualsmapping of {
str
sequence ofstr
}, optional Mapping of visuals to aesthetics that should use their mapping in
plot_collection
when plotted. Valid keys are the same as forvisuals
.- visualsmapping of {
str
mapping orFalse
}, optional Valid keys are:
lines -> passed to
ecdf_line
ref_line -> passed to
line_xy
credible_interval -> passed to
fill_between_y
xlabel -> passed to
labelled_x
title -> passed to
labelled_title
- **pc_kwargs
Passed to
arviz_plots.PlotCollection.grid
- dt
- Returns:
Examples
Autocorrelation plot for mu variable in the centered eight dataset.
>>> from arviz_plots import plot_autocorr, style >>> style.use("arviz-variat") >>> from arviz_base import load_arviz_data >>> dt = load_arviz_data('centered_eight') >>> plot_autocorr(dt, var_names=["mu"])