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.
acorris an autocorrelation tensor with alagdimension and two square variable dimensions (the cross-correlation axes, e.g.variable/variable_auxorstate/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:
- acorr
DataArrayormappingofstrtoDataArray The autocorrelation tensor(s). A single tensor is plotted directly; a mapping overlays one dodged, coloured forest per entry. Each tensor must have a
lagdimension and exactly two non-lag, non-sample variable dimensions, and may additionally carry thesample_dims.- vars_to_plot
listofstr, optional Variables to plot. Plot every variable in
acorr(the first entry, if a mapping) when not provided.- sample_dims
tupleofstr, optional Dimensions treated as posterior samples; their presence switches stems to forest intervals. Default
("chain", "draw").- ci_probs
tupleoffloat, 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).- reference
DataArray, 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
lagand a single variable dimension; only variables that also appear inacorrare overlaid. Default None.- dodge
float, optional Horizontal offset between successive models’ forests when
acorris a mapping. Default 0.2.- figsize
tuple, optional Figure size in inches. Default
(14, 4).- dpi
int, optional Figure resolution in dots per inch. Default 100.
- n_cols
int, optional Number of columns in the subplot grid. Default 4.
- mean_kwargs
dict, optional Keyword arguments forwarded to
Axes.scatterfor the posterior-mean point of each forest, merged over the defaults{"s": 38, "zorder": 3}(per-modelcoloris set automatically). Default None.- inner_hdi_kwargs
dict, optional Keyword arguments forwarded to
Axes.vlinesfor the inner (thicker) HDI stick, merged over the default{"lw": 3.0}. Default None.- outer_hdi_kwargs
dict, optional Keyword arguments forwarded to
Axes.vlinesfor the outer (thinner) HDI stick, merged over the default{"lw": 1.0}. Default None.- stem_kwargs
dict, optional Keyword arguments forwarded to
Axes.scatterfor the stem marker drawn when a tensor has no sample dimensions. Default None.- reference_kwargs
dict, optional Keyword arguments forwarded to
Axes.scatterfor 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.
- acorr
- Returns:
matplotlib.figure.FigureFigure object containing the plots.