Add Li-Mak (1994) portmanteau test for ARCH effects in standardized residuals#856
Open
hass-nation wants to merge 1 commit into
Open
Add Li-Mak (1994) portmanteau test for ARCH effects in standardized residuals#856hass-nation wants to merge 1 commit into
hass-nation wants to merge 1 commit into
Conversation
…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 Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #405.
Adds
li_mak_test(lags, fitdf)toARCHModelFixedResult, 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:where
r̂ₖis the k-th autocorrelation ofe_t²andfitdfdefaults tovolatility.num_params − 1(all estimated lag parameters, excluding the constant ω).Why this is different from
arch_lm_testarch_lm_testli_mak_testr_tr_t / σ_tT · R²)− fitdfarch_lm_testdetects heteroskedasticity in raw residuals;li_mak_testchecks 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 asarch_lm_test)fitdf— df correction (default:volatility.num_params − 1; passfitdf=0for uncorrected Ljung-Box)Tests
3 new test functions in
arch/tests/univariate/test_mean.py:test_li_mak— default call, explicit lags,fitdf=0cross-check against manual Ljung-Box, comparison witharch_lm_test, customfitdftest_li_mak_constant_variance—ConstantVariancemodel givesfitdf=0test_li_mak_pval_structure— p-value, critical values, repr consistencyAll 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