Repository navigation
plot.psa(): log axes with correctly shaped ellipses (xtrans, ytrans) (#201) - #250
Merged
Merged
Conversation
…scale (#201) The ellipses were computed on the data scale, so on log axes (added with scale_*_log10()) they lost their shape and any part below zero became NaN. plot.psa() now takes xtrans and ytrans, passes them to its own scales, and computes each ellipse from the transformed samples before mapping it back. Values a transformation cannot show (zero or negative on a log scale, common on the incremental plane) give an informative error. With the default identity transformations the plots are unchanged. The duplicated ellipse code of the two planes is now one helper, psa_ellipses().
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 209-reference-strategy-core #250 +/- ##
===============================================================
+ Coverage 93.65% 93.69% +0.03%
===============================================================
Files 18 18
Lines 2002 2013 +11
===============================================================
+ Hits 1875 1886 +11
Misses 127 127
🚀 New features to boost your workflow:
|
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.
Closes #201.
Base: this PR is built on #227 (
209-reference-strategy-core), because it changesplot.psa(), which #227 also changes. When #227 merges, GitHub retargets this PR tomain.Problem
On skewed PSA results, a log scale for cost or QALYs reads better (#201). But
plot.psa()had no axis-transformation argument. Users added+ scale_y_log10(), which replaced the package's scale, and the ellipses were still computed on the original scale. Onexample_psa_objthat givesNaNs producedandlog-10 transformation introduced infinite values. The ellipses extend below zero cost, so they break, and where they survive they are the wrong shape.Change
plot.psa()gainsxtransandytrans(default"identity"), passed to its own scales throughadd_common_aes(). Any ggplot2 transformation works, such as"log10","sqrt", or ascales::transform_*().ytrans = "log10"` cannot show every incremental cost value: some are outside its domain (zero or negative, for a log scale). Differences from the reference strategy are often negative.psa_ellipses().Tests (test_psa.R)
ellipse::ellipse()computed on the log10 samples.Verification
devtools::test(): 485 passed, 0 failed.lintr: 0 lints.R CMD check --as-cran: only the development-version NOTE.