Skip to content

Commit 40fbb2d

Browse files
committed
Update code with WCC using Simpson's 1/3rd rule
1 parent 17e3577 commit 40fbb2d

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

Cohort-modeling-tutorial.Rproj

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
Version: 1.0
2-
3-
RestoreWorkspace: Default
4-
SaveWorkspace: Default
5-
AlwaysSaveHistory: Default
6-
7-
EnableCodeIndexing: Yes
8-
UseSpacesForTab: Yes
9-
NumSpacesForTab: 2
10-
Encoding: UTF-8
11-
12-
RnwWeave: knitr
13-
LaTeX: pdfLaTeX
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: knitr
13+
LaTeX: pdfLaTeX

analysis/STM_01.R

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,16 @@ n_age_max <- 100 # maximum age of follow up
6464
n_t <- n_age_max - n_age_init # time horizon, number of cycles
6565
v_names_states <- c("H", "S1", "S2", "D") # the 4 health states of the model:
6666
# Healthy (H), Sick (S1), Sicker (S2), Dead (D)
67-
v_hcc <- rep(1, n_t + 1) # vector of half-cycle correction
68-
v_hcc[1] <- v_hcc[n_t + 1] <- 0.5 # half-cycle correction weight
6967
n_states <- length(v_names_states) # number of health states
68+
# Discounting factors
7069
d_c <- 0.03 # discount rate for costs
7170
d_e <- 0.03 # discount rate for QALYs
71+
# Strategies
7272
v_names_str <- c("SoC", "A", "B", "AB") # store the strategy names
7373
n_str <- length(v_names_str) # number of strategies
74+
# Within-cycle correction (WCC) using Simpson's 1/3 rule
75+
v_wcc <- darthtools::gen_wcc(n_t = n_t, method = "Simpson1/3") # vector of wcc
76+
7477

7578
## Transition probabilities (per cycle), hazard ratios and odds ratio
7679
r_HD <- 0.002 # constant rate of dying when Healthy (all-cause mortality)
@@ -318,9 +321,9 @@ for (i in 1:n_str) {
318321

319322
#### Discounted total expected QALYs and Costs per strategy and apply half-cycle correction if applicable ####
320323
## QALYs
321-
v_tot_qaly[i] <- t(v_qaly_str) %*% (v_dwe * v_hcc)
324+
v_tot_qaly[i] <- t(v_qaly_str) %*% (v_dwe * v_wcc)
322325
## Costs
323-
v_tot_cost[i] <- t(v_cost_str) %*% (v_dwc * v_hcc)
326+
v_tot_cost[i] <- t(v_cost_str) %*% (v_dwc * v_wcc)
324327
}
325328

326329
########################## Cost-effectiveness analysis #######################

0 commit comments

Comments
 (0)