Autocorrelation (acf), partial autocorrelation (pacf),
cross-correlation (ccf), Durbin-Watson, Ljung-Box, and Box-Pierce tests —
mirrors statsmodels.tsa.stattools and pd.Series.autocorr.
autocorr(x, lag) computes the Pearson correlation between
x[0..n−lag−1] and x[lag..n−1], exactly like
pd.Series.autocorr(lag).
acf(x, { nlags, alpha }) returns all autocorrelations at lags 0…nlags.
With alpha=0.05, Bartlett confidence intervals are returned: lags whose
CI excludes zero are statistically significant.
pacf(x, { nlags, alpha }) uses the Levinson-Durbin recursion to compute
partial autocorrelations. For a true AR(p) process, only the first p PACF values are
significantly non-zero — this is how you identify the AR order.
ccf(x, y, { nlags, alpha }) measures the linear relationship between
x[t] and y[t+k] at each lag k. Peaks in the CCF reveal
lead/lag relationships between two series.
durbinWatson(residuals) tests for first-order autocorrelation in OLS residuals.
Values near 2 indicate no autocorrelation; values near 0 indicate positive autocorrelation;
values near 4 indicate negative autocorrelation.
ljungBox(x, { lags }) and boxPierce(x, { lags }) test the null
hypothesis that no autocorrelation exists up to a given lag. Small p-values reject the
white-noise hypothesis. Ljung-Box has better finite-sample properties.