Fix residual calculation inconsistency between plotResidualsVsCovariate and calculateResiduals#1853
Merged
KatrinCoboeken merged 13 commits intomainfrom Apr 20, 2026
Merged
Conversation
…nstead of predicted/observed Agent-Logs-Url: https://github.com/Open-Systems-Pharmacology/OSPSuite-R/sessions/fad85bed-39dc-425c-a47a-5282b067ff03 Co-authored-by: KatrinCoboeken <28564329+KatrinCoboeken@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Unify residual calculations in plotResidualsVsCovariate
Fix residual calculation inconsistency between Apr 9, 2026
plotResidualsVsCovariate and calculateResiduals
Contributor
|
@pchelle Could you review? |
Merged
pchelle
approved these changes
Apr 20, 2026
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.
plotResidualsVsCovariatewas delegating residual computation toospsuite.plotsinternally, whilecalculateResidualsusedaddResidualColumn. The two approaches diverged:ospsuite.plotsuses plainlog()(producing extreme values like −44 for zero observations), whileaddResidualColumnproducesNaNwith a warning — the correct behaviour.Main discussion is in #1713
Conclusion was: "C) We could give up functionality in OSPSuite.plots. Currently, the plotting functions in OSPSuite.Plots take the input residualScale and calculate the residuals from the observed and predicted values. This could be reverted so that the residual calculation occurs outside. The function in OSPSuite-R could then be designed to take a data.frame as input and add a new column for the residuals. The column has an attribute label which can be used for the y-axis plot label.
The function would be called in .extractResidualsToTibble() in ospsuite-R"
Main work was done in #1811
Still missing was the adjustment of the mapping in the functions
plotResidualsVsCovariate,plotResidualsAsHistogram, andplotQuantileQuantilePlot. This is done in this PR.Additionally svg were updated.