Skip to content

Fix residual calculation inconsistency between plotResidualsVsCovariate and calculateResiduals#1853

Merged
KatrinCoboeken merged 13 commits intomainfrom
copilot/unify-residual-calculation-methods
Apr 20, 2026
Merged

Fix residual calculation inconsistency between plotResidualsVsCovariate and calculateResiduals#1853
KatrinCoboeken merged 13 commits intomainfrom
copilot/unify-residual-calculation-methods

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

plotResidualsVsCovariate was delegating residual computation to ospsuite.plots internally, while calculateResiduals used addResidualColumn. The two approaches diverged: ospsuite.plots uses plain log() (producing extreme values like −44 for zero observations), while addResidualColumn produces NaN with 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, and plotQuantileQuantilePlot. This is done in this PR.

Additionally svg were updated.

…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 plotResidualsVsCovariate and calculateResiduals Apr 9, 2026
Copilot AI requested a review from KatrinCoboeken April 9, 2026 11:56
@KatrinCoboeken KatrinCoboeken requested a review from pchelle April 10, 2026 06:49
@KatrinCoboeken
Copy link
Copy Markdown
Contributor

@pchelle Could you review?

@rengelke rengelke mentioned this pull request Apr 16, 2026
@KatrinCoboeken KatrinCoboeken marked this pull request as ready for review April 20, 2026 06:35
@KatrinCoboeken KatrinCoboeken merged commit eaffbf6 into main Apr 20, 2026
17 of 18 checks passed
@KatrinCoboeken KatrinCoboeken deleted the copilot/unify-residual-calculation-methods branch April 20, 2026 06:35
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.

Different values calculated by plotResidualsVsCovariate and calculateResiduals

4 participants