# Load the dataset
data("data_model_output_sick_sicker.rda")
# Load list in global environment
list2env(data_model_output_sick_sicker, envir = .GlobalEnv)
# Explore the available objects
ls(pattern = "l_|v_")
# View names of health states
v_names_str
# Inspect the first few cycles of the annual Markov trace for the first strategy
head(l_m_M_annual[[1]])
# Compare dimensions of annual and monthly traces
dim(l_m_M_annual[[1]])
dim(l_m_M_monthly[[1]])
# Apply the half cycle correction
## Loop through each strategy and calculate total utilities and costs ----
v_tot_qaly <- v_tot_cost <- c()
for (i in 1:length(v_names_str)) {
v_u_str <- l_u_monthly[[i]] # select the vector of state utilities for the i-th strategy
v_c_str <- l_c_monthly[[i]] # select the vector of state costs for the i-th strategy
###* Expected QALYs and costs per cycle
##* Vector of QALYs and Costs
#* Apply state rewards
v_qaly_str <- l_m_M_monthly[[i]] %*% v_u_str # sum the utilities of all states for each cycle
v_cost_str <- l_m_M_monthly[[i]] %*% v_c_str # sum the costs of all states for each cycle
###* Total expected QALYs and costs per strategy and apply half-cycle correction (if applicable)
#* QALYs
v_tot_qaly[i] <- t(v_qaly_str) %*% v_wcc_monthly
#* Costs
v_tot_cost[i] <- t(v_cost_str) %*% v_wcc_monthly
}
Run the code above in your browser using DataLab