Repository navigation
Conversation
calculate_icers() gains ref_str, wtp, nhb, and currency (added after the
existing arguments, so positional calls keep working). The frontier
(Status, Inc_Cost, Inc_Effect, ICER) is computed exactly as before and is
never changed; the new columns are added afterwards by
add_reference_and_nmb(), and only for the arguments that are given, so
with the defaults the object is identical to before.
- ref_str: Inc_Cost_ref, Inc_Effect_ref, ICER_ref (numeric, NA where a
ratio is not meaningful), and Status_ref ('Reference', 'Dominant',
'Dominated', 'More costly, more effective', 'Less costly, less
effective', or 'Equivalent' for the same cost and effect) (#209).
- wtp: NMB, plus iNMB_ref with a reference (#200); nhb = TRUE also adds
NHB and iNHB_ref.
- currency: stored on the object and used by print.icers().
- print.icers() gains ref = c('sequential', 'reference', 'both'); the
default prints the same table as before. Headers name the reference
('Incremental Costs vs Standard of care ($)').
- Validation helpers check_ref_str() and check_wtp_nhb() with clear
errors; a new example in ?calculate_icers.
Tests (test_icers_reference.R) check hand-calculated values for every
Status_ref category, a dominated and a most-expensive reference,
hund_strat, NMB/NHB, one and two strategies, names with spaces, the
errors, and the print views. The default printed tables are identical to
main's print.icers().
Part of #209. Closes #200
…lines - plot.icers() gains ref_str, wtp, ref_axis, and ref_caption (after the existing arguments). ref_str shifts the plot so the reference strategy is at the origin (the frontier and statuses are unchanged); wtp draws a dotted line with slope wtp through the reference, or without ref_str through the least costly frontier strategy. The currency defaults to the one stored by calculate_icers() (#209, #202). - plot.psa() gains wtp, which draws the same line on its incremental plane (requires ref_str) (#202). - plot.psa(ref_str = ) with two strategies: keep a data frame when one comparator is left (drop = FALSE); it failed with "'dims' cannot be of length 0". ref_str is now checked with check_ref_str(). - Captions name the reference and the WTP threshold; this also removes a double space in plot.psa()'s 'Reference Strategy: X' caption. - Tests (test_reference_plots.R) check the plotted coordinates, axis labels, captions, WTP line slope and intercept, currency, the two-strategy case, and the errors. Default plots are unchanged. Part of #209
…_icers_psa() - summary.psa() gains ref_str and wtp (after calc_sds). With ref_str it adds meanIncCost, meanIncEffect, and the share of PSA samples in each quadrant of the incremental CE plane (propNE, propSE, propSW, propNW; NA for the reference). With wtp it adds meanNMB, and with ref_str also meanIncNMB and propCostEffective (share of samples with a higher NMB than the reference) (#209, #202). - calculate_icers_psa() gains ref_str, wtp, and nhb, passed to calculate_icers(). With uncertainty = TRUE and ref_str, it adds 95% intervals of the sample-by-sample differences from the reference (Lower_95_/Upper_95_ for Inc_Cost_ref, Inc_Effect_ref, iNMB_ref). The icers class and attributes are now kept through the uncertainty joins. - print.icers(): every *_ref column belongs to the reference view. - Docs: escape % in roxygen. An unescaped % starts an Rd comment, which had silently truncated ?calculate_icers_psa ('whether or not 95') and ?predict.metamodel. calculate_icers_psa() output for existing calls is identical to main's (objects, class, and printed tables, with and without uncertainty). Part of #209. Closes #202
…y-core # Conflicts: # NEWS.md
…fix entry first in Bug fixes so the open PRs merge in any order
- ceac(), calc_exp_loss(), calc_evpi(), calc_evppi(), calc_evsi(), and calculate_icers_psa() store psa$currency on their results. - Their plot() methods (and print.icers()) use it: currency defaults to NULL, resolved by resolve_currency() as the argument if given, else the result's currency, else '$'. Existing calls keep working. - plot.ceac() gains effect_units (the x-axis label hard-coded QALY). - EVPPI and EVSI computed from net health benefit are in health units: calc_evppi() and calc_evsi() store the outcome, and their plots are labeled 'EVPPI (QALY)' / 'EVSI (QALY)' instead of a currency. calc_evsi() defaults to outcome = 'nhb', so its default plot was mislabeled in dollars. - Tests (test_currency.R) with a euro PSA for every function, overrides, effect_units, and dollar defaults; two existing tests now build the expected object with the same currency. Outputs of all vignettes and examples change only by the new currency attribute; values, plot data, and labels are unchanged. Closes #203
Carry the currency of a psa object through to its analyses (#203)
mbkauf
left a comment
There was a problem hiding this comment.
icers.R
- Printing with reference strategy has the strategies in the same order as without a reference strategy. So, the example code in the roxygen has the reference strategy is "1", but it ends up being the 55th strategy printed in the table. It should reorder with the reference strategy at the top? Or at least with some other ordering with respect to the reference strategy.
- In calculate_icers() lines 117 to 124, there is a chunk of code for if only 1 strategy is provided. It returns a data frame, but should it just return an error that more than 1 strategy must be provided?
- Are lines 103, 369-370 necessary?
- General naming conventions as it relates to capitalization. Should everything be lower case unless it's for formatting purposes to display.
- Line 406, what is everything() doing? Is it necessary?
- Add comments to explain code in add_reference_and_nmb() and add_reference_intervals() functions. In general, more commenting with newly written code would be good.
- Do we want incremental net monetary and incremental net health benefit to have the lower case "i" in the name (e.g. iNMB and iNHB)?
psa.R
- Lines 219-222, why does having a WTP threshold require a reference strategy be supplied?
…ng, wtp without ref_str in plot.psa - print.icers(ref = "reference") lists the reference first and the other strategies by increasing cost; "sequential" and "both" keep the frontier order. - Rename iNMB_ref/iNHB_ref to Inc_NMB_ref/Inc_NHB_ref, matching Inc_Cost_ref, Inc_Effect_ref and summary.psa()'s meanIncNMB. Print headers say "Incremental NMB/NHB". - plot.psa(wtp = ) no longer requires ref_str: without one, the line goes through the mean of the least costly strategy, as plot.icers() already did. - Comment add_reference_and_nmb(), add_reference_intervals(), the global-variable declarations, and the everything() in calculate_icers_psa().
|
@mbkauf thanks for the careful review. Point by point; the changes are in 308850f. icers.R
psa.R
Tests: 343 passing, 0 lints, R CMD check |
…rtainty; drop context() for testthat 3e - plot.icers() now always reduces x to its seven plot columns as a plain data frame. dplyr::select() had dropped the stored currency attribute only when uncertainty bounds were present, so the two plots differed under testthat's edition-3 comparison. - Replace context() in the four test files added by this PR (deprecated in edition 3).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #227 +/- ##
==========================================
+ Coverage 93.09% 93.83% +0.74%
==========================================
Files 18 18
Lines 1824 2028 +204
==========================================
+ Hits 1698 1903 +205
+ Misses 126 125 -1
🚀 New features to boost your workflow:
|
…y-core # Conflicts: # NEWS.md
…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().
…idth, axis limits, effect_units
- ceac() takes the psa object first, like calc_exp_loss() and calc_evpi(). The old positional
ceac(wtp, psa) still works with lifecycle::deprecate_soft(); named calls work in any order.
- plot.owsa() and plot.exp_loss() take linewidth; size and lsize still work, deprecated.
- plot.owsa() and plot.twsa() gain xlim/ylim, owsa_opt_strat() gains xlim.
- effect_units defaults to "QALYs" in every plot; per_unit() gives the singular for
willingness-to-pay labels, so default labels are unchanged ("$/QALY").
- lifecycle (>= 1.0.0) added to Imports.
- API style decision record in .github/CONTRIBUTING.md, including the open 2.0 questions.
plot.psa(): log axes with correctly shaped ellipses (xtrans, ytrans) (#201)
The minimum-dependency CI job could not install ggplot2@3.5.0 with lifecycle@1.0.0.
…o HEAD # Conflicts: # NEWS.md
Current dplyr needs lifecycle (>= 1.0.5) and ggplot2 3.5.0 needs lifecycle (> 1.0.1), so any lower pin makes the minimum-dependency environment unsolvable. dampack only uses deprecate_soft(), deprecated() and is_present(), which predate lifecycle 1.0.
Harmonize the API with soft deprecation: ceac(psa, wtp), linewidth, axis limits, effect_units (#214)
|
Hi @mbkauf and @krijkamp, Fernando asked me (Claude, working in his session) to send a short guide for reviewing this PR. It's the one most other work is waiting on: three more PRs are built on top of it. GitHub won't let Fernando approve his own PR, so it needs an approval from one of you. You don't need to read all the code. The most useful review is to run it and check that the results and wording make sense. 1. Try it (about 5 minutes)In R: remotes::install_github("DARTH-git/dampack", ref = "209-reference-strategy-core")
library(dampack)
data(cancer_psa_data)
psa <- make_psa_obj(cost = cancer_psa_data$cost,
effectiveness = cancer_psa_data$effectiveness,
parameters = cancer_psa_data$parameters,
strategies = cancer_psa_data$strategies)
icers <- calculate_icers_psa(psa, ref_str = "Radio", wtp = 100000)
print(icers) # the usual sequential table (unchanged)
print(icers, ref = "reference") # every strategy vs Radio, Radio listed first
plot(icers, ref_str = "Radio", wtp = 100000)
summary(psa, ref_str = "Radio", wtp = 100000) # mean differences and quadrant shares
plot(psa, ref_str = "Radio", wtp = 100000) # incremental CE plane with a WTP line2. What to look atMatt:
Eline: the methods, as agreed on #209:
Both:
3. How to leave your review on GitHub
A plain comment at the bottom of this page also works. Fernando or I will turn it into changes. |
First PR of the reference-strategy series (#209), the second headline feature of v1.1.0. This one covers the ICER table:
calculate_icers()andprint.icers().Part of #209 (next:
plot.icers()/plot.psa(), then the PSA summaries). Closes #200.This branch now also contains #228 (plots), #229 (PSA summaries), #242 (currency), #250 (log axes) and #251 (API harmonization), which were merged into it. So merging this PR also closes:
plot.icers()andplot.psa(), and the quadrant shares insummary.psa().psaobject carried through to its analyses (Carry the currency of a psa object through to its analyses (#203) #242).plot.psa()with correctly shaped ellipses (plot.psa(): log axes with correctly shaped ellipses (xtrans, ytrans) (#201) #250).ceac()argument order (soft deprecation) #214: consistent API with soft deprecation,ceac(psa, wtp)andlinewidth(Harmonize the API with soft deprecation: ceac(psa, wtp), linewidth, axis limits, effect_units (#214) #251).#209 stays open for its vignette section (#216).
Example
On the Hunink example (
hund_strat, first 5 strategies, strategy "1" as reference):Design, as agreed on #209
Status,Inc_Cost,Inc_EffectandICERare computed exactly as before. The comparison with the reference is added afterwards as separate columns. This avoids the problem with the 2019ref_stratoption, which re-sorted strategies before the dominance loop.ref_stris given:Inc_Cost_ref,Inc_Effect_ref.ICER_ref: numeric, andNAwhere a ratio isn't meaningful (the reference itself, and strategies that dominate, are dominated, or are equivalent).Status_ref: one of"Reference","Dominant","Dominated","More costly, more effective","Less costly, less effective".wtp:NMBby default, plusiNMB_refwith a reference.nhb = TRUEaddsNHBandiNHB_ref.print.icers():ref = "reference"/"both"show the comparison, and the headers name the reference strategy.calculate_icers(currency = )."Equivalent"A strategy with exactly the same cost and effect as the reference fits neither "Dominant" nor "Dominated". I labeled it
"Equivalent"(withICER_ref = NA). Please confirm, or suggest a different label.Backward compatibility
calculate_icers()returns exactly what it did before, with no new columns or attributes. The outputs of every vignette and help-page example are identical tomain; the one exception is the new example added to?calculate_icers.print.icers()prints identical tables tomain's version for existing objects (standard tables, PSA tables with uncertainty columns, custom currency and digits). I compared them directly.Tests
New
test_icers_reference.R:Status_refcategory.hund_strat.nhb = TRUE.ref_str, severalref_str, a vector or negativewtp, andnhbwithoutwtp.Verification
R CMD check --as-cran: 0 errors, 0 warnings, 1 NOTE (the development version number). This was run without the strayRplots.pdffiles, which Remove stray Rplots.pdf files committed in #223 #226 removes frommain.