gEconpy.plotting.plot_acf#

gEconpy.plotting.plot_acf(acorr, vars_to_plot=None, sample_dims=('chain', 'draw'), ci_probs=(0.5, 0.94), reference=None, dodge=0.2, figsize=(14, 4), dpi=100, n_cols=4, mean_kwargs=None, inner_hdi_kwargs=None, outer_hdi_kwargs=None, stem_kwargs=None, reference_kwargs=None)#

Plot the autocorrelation function for a set of variables.

acorr is an autocorrelation tensor with a lag dimension and two square variable dimensions (the cross-correlation axes, e.g. variable/variable_aux or state/state_aux); only the diagonal — each variable’s own autocorrelation — is drawn. If the tensor also carries posterior sample dimensions (chain, draw), the result is an uncertainty-aware forest: a point at the posterior mean with two nested credible-interval sticks at each lag. Otherwise it is a single-estimate stem plot.

Pass a mapping of {label: tensor} to overlay several models on the same axes; their forests are dodged along the lag axis, coloured per model, and a legend of the labels is added.

Parameters:
acorrDataArray or mapping of str to DataArray

The autocorrelation tensor(s). A single tensor is plotted directly; a mapping overlays one dodged, coloured forest per entry. Each tensor must have a lag dimension and exactly two non-lag, non-sample variable dimensions, and may additionally carry the sample_dims.

vars_to_plotlist of str, optional

Variables to plot. Plot every variable in acorr (the first entry, if a mapping) when not provided.

sample_dimstuple of str, optional

Dimensions treated as posterior samples; their presence switches stems to forest intervals. Default ("chain", "draw").

ci_probstuple of float, optional

The two credible-interval probabilities drawn at each lag as (inner, outer); the inner interval gets the thicker line. Ignored for tensors with no sample dimensions. Default (0.5, 0.94).

referenceDataArray, optional

A second autocorrelation to overlay as hollow markers — typically the empirical ACF of the observed data, for a model-vs-data check. Indexed by lag and a single variable dimension; only variables that also appear in acorr are overlaid. Default None.

dodgefloat, optional

Horizontal offset between successive models’ forests when acorr is a mapping. Default 0.2.

figsizetuple, optional

Figure size in inches. Default (14, 4).

dpiint, optional

Figure resolution in dots per inch. Default 100.

n_colsint, optional

Number of columns in the subplot grid. Default 4.

mean_kwargsdict, optional

Keyword arguments forwarded to Axes.scatter for the posterior-mean point of each forest, merged over the defaults {"s": 38, "zorder": 3} (per-model color is set automatically). Default None.

inner_hdi_kwargsdict, optional

Keyword arguments forwarded to Axes.vlines for the inner (thicker) HDI stick, merged over the default {"lw": 3.0}. Default None.

outer_hdi_kwargsdict, optional

Keyword arguments forwarded to Axes.vlines for the outer (thinner) HDI stick, merged over the default {"lw": 1.0}. Default None.

stem_kwargsdict, optional

Keyword arguments forwarded to Axes.scatter for the stem marker drawn when a tensor has no sample dimensions. Default None.

reference_kwargsdict, optional

Keyword arguments forwarded to Axes.scatter for the hollow reference markers, merged over the defaults {"facecolors": "none", "edgecolors": "k", "s": 60, "linewidths": 1.6, "zorder": 4}. The legend proxy for the reference series is kept in sync with these settings. Default None.

Returns:
matplotlib.figure.Figure

Figure object containing the plots.