statsmodels.graphics.tsaplots.plot_accf_grid

statsmodels.graphics.tsaplots.plot_accf_grid(x, *, varnames=None, fig=None, lags=None, negative_lags=True, alpha=0.05, use_vlines=True, adjusted=False, fft=False, missing='none', zero=True, auto_ylims=False, bartlett_confint=False, vlines_kwargs=None, **kwargs)[source]

Plot auto/cross-correlation grid

Plots lags on the horizontal axis and the correlations on the vertical axis of each graph.

Parameters:
xarray_like

2D array of time-series values: rows are observations, columns are variables.

varnames: sequence of str, optional

Variable names to use in plot titles. If x is a pandas dataframe and varnames is provided, it overrides the column names of the dataframe. If varnames is not provided and x is not a dataframe, variable names x[0], x[1], etc. are generated.

figMatplotlib figure instance, optional

If given, this figure is used to plot in, otherwise a new figure is created.

lags{int, array_like}, optional

An int or array of lag values, used on horizontal axes. Uses np.arange(lags) when lags is an int. If not provided, lags=np.arange(len(corr)) is used.

negative_lags: bool, optional

If True, negative lags are shown on the horizontal axes of plots below the main diagonal.

alphascalar, optional

If a number is given, the confidence intervals for the given level are plotted, e.g. if alpha=.05, 95 % confidence intervals are shown. If None, confidence intervals are not shown on the plot.

use_vlinesbool, optional

If True, shows vertical lines and markers for the correlation values. If False, only shows markers. The default marker is ‘o’; it can be overridden with a marker kwarg.

adjustedbool

If True, then denominators for correlations are n-k, otherwise n.

fftbool, optional

If True, computes the ACF via FFT.

missingstr, optional

A string in [‘none’, ‘raise’, ‘conservative’, ‘drop’] specifying how NaNs are to be treated.

zerobool, optional

Flag indicating whether to include the 0-lag autocorrelations (which are always equal to 1). Default is True.

auto_ylimsbool, optional

If True, adjusts automatically the vertical axis limits to correlation values.

bartlett_confintbool, default False

If True, use Bartlett’s formula to calculate confidence intervals in auto-correlation plots. See the description of plot_acf for details. This argument does not affect cross-correlation plots.

vlines_kwargsdict, optional

Optional dictionary of keyword arguments that are passed to vlines.

**kwargskwargs, optional

Optional keyword arguments that are directly passed on to the Matplotlib plot and axhline functions.

Returns:
Figure

If fig is None, the created figure. Otherwise, fig is returned. Plots on the grid show the cross-correlation of the row variable with the lags of the column variable.

See also

statsmodels.graphics.tsaplots

Examples

>>> import pandas as pd
>>> import matplotlib.pyplot as plt
>>> import statsmodels.api as sm
>>> dta = sm.datasets.macrodata.load_pandas().data
>>> diffed = dta.diff().dropna()
>>> sm.graphics.tsa.plot_accf_grid(diffed[["unemp", "infl"]])
>>> plt.show()

Last update: Oct 03, 2024