Repository navigation
Fix Simpson's 1/3 within-cycle correction weights (v0.3.0) - #3
Merged
Merged
Conversation
gen_wcc(method = "Simpson1/3") assigned the 4/3 and 2/3 weights by position in the 1-based R vector instead of by time t = 0, ..., n, returning 1/3, 2/3, 4/3, ..., 1/3 instead of 1/3, 4/3, 2/3, ..., 1/3. The weights summed to n - 2/3 instead of n. - Index Simpson weights by time. - For an odd number of cycles (the tutorial uses 75), apply Simpson's 3/8 rule over the last three cycles so cubics are still integrated exactly and the weights sum to n. - Validate n_cycles (single positive integer; >= 2 for Simpson). - Use the corrected local gen_wcc() in the PSA wrapper instead of darthtools::gen_wcc(), which has the same bug in darthtools <= 0.4.0. - Fix swapped cost/QALY discount rates in calculate_ce_out() (no effect with equal 3% rates). - Scale Strategy A state costs by cycle_length in the analysis script (no effect with annual cycles). Base-case QALYs increase by ~0.32 per strategy; ICERs change by ~0.4%; the efficient frontier and dominance results are unchanged. Reported by Lauren N. Steimle and @ambtnhlr. Closes #2
- Remove a stray, unnamed copy of rate_to_prob() from R/Functions.R. - Use linewidth instead of size in geom_line() (ggplot2 >= 3.4.0). - Use after_stat(density) instead of ..density.. in the PSA histogram. - Add missing final newline to R/Functions.R.
- test-gen_wcc.R: exact Simpson weights for odd and even n, exact integration of polynomials of degree 0-3, half-cycle and none methods, input validation, and the examples from the bug reports. - test-base-case.R: regression test of base-case costs, QALYs, ICERs and dominance, and consistency between the analysis script and the PSA wrapper.
- DESCRIPTION: project version (0.3.0) and dependencies. - renv.lock: pinned package versions (R 4.5.3); restore with renv::restore(). - CITATION.cff: software and preferred article citation with all authors. - GitHub Actions: run the tests and the full analysis on Ubuntu and macOS.
- NEWS.md: changelog with before/after results of the WCC fix and acknowledgements; entries for previous releases. - README: correction notice, quick start with renv, repository structure, dependency notes, contributing guidelines, CI and license badges; fix typos and the Zenodo DOIs (the cited DOI was the v0.1.1 version DOI). - manuscript/README.md: document the erratum in the archival manuscript sources.
✅ Deploy Preview for testcohort ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ource CRAN only provides macOS binaries for the latest package versions; older versions pinned in renv.lock (e.g., data.table 1.18.2.1) are compiled from source and need libintl from gettext.
Credit both reporters in the gen_wcc() documentation, NEWS.md, a new README Acknowledgements section, and the manuscript erratum note.
The gettext install ran 'sudo Rscript' in the project root, so .Rprofile activated renv as root and left a root-owned lock that made renv::restore() hang until the 6-hour limit. Run it with --vanilla from the runner's temp directory, cap jobs at 60 minutes, and cancel superseded runs.
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.
Summary
gen_wcc(method = "Simpson1/3")assigned Simpson's 4/3 and 2/3 weights by position in the 1-based R vector instead of by time t = 0, …, n. It returned1/3, 2/3, 4/3, …, 1/3instead of1/3, 4/3, 2/3, …, 1/3, so the weights summed to n − 2/3 instead of n. This PR fixes the bug, makes the PSA use the same corrected function, and adds tests, CI and reproducibility infrastructure for release v0.3.0.Closes #2. Also reported independently by Lauren N. Steimle (Georgia Tech) by email.
Changes
Bug fixes
n_cycles.gen_wcc()instead ofdarthtools::gen_wcc(), which has the same bug in darthtools ≤ 0.4.0.calculate_ce_out(). No effect while both rates are 3%.cycle_length. No effect with annual cycles.Cleanup: remove a stray dead copy of
rate_to_prob(), and replace deprecated ggplot2 arguments.Infrastructure: testthat tests (11 tests, 112 expectations), a GitHub Actions workflow (tests plus the full analysis on Ubuntu and macOS),
renv.lock,DESCRIPTION(version 0.3.0) andCITATION.cff.Docs: add
NEWS.mdandmanuscript/README.md(erratum note; the manuscript sources are unchanged), and revise the README, including correcting the Zenodo DOIs.Impact on base-case results
The efficient frontier and the dominance of Strategy A are unchanged.
Verification
testthat::test_dir("tests/testthat"): 112 expectations, 0 failures.source("analysis/cSTM_time_indep.R")runs end to end underrenv, and the PSA wrapper reproduces the script's base case exactly.