Repository navigation
BUG: Exclude implicit intercepts from panel and system F tests - #876
Swapnil-byte-798 wants to merge 1 commit into
Conversation
Test the coefficient restrictions that reduce the fitted model to a constant. Use the transformed constant in PanelOLS so the tests still work after a fixed effect absorbs one of the original dummy columns. Co-authored-by: Codex <codex@openai.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #876 +/- ##
========================================
Coverage 99.69% 99.69%
========================================
Files 202 203 +1
Lines 38871 38988 +117
Branches 2501 2511 +10
========================================
+ Hits 38752 38869 +117
Misses 51 51
Partials 68 68
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:
|
bashtage
left a comment
There was a problem hiding this comment.
Thanks, this is a real fix. With dummies that imply the constant, the robust F of the panel models and the equation F of the system models dropped an arbitrary regressor from the test (165.14 on main vs 5.632 here for the PooledOLS example in the description). I checked the panel models, PanelOLS with absorbed dummies and the system models against a hand Wald test and against the same model with an explicit constant; they agree to about 1e-14. Results of models with an explicit constant or no constant are unchanged, apart from rounding (at most 1.6e-14 relative in a few PanelOLS F statistics).
Two text changes before merging:
-
Release note: please replace the bullet with this one, which says what 7.1 did:
- The robust model F statistic of the panel models (``f_statistic_robust``) and the equation F statistics of ``SUR``, ``IV3SLS`` and ``IVSystemGMM`` leave out an intercept that the regressors imply, such as dummies that sum to one in a model without a constant. They test that the group effects are equal and the other coefficients are zero. 7.1 dropped one regressor from the test instead, which could be one of the dummies or another variable. The classical F statistic of ``PanelOLS`` is also correct when ``drop_absorbed=True`` drops dummies that imply the intercept, for example a dummy for every period with time effects (:issue:`780`, :issue:`876`).
-
The Notes of
PanelResults.f_statistic_robust,FamaMacBethResults.f_statistic_robustandSystemEquationResult.f_statisticstill describe the old test. Please add after the formula paragraph:If the regressors span a constant without a constant column, for example a dummy for every group, the null is that the fitted values are constant: the group coefficients are equal and all other coefficients are zero. .. versionchanged:: 7.2 With an implicit constant, the test no longer drops one of the regressors and tests that the others are zero.
Optional: scale[scale == 0] = 1 in _implicit_constant_restriction can't be reached, since every caller has full-rank regressors, so it could go.
Related to #780. The robust panel and system equation F tests can select the wrong null when the regressors jointly span an intercept. With two complementary dummies and a slope, the constant-only model has equal group effects and a zero slope. Dropping one dummy from the test instead imposes a zero group effect.
In the regression fixture, the pooled chi-square statistic falls from 165.136 to 5.632 on two degrees of freedom, matching the equivalent explicit-intercept design. With the F reference distribution, the corrected result also matches an independent statsmodels OLS fit (F = 2.7831, p = 0.06374).
The patch reuses the restriction construction from #859, keeping the existing covariance and reference distribution for each estimator. For
PanelOLS, the transformed constant also gives the correct classical F test whendrop_absorbed=Trueremoves a column that contributed to the intercept.Verification
d7980a7, 58 new cases fail and the singular-covariance control passes. On this branch, all 59 pass. Coverage includes weighted fits, rescaled dummies, Hotelling's test for FamaMacBeth, three fixed-effect solvers, and equations fitted by SUR, IV3SLS and IVSystemGMM.--skip-slow --skip-examples) reported 23,449 passed, 2,783 skipped and 47 expected failures. Changed-file Ruff, isort, Black, numpydoc and whitespace checks passed. The same 17 informational mypy diagnostics occur on the base and the patch.Codex assisted with implementation, testing, and this description.