@@ -62,7 +62,7 @@ source("R/Functions.R")
6262# # General setup
6363n_age_init <- 25 # age at baseline
6464n_age_max <- 100 # maximum age of follow up
65- n_t <- n_age_max - n_age_init # time horizon, number of cycles
65+ n_cycles <- n_age_max - n_age_init # time horizon, number of cycles
6666v_names_states <- c(" H" , " S1" , " S2" , " D" ) # the 4 health states of the model:
6767 # Healthy (H), Sick (S1), Sicker (S2), Dead (D)
6868n_states <- length(v_names_states ) # number of health states
@@ -73,7 +73,7 @@ d_e <- 0.03 # discount rate for QALYs
7373v_names_str <- c(" SoC" , " A" , " B" , " AB" ) # store the strategy names
7474n_str <- length(v_names_str ) # number of strategies
7575# Within-cycle correction (WCC) using Simpson's 1/3 rule
76- v_wcc <- darthtools :: gen_wcc(n_t = n_t , method = " Simpson1/3" ) # vector of wcc
76+ v_wcc <- darthtools :: gen_wcc(n_t = n_cycles , method = " Simpson1/3" ) # vector of wcc
7777
7878
7979# # Transition probabilities (per cycle), hazard ratios and odds ratio
@@ -107,8 +107,8 @@ ic_HS1 <- 1000 # increase in cost when transitioning from Healthy to Sick
107107ic_D <- 2000 # increase in cost when dying
108108
109109# Discount weight (equal discounting is assumed for costs and effects)
110- v_dwc <- 1 / ((1 + d_e ) ^ (0 : n_t ))
111- v_dwe <- 1 / ((1 + d_c ) ^ (0 : n_t ))
110+ v_dwc <- 1 / ((1 + d_e ) ^ (0 : n_cycles ))
111+ v_dwe <- 1 / ((1 + d_c ) ^ (0 : n_cycles ))
112112
113113# ## Process model inputs
114114# # Age-specific transition probabilities to the Dead state
@@ -136,8 +136,8 @@ v_s_init
136136
137137# # Initialize cohort trace for cSTM for strategies SoC and A
138138m_M <- matrix (0 ,
139- nrow = (n_t + 1 ), ncol = n_states ,
140- dimnames = list (0 : n_t , v_names_states ))
139+ nrow = (n_cycles + 1 ), ncol = n_states ,
140+ dimnames = list (0 : n_cycles , v_names_states ))
141141# Store the initial state vector in the first row of the cohort trace
142142m_M [1 , ] <- v_s_init
143143# # Initialize cohort trace for strategies B and AB
@@ -177,22 +177,22 @@ m_P_strB["S1", "S2"] <- (1 - p_S1D) * p_S1S2_trtB
177177check_transition_probability(m_P , verbose = TRUE )
178178check_transition_probability(m_P_strB , verbose = TRUE )
179179# # Check that all rows sum to 1
180- check_sum_of_transition_array(m_P , n_states = n_states , n_t = n_t , verbose = TRUE )
181- check_sum_of_transition_array(m_P_strB , n_states = n_states , n_t = n_t , verbose = TRUE )
180+ check_sum_of_transition_array(m_P , n_states = n_states , n_t = n_cycles , verbose = TRUE )
181+ check_sum_of_transition_array(m_P_strB , n_states = n_states , n_t = n_cycles , verbose = TRUE )
182182
183183# # Initialize transition array which will capture transitions from each state to another over time
184184# for strategies SoC and A
185185a_A <- array (0 ,
186- dim = c(n_states , n_states , n_t + 1 ),
187- dimnames = list (v_names_states , v_names_states , 0 : n_t ))
186+ dim = c(n_states , n_states , n_cycles + 1 ),
187+ dimnames = list (v_names_states , v_names_states , 0 : n_cycles ))
188188# Set first slice of A with the initial state vector in its diagonal
189189diag(a_A [, , 1 ]) <- v_s_init
190190# For strategies B and AB, the array structure and initial state are identical
191191a_A_strB <- a_A
192192
193193# ### Run Markov model ####
194194# Iterative solution of time-independent cSTM
195- for (t in 1 : n_t ){
195+ for (t in 1 : n_cycles ){
196196 # # Fill in cohort trace
197197 # For strategies SoC and A
198198 m_M [t + 1 , ] <- m_M [t , ] %*% m_P
@@ -294,12 +294,12 @@ for (i in 1:n_str) {
294294 m_c_str <- matrix (v_c_str , nrow = n_states , ncol = n_states , byrow = T )
295295 # Expand the transition matrix of state utilities across cycles to form a transition array of state utilities
296296 a_R_u_str <- array (m_u_str ,
297- dim = c(n_states , n_states , n_t + 1 ),
298- dimnames = list (v_names_states , v_names_states , 0 : n_t ))
297+ dim = c(n_states , n_states , n_cycles + 1 ),
298+ dimnames = list (v_names_states , v_names_states , 0 : n_cycles ))
299299 # Expand the transition matrix of state costs across cycles to form a transition array of state costs
300300 a_R_c_str <- array (m_c_str ,
301- dim = c(n_states , n_states , n_t + 1 ),
302- dimnames = list (v_names_states , v_names_states , 0 : n_t ))
301+ dim = c(n_states , n_states , n_cycles + 1 ),
302+ dimnames = list (v_names_states , v_names_states , 0 : n_cycles ))
303303
304304 # ### Apply transition rewards ####
305305 # Apply disutility due to transition from H to S1
0 commit comments