Skip to content

DOC: Follow up on #10476, document WLS influence and add R reference tests - #10563

Merged
bashtage merged 2 commits into
statsmodels:mainfrom
bashtage:wip-fu-10476
Oct 25, 2026
Merged

bashtage merged 2 commits into
statsmodels:mainfrom
bashtage:wip-fu-10476

Conversation

@bashtage

Copy link
Copy Markdown
Member
  • closes #xxxx
  • tests added / passed.
  • code/documentation is well formatted.
  • properly formatted commit message. See
    NumPy's guide.

Follow up to #10476 (OLSInfluence uses the weights of WLS results). It addresses the points left in the review of that PR.

  • The OLSInfluence docstring was partly stale. The summary and Notes now cover OLS and WLS, with a versionchanged note; they state that WLS weights are precision weights as in WLS.mse_resid (the residual degrees of freedom count the rows, not sum(w)), what happens with zero weights (WLS.df_resid counts the zero-weight rows whereas R drops them, so the quantities that use the residual degrees of freedom are larger by (nobs - k) / (n_pos - k); hat and Cook's distance of those rows are 0), which sum of squares ess_press is (the unweighted PRESS; resid_press stays on the endog scale), and that GLS with a non-trivial sigma is not supported and silently gives wrong values.
  • New tests: a reference test with values from R 4.6.1 (lm(y ~ x1 + x2, weights = w): hatvalues, rstandard, rstudent, cooks.distance, dffits, covratio, dfbeta, dfbetas), compared with rtol=1e-8 (the R command and version are in a comment); a rank-deficient WLS exog and an observation with hat diagonal 1, both against brute-force refits; and zero weights against a fit on the positive-weight rows with the factor above.
  • The function-local OLSInfluence imports of the tests are one module-level import.

Not changed: an error for GLS with a non-identity sigma is a design decision, as is get_influence for WLS results. With a rank-deficient exog OLSInfluence emits a SingularMatrixWarning for every refit; that is the existing behaviour and the test ignores it.

The release note is in the single 0.15.1 draft.

AI Disclosure

Contributions must comply with the statsmodels AI Policy.

Tick exactly one of the following. If AI tools were used, replace the <...>
placeholders in the second option with the tool name(s) and how the tool's output was
used.

  • No AI tools were used to develop this pull request.
  • AI tools were used.
    Tool(s): Claude Code (Claude Sonnet 5.5).
    Used for: reviewing the merged PR, checking the values against R, drafting the docstring and the tests.
    I have personally read, understood, and can explain every line of this diff, and
    have verified the statistical/numerical correctness of the change.

🤖 Generated with Claude Code

bashtage and others added 2 commits October 24, 2026 23:18
Add versionchanged for the use of the weights, state that WLS weights are precision weights, how zero weights differ from R, which sum of squares ess_press is, and that only OLS and WLS are supported (GLS with sigma is silently incorrect). Follow up to statsmodelsgh-10476.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Compare OLSInfluence of WLS results with R 4.6.1 influence measures for lm with weights, add tests for rank deficient exog, a unit hat diagonal and zero weights, and move the OLSInfluence imports to module level. Follow up to statsmodelsgh-10476.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@bashtage bashtage mentioned this pull request Oct 24, 2026
4 of 6 tasks
@bashtage
bashtage marked this pull request as ready for review October 25, 2026 08:55
@bashtage
bashtage merged commit 390eec9 into statsmodels:main Oct 25, 2026
8 of 11 checks passed
@bashtage
bashtage deleted the wip-fu-10476 branch October 25, 2026 17:34
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.

1 participant