Skip to content

BUG: Exclude implicit intercepts from panel and system F tests - #876

Open
Swapnil-byte-798 wants to merge 1 commit into
bashtage:mainfrom
Swapnil-byte-798:fix/implicit-intercept-f-tests
Open

Swapnil-byte-798 wants to merge 1 commit into
bashtage:mainfrom
Swapnil-byte-798:fix/implicit-intercept-f-tests

Conversation

@Swapnil-byte-798

Copy link
Copy Markdown

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 when drop_absorbed=True removes a column that contributed to the intercept.

Verification

  • On upstream 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.
  • The full standard test selection (--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.

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>
Copilot AI balanced review requested due to automatic review settings November 16, 2026 07:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.69%. Comparing base (d7980a7) to head (32a937d).

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            
Flag Coverage Δ
adder 99.68% <100.00%> (+<0.01%) ⬆️
subtractor 99.68% <100.00%> (+<0.01%) ⬆️

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.

@bashtage bashtage left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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`).
  2. The Notes of PanelResults.f_statistic_robust, FamaMacBethResults.f_statistic_robust and SystemEquationResult.f_statistic still 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.

This branch has not been deployed

No deployments
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.

3 participants