Logo

statsmodels.tsa.stattools.acf

statsmodels.tsa.stattools.acf(x, unbiased=False, nlags=40, confint=None, qstat=False, fft=False, alpha=None)[source]

Autocorrelation function for 1d arrays.

Parameters:

x : array

Time series data

unbiased : bool

If True, then denominators for autocovariance are n-k, otherwise n

nlags: int, optional :

Number of lags to return autocorrelation for.

confint : scalar, optional

The use of confint is deprecated. See alpha. If a number is given, the confidence intervals for the given level are returned. For instance if confint=95, 95 % confidence intervals are returned where the standard deviation is computed according to Bartlett’s formula.

qstat : bool, optional

If True, returns the Ljung-Box q statistic for each autocorrelation coefficient. See q_stat for more information.

fft : bool, optional

If True, computes the ACF via FFT.

alpha : scalar, optional

If a number is given, the confidence intervals for the given level are returned. For instance if alpha=.05, 95 % confidence intervals are returned where the standard deviation is computed according to Bartlett’s formula.

Returns:

acf : array

autocorrelation function

confint : array, optional

Confidence intervals for the ACF. Returned if confint is not None.

qstat : array, optional

The Ljung-Box Q-Statistic. Returned if q_stat is True.

pvalues : array, optional

The p-values associated with the Q-statistics. Returned if q_stat is True.

Notes

The acf at lag 0 (ie., 1) is returned.

This is based np.correlate which does full convolution. For very long time series it is recommended to use fft convolution instead.

If unbiased is true, the denominator for the autocovariance is adjusted but the autocorrelation is not an unbiased estimtor.

Previous topic

statsmodels.tsa.stattools.acovf

Next topic

statsmodels.tsa.stattools.pacf

This Page