Skip to content

Incremental CE plane and WTP lines in plot.icers() and plot.psa() (#209, #202) - #228

Merged
feralaes merged 1 commit into
209-reference-strategy-corefrom
209-reference-strategy-plots
Nov 12, 2026
Merged

feralaes merged 1 commit into
209-reference-strategy-corefrom
209-reference-strategy-plots

Conversation

@feralaes

@feralaes feralaes commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Second PR of the reference-strategy series (#209), covering the plots. It also adds the willingness-to-pay line requested in #202.

Stacked on #227 (the ICER table). The diff shows only this change.

Part of #209. Covers the WTP-line part of #202; the quadrant table is in the next PR.

Example

x <- calculate_icers(cost, effect, strategies, ref_str = "Chemotherapy", wtp = 50000)
plot(x, ref_str = "Chemotherapy", wtp = 50000)          # incremental CE plane + WTP line
plot(psa, ref_str = "Chemotherapy", wtp = 50000)        # same for the PSA cloud

Left, plot.icers(ref_str, wtp): the reference is at the origin, the frontier and statuses are unchanged, and the dotted line is the WTP threshold. Right, plot.psa(ref_str, wtp), using cancer_psa_data. Both captions name the reference and the threshold, e.g. "Reference Strategy: Chemotherapy; Dotted line: WTP = $50,000/QALY".

What changed

  • plot.icers() gains ref_str, wtp, ref_axis and ref_caption. These are the same names plot.psa() already uses, and they're added after the existing arguments.
    • ref_str moves the reference strategy to the origin (the incremental plane), with dashed axes. It only moves the axes: dominance and the frontier are unchanged.
    • wtp draws a dotted line with slope wtp through the reference. Without ref_str, it goes through the least costly strategy on the frontier.
    • The currency defaults to the one stored by calculate_icers(currency = ).
  • plot.psa() gains wtp, the same line on its incremental plane. It requires ref_str, because the absolute plane has no natural anchor for the line.
  • Bug fix: plot.psa(ref_str = ) with only two strategies failed with "'dims' cannot be of length 0". With a single comparator, the subsetting dropped to a vector; it now uses drop = FALSE. ref_str is checked with the shared check_ref_str().
  • Captions: they now name both the reference and the WTP threshold. This also removes a double space in plot.psa()'s existing caption ("Reference Strategy: X" → "Reference Strategy: X"). That is the only change to any existing output (the psa_analysis vignette's caption).

Tests

New test_reference_plots.R:

  • Unchanged defaults: default plots are unchanged, with no WTP line and the same labels and points.
  • Incremental plane: the plotted coordinates equal cost and effect minus the reference's, with the right axis labels and caption.
  • WTP line: its slope, and its intercept with and without a reference.
  • Currency: the currency stored on the object is used, and it can be overridden.
  • plot.psa(): the two-strategy case now plots the correct differences.
  • Errors: for wtp without ref_str and for an unknown ref_str.

Verification

Noted, not changed

plot.icers() shows its cost axis without thousands separators ("-16000"), while plot.psa() uses them ("60,000"). This predates this PR and fits the plot-argument harmonization issue (#214).

plot.icers and plot.psa with a reference strategy and a WTP line

…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
@feralaes
feralaes merged commit a22ee3d into 209-reference-strategy-core Nov 12, 2026
9 checks passed
@feralaes
feralaes deleted the 209-reference-strategy-plots branch November 12, 2026 22:29
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.

1 participant