augment() can recompute rank() terms after omitting rows, producing values inconsistent with fitted()
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start by reading the augment() implementation and its tests for newdata = NULL, then trace how missing outcomes are omitted before predictions are computed. Add a reproducible case using a formula with rank() and missing outcomes; done means .fitted matches fitted(fit) for the observations used in the model, with residuals aligned to those observations.
Written by the indexing model from the issue text.
Description
Hi @danielinteractive, opening this separately as you suggested in #585.
While checking that fix, we noticed that augment(fit) can return .fitted values that differ from fitted(fit) when the formula includes rank(). Removing rows with missing outcomes before prediction changes the ranks of the remaining observations, so the predictions use different predictor values from those used to fit the model.
We saw this on the unmodified base too. With newdata = NULL, we would expect augment() to return the fitted values for the observations used in the model, alongside their matching residuals.
We’d be happy to look into this and put together a small reproducible example and a regression test. We’ll make sure the changes and tests are reviewed by a human before opening any PR.
Algoria
- Dominant language
- R
- Stars
- 162
- Forks
- 29
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 2
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openpharma/mmrm
-
augment() fails when unrelated missing values cause na.omit(x$data) to return zero rowsPossibly taken @algoria-contributions claimed this 3 days ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 66/100
openpharma/mmrm#585 · 5 comments ·
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
openpharma/mmrm#562 · 2 comments ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
openpharma/mmrm#551 · 2 comments · 1 reaction ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
openpharma/mmrm#538 · 6 comments ·
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 30/100
openpharma/mmrm#505 · 5 comments ·
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
OHDSI/CohortGenerator#281 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100