Repository navigation
Use fitted rows for binned residuals with na.exclude - #1039
Merged
strengejacke merged 1 commit intoDec 2, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No actionable issues were found in the reviewed changes.
No open issues 🎉
What changed in this PR
Fixes binned_residuals() for na.exclude models by aligning fitted values and residuals with fitted observations.
Changes:
- Applies
.fitted_rows()to fitted values and deviance residuals. - Adds regression tests comparing
na.excludeandna.omit. - Documents the fix in
NEWS.md.
| File | Description |
|---|---|
| tests/testthat/test-binned_residuals.R | Adds regression coverage comparing binned residuals for na.exclude and na.omit models. |
| R/binned_residuals.R | Aligns fitted values and deviance residuals with the rows used during model fitting. |
| NEWS.md | Documents the na.exclude binned-residuals fix. |
Review effort: Lite
Member
|
LGTM (and also LGTcopilot), thanks! |
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.
Fixes #1038.
With
na.exclude, fitted values and deviance residuals can include placeholders for rows the model dropped. The response and predictor used to build the bins contain only the fitted rows. Reuse.fitted_rows()to align the vectors before calculating residuals or allocating the bins.Added comparisons with
na.omitfor bins based on fitted values and on a named predictor. The binned-residual tests pass, andcheck_model()returns the same six bins for both fits in the reported example.R CMD check --no-manualpassed with available suggested packages.