Skip to content

Add Li-Mak (1994) portmanteau test for ARCH effects in standardized residuals#856

Open
hass-nation wants to merge 1 commit into
bashtage:mainfrom
hass-nation:feat/li-mak-test
Open

Add Li-Mak (1994) portmanteau test for ARCH effects in standardized residuals#856
hass-nation wants to merge 1 commit into
bashtage:mainfrom
hass-nation:feat/li-mak-test

Conversation

@hass-nation

Copy link
Copy Markdown

Summary

Closes #405.

Adds li_mak_test(lags, fitdf) to ARCHModelFixedResult, implementing the Li & Mak (1994) diagnostic test for remaining ARCH effects.

The test applies the Ljung-Box portmanteau statistic to squared standardized residuals e_t² = (r_t / σ_t)² and corrects the degrees of freedom for GARCH parameter estimation uncertainty:

Q*(m) = T(T+2) · Σₖ₌₁ᵐ r̂ₖ² / (T−k)   ~  χ²(m − fitdf)

where r̂ₖ is the k-th autocorrelation of e_t² and fitdf defaults to volatility.num_params − 1 (all estimated lag parameters, excluding the constant ω).

Why this is different from arch_lm_test

arch_lm_test li_mak_test
Residuals tested raw r_t standardized r_t / σ_t
Test statistic LM/OLS (T · R²) Ljung-Box
df correction none − fitdf
Null hypothesis residuals are homoskedastic GARCH model captures all variance clustering

arch_lm_test detects heteroskedasticity in raw residuals; li_mak_test checks whether the fitted GARCH model has adequately removed all conditional variance structure.

Parameters

  • lags — number of autocorrelation lags (default: ⌈1.2 · T^{1/4}⌉, same as arch_lm_test)
  • fitdf — df correction (default: volatility.num_params − 1; pass fitdf=0 for uncorrected Ljung-Box)

Tests

3 new test functions in arch/tests/univariate/test_mean.py:

  • test_li_mak — default call, explicit lags, fitdf=0 cross-check against manual Ljung-Box, comparison with arch_lm_test, custom fitdf
  • test_li_mak_constant_varianceConstantVariance model gives fitdf=0
  • test_li_mak_pval_structure — p-value, critical values, repr consistency

All existing tests pass unchanged.

Reference

Li, W. K. and Mak, T. K. (1994). On the Squared Residual Autocorrelations in Non-Linear Time Series with Conditional Heteroskedasticity. Journal of Time Series Analysis, 15(6), 627–636. https://doi.org/10.1111/j.1467-9892.1994.tb00217.x

🤖 Generated with Claude Code

…siduals

Adds `li_mak_test(lags, fitdf)` to `ARCHModelFixedResult`, implementing
the Ljung-Box portmanteau test on *squared standardized* residuals e_t^2 =
(r_t / sigma_t)^2 with the degrees-of-freedom correction derived by Li and
Mak (1994) for GARCH-estimated parameters.

Under a correctly specified GARCH(p,q) model the statistic is asymptotically
chi-squared with (lags - fitdf) degrees of freedom, where fitdf defaults to
volatility.num_params - 1 (all lag parameters, excluding the constant omega).
Unlike the existing arch_lm_test, which tests raw residuals for
heteroskedasticity via an OLS auxiliary regression, li_mak_test directly
checks whether the fitted GARCH model has captured all variance clustering.

Reference: Li, W.K. and Mak, T.K. (1994). On the Squared Residual
Autocorrelations in Non-Linear Time Series with Conditional Heteroskedasticity.
Journal of Time Series Analysis, 15(6), 627-636.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.10145% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.52%. Comparing base (543f44c) to head (d2331d4).

Files with missing lines Patch % Lines
arch/univariate/base.py 90.90% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #856      +/-   ##
==========================================
- Coverage   99.54%   99.52%   -0.03%     
==========================================
  Files          78       78              
  Lines       15818    15887      +69     
  Branches     1294     1298       +4     
==========================================
+ Hits        15746    15811      +65     
- Misses         38       40       +2     
- Partials       34       36       +2     
Flag Coverage Δ
adder 99.49% <97.10%> (-0.02%) ⬇️
subtractor 99.49% <97.10%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Li-Mak test for residual from arch model

1 participant