Skip to content

Fix dof + improve collinearity detection#279

Merged
eloualiche merged 2 commits into
FixedEffects:mainfrom
matthieugomez:fix-dof-and-collinearity
Jun 4, 2026
Merged

Fix dof + improve collinearity detection#279
eloualiche merged 2 commits into
FixedEffects:mainfrom
matthieugomez:fix-dof-and-collinearity

Conversation

@matthieugomez

@matthieugomez matthieugomez commented May 30, 2026

Copy link
Copy Markdown
Member

Fix degrees-of-freedom reporting and improve API/docs

Main fix: residual dof no longer subtracts the intercept twice — it is now
N-K (and G-1 for clustered standard errors), matching Stata. The standard
errors themselves were already correct.

Also:

  • Collinearity detection is scale-invariant, so small-scale independent
    regressors are no longer wrongly dropped.
  • dof_fes ignores continuous-FE groups (fe(id)&x) whose interaction is all zero.
  • coeftable labels the confidence-interval columns with the requested level.
  • partial_out: deprecate method=:gpu and default tol to 1e-6 (so its residuals
    match reg).
  • Clearer errors (malformed formulas), new docstrings (fe, has_iv, has_fe,
    dof_fes, FixedEffectModel, collinear-omitted NaN convention), and small
    README fixes.

🤖 Generated with Claude Code

@matthieugomez matthieugomez force-pushed the fix-dof-and-collinearity branch from f79c15d to c4f209b Compare May 30, 2026 11:20
@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@b0aabc3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/fit.jl 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #279   +/-   ##
=======================================
  Coverage        ?   97.97%           
=======================================
  Files           ?        8           
  Lines           ?      693           
  Branches        ?        0           
=======================================
  Hits            ?      679           
  Misses          ?       14           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 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.

@matthieugomez matthieugomez force-pushed the fix-dof-and-collinearity branch from c4f209b to 4fb651f Compare May 30, 2026 11:35
@matthieugomez matthieugomez changed the title Fix dof and collinearity Fix dof + improve collinearity detection May 30, 2026
Main fix: residual dof no longer subtracts the intercept twice — it is now
N-K (and G-1 for clustered standard errors), matching Stata. The standard
errors themselves were already correct.

Also:
- Collinearity detection is scale-invariant, so small-scale independent
  regressors are no longer wrongly dropped.
- dof_fes ignores continuous-FE groups (fe(id)&x) whose interaction is all zero.
- coeftable labels the confidence-interval columns with the requested level.
- partial_out: deprecate method=:gpu and default tol to 1e-6 (so its residuals
  match reg).
- Clearer errors (malformed formulas), new docstrings (fe, has_iv, has_fe,
  dof_fes, FixedEffectModel, collinear-omitted NaN convention), and small
  README fixes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@matthieugomez matthieugomez force-pushed the fix-dof-and-collinearity branch from 4fb651f to 7bde4e4 Compare May 30, 2026 11:42
HC2/HC3 compute leverage from the partialled-out (demeaned) regressors
only, omitting the absorbed fixed-effect contribution to leverage. This
silently understates leverage and yields anti-conservative standard
errors whenever fe() is used. Throw an informative ArgumentError for the
combination, mirroring the existing IV guard (HC2/HC3 are likewise
rejected for IV), and point users to Vcov.robust() (HC1) or Vcov.cluster().

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@eloualiche eloualiche merged commit 130b905 into FixedEffects:main Jun 4, 2026
4 checks passed
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.

2 participants