statsmodels.graphics.tsaplots.plot_pccf#
- statsmodels.graphics.tsaplots.plot_pccf(x, y, *, ax=None, lags=None, method='ywm', alpha=0.05, use_vlines=True, title='Partial Cross-correlation', auto_ylims=False, vlines_kwargs=None, **kwargs)[source]#
Plot the partial cross-correlation function
Partial cross-correlations between
xand the lags ofyare calculated.The lags are shown on the horizontal axis and the partial cross-correlations on the vertical axis.
- Parameters:
- x, yarray_like
Arrays of time-series values.
- ax
AxesSubplot,optional If given, this subplot is used to plot in, otherwise a new figure with one subplot is created.
- lags{
int, array_like},optional An int or array of lag values, used on the horizontal axis. Uses
np.arange(lags)when lags is an int. If not provided,lags=np.arange(len(corr))is used.- method
str,default“ywm” Specifies which method for the calculations to use.
“ywm”, “ywmle” or “yw_mle” : Yule-Walker via the multivariate Levinson-Durbin recursion without sample-size adjustment in the autocovariance denominator. Default.
“yw”, “ywa”, “ywadjusted” or “yw_adjusted” : Yule-Walker via the multivariate Levinson-Durbin recursion with sample-size adjustment in the autocovariance denominator.
“ols” : OLS regression of x_t and y_{t+h} on all intervening observations.
- 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
markerkwarg.- title
str,optional Title to place on plot. Default is ‘Partial Cross-correlation’.
- auto_ylimsbool,
optional If True, adjusts automatically the vertical axis limits to PCCF values.
- vlines_kwargs
dict,optional Optional dictionary of keyword arguments that are passed to vlines.
- **kwargs
kwargs,optional Optional keyword arguments that are directly passed on to the Matplotlib
plotandaxhlinefunctions.
- Returns:
FigureThe figure where the plot is drawn. This is either an existing figure if the ax argument is provided, or a newly created figure if ax is None.
See also
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_pccf( ... diffed["unemp"], diffed["infl"] ... ) >>> plt.show()