Skip to content

Carry the currency of a psa object through to its analyses (#203) - #242

Merged
feralaes merged 1 commit into
209-reference-strategy-corefrom
203-currency
Nov 13, 2026
Merged

feralaes merged 1 commit into
209-reference-strategy-corefrom
203-currency

Conversation

@feralaes

Copy link
Copy Markdown
Collaborator

Closes #203

Stacked on #227, which adds calculate_icers(currency = ) and the currency-aware print.icers()/plot.icers(). The diff shows only this change. When #227 merges, GitHub retargets this PR to main.

The problem (#203)

make_psa_obj(..., currency = "€") stored the currency, but only plot.psa() used it. Every other analysis and plot defaulted to a hard-coded "$", so users had to pass currency = to each plot.

What changed

  • Results carry the currency. ceac(), calc_exp_loss(), calc_evpi(), calc_evppi(), calc_evsi() and calculate_icers_psa() keep psa$currency on their results.
  • Plots use it. In each plot() method (and print.icers()), currency now defaults to NULL, which resolves to the argument if given, else the result's currency, else "$". Positional calls are unaffected, and an explicit currency = still overrides.
  • plot.ceac() gains effect_units. Its x-axis label had "QALY" hard-coded.
  • VOI in health units are labeled in health units. EVPPI and EVSI computed from net health benefit (outcome = "nhb") are in QALYs, so their plots now read "EVPPI (QALY)" and "EVSI (QALY)". This also fixes a mislabeling: calc_evsi() defaults to outcome = "nhb", so its default plot said "EVSI ($)" for a value in QALYs.

Tests

New test_currency.R builds a PSA in euros and checks, for every affected function:

  • the currency is stored on the result,
  • plot labels use "€",
  • currency = "£" overrides it,
  • effect_units works in plot.ceac(),
  • outcomes in health units are labeled "(QALY)",
  • a dollar PSA still gives "$" labels.

Two existing tests now build their expected object with the same currency.

Verification

Not changed

run_owsa_det() and run_twsa_det() don't gain a currency argument: their OWSA/TWSA results and plots never show a currency.

- 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
@feralaes
feralaes requested a review from mbkauf November 13, 2026 15:10
@feralaes
feralaes merged commit 33c9905 into 209-reference-strategy-core Nov 13, 2026
11 checks passed
@feralaes
feralaes deleted the 203-currency branch November 13, 2026 15:24
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