Repository navigation
DOC: Follow up on #10476, document WLS influence and add R reference tests - #10563
Merged
Merged
Conversation
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]>
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.
NumPy's guide.
Follow up to #10476 (
OLSInfluenceuses the weights of WLS results). It addresses the points left in the review of that PR.OLSInfluencedocstring was partly stale. The summary and Notes now cover OLS and WLS, with aversionchangednote; they state that WLS weights are precision weights as inWLS.mse_resid(the residual degrees of freedom count the rows, notsum(w)), what happens with zero weights (WLS.df_residcounts 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 squaresess_pressis (the unweighted PRESS;resid_pressstays on the endog scale), and that GLS with a non-trivialsigmais not supported and silently gives wrong values.lm(y ~ x1 + x2, weights = w):hatvalues,rstandard,rstudent,cooks.distance,dffits,covratio,dfbeta,dfbetas), compared withrtol=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.OLSInfluenceimports of the tests are one module-level import.Not changed: an error for GLS with a non-identity
sigmais a design decision, as isget_influencefor WLS results. With a rank-deficient exogOLSInfluenceemits aSingularMatrixWarningfor 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.
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