sigmaquant.research.autocorr.ljung_box#
- sigmaquant.research.autocorr.ljung_box(
- values,
- lags=None,
- boxpierce=False,
- model_df=0,
- epsilon=0.05,
Ljung-Box (or Box-Pierce) test for autocorrelation.
The test evaluates the joint null hypothesis that autocorrelations up to a specified lag are equal to zero.
H0: rho_1 = rho_2 = … = rho_k = 0 H1: at least one rho_i != 0
- Parameters:
values (ArrayLike) – Time series observations.
lags (int | None, default None) – Number of lags included in the test. If None, a default value proportional to log(sample_size) is used.
boxpierce (bool, default False) – If True, compute the Box-Pierce statistic instead of Ljung-Box.
model_df (int, default 0) – Number of parameters estimated in the model whose residuals are being tested. This adjusts the degrees of freedom of the test.
epsilon (float, default 0.05) – Significance level used for the rejection decision.
- Returns:
Structured container with statistic values, p-values, and the rejection decision.
- Return type:
Notes
The Ljung-Box statistic is
Q = T (T + 2) * sum_{k=1}^h rho_k^2 / (T - k)
which asymptotically follows a chi-square distribution with (h - model_df) degrees of freedom.