Repository navigation
Fix gen_wcc() Simpson's 1/3 weights; add unit tests and R CMD check CI (v0.4.1) - #16
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. - Weights are now assigned by time. - For an odd number of cycles, apply the composite Simpson's 1/3 rule over the first n - 3 cycles and Simpson's 3/8 rule over the last three, so polynomials up to degree three are integrated exactly. - Validate that n_cycles is a single positive integer (and >= 2 for Simpson). Reported independently by Lauren N. Steimle and by GitHub user ambtnhlr (DARTH-git/cohort-modeling-tutorial-intro#2). Documentation regenerated with roxygen2 8.0.0.
Tests check the exact weight vectors, exact integration of polynomials up to degree three for even and odd n, the reported examples, the half-cycle and none methods, and input validation.
- surv_prob(): drop require("MASS"); MASS (already used via MASS::mvrnorm) is now in Imports.
- Import coef() and vcov() from stats.
- Document surv_prob(B) and plot_trace_microsim(v_n_states).
Checks on macOS, Windows and Ubuntu (R release) and Ubuntu (R oldrel-1) using r-lib/actions.
This was referenced Nov 10, 2026
Release v0.3.1: point to darthtools 0.4.1 fix, add ORCIDs
DARTH-git/cohort-modeling-tutorial-intro#4
Merged
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 the 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 (even n) or n − 1/3 (odd n) instead of n. This PR fixes it and releases darthtools 0.4.1.The bug was reported independently by Lauren N. Steimle (Georgia Institute of Technology) and by GitHub user ambtnhlr (DARTH-git/cohort-modeling-tutorial-intro#2). It was fixed in the intro tutorial in v0.3.0; this PR applies the same fix here.
Changes
n_cyclesmust be a single positive integer (and ≥ 2 for Simpson's rule). Previously,n_cycles = 7.5was silently truncated.R-CMD-checkworkflow on macOS, Windows and Ubuntu (R release) and Ubuntu (R oldrel-1).surv_prob()no longer callsrequire("MASS")(MASS is now in Imports),coef/vcovare imported from stats, and thesurv_prob(B)andplot_trace_microsim(v_n_states)arguments are documented.Impact for users
Results computed with
gen_wcc(method = "Simpson1/3")will change slightly. In the intro tutorial's base case, QALYs rise about 0.32 per strategy and ICERs move about 0.4%, with no change in dominance or conclusions.Checks
devtools::test(): 106 passing, 0 failing.devtools::check()locally (macOS, R 4.5.3): 0 errors, 0 warnings, 1 note ("unable to verify current time", which comes from the local machine).