#####################
# Markov model: PSA #
#####################
## model set-up ----
t_names <- c("without_drug", "with_drug")
n_treatments <- length(t_names)
s_names <- c("Asymptomatic_disease", "Progressive_disease", "Dead")
n_states <- length(s_names)
n_pop <- 1000
n_cycles <- 46
Initial_age <- 55
# replace point values with functions to random sample
cAsymp <- function() rnorm(1, 500, 127.55)
cDeath <- function() rnorm(1, 1000, 255.11)
cDrug <- function() rnorm(1, 1000, 102.04)
cProg <- function() rnorm(1, 3000, 510.21)
effect <- function() rnorm(1, 0.5, 0.051)
tpDcm <- function() rbeta(1, 29, 167)
tpProg <- function() rbeta(1, 15, 1506)
uAsymp <- function() rbeta(1, 69, 4)
uProg <- function() rbeta(1, 24, 8)
# discount rates
oDr <- 0.06
cDr <- 0.06
# Define cost and QALYs as functions
state_c_matrix <- function() {
matrix(c(cAsymp(), cProg(), 0, # without drug
cAsymp() + cDrug(), cProg(), 0), # with drug
byrow = TRUE,
nrow = n_treatments,
dimnames = list(t_names,
s_names))
}
state_q_matrix <- function() {
matrix(c(uAsymp(), uProg(), 0, # without drug
uAsymp(), uProg(), 0), # with drug
byrow = TRUE,
nrow = n_treatments,
dimnames = list(t_names,
s_names))
}
trans_c_matrix <- function() {
matrix(c(0, 0, 0, # Asymptomatic_disease
0, 0, cDeath(), # Progressive_disease
0, 0, 0), # Dead
byrow = TRUE,
nrow = n_states,
dimnames = list(from = s_names,
to = s_names))
}
# transition probabilities
p_matrix <- array(data = 0,
dim = c(n_states, n_states, n_treatments),
dimnames = list(from = s_names,
to = s_names,
t_names))
## Run PSA analysis ----
n_trials <- 500
costs <- matrix(NA, nrow = n_trials, ncol = n_treatments,
dimnames = list(NULL, t_names))
qalys <- matrix(NA, nrow = n_trials, ncol = n_treatments,
dimnames = list(NULL, t_names))
for (i in 1:n_trials) {
ce_res <- ce_markov(start_pop = c(n_pop, 0, 0),
p_matrix,
state_c_matrix(),
trans_c_matrix(),
state_q_matrix())
costs[i, ] <- ce_res$total_costs
qalys[i, ] <- ce_res$total_QALYs
}
## Plot results ----
# incremental costs and QALYs of with_drug vs to without_drug
c_incr_psa <- costs[, "with_drug"] - costs[, "without_drug"]
q_incr_psa <- qalys[, "with_drug"] - qalys[, "without_drug"]
plot(x = q_incr_psa/n_pop, y = c_incr_psa/n_pop,
xlim = c(0, 2),
ylim = c(0, 15e3),
pch = 16, cex = 1.2,
col = "grey",
xlab = "QALY difference",
ylab = "Cost difference (£)",
frame.plot = FALSE)
abline(a = 0, b = 30000, lwd = 2) # Willingness-to-pay threshold £30,000/QALY
points(x = mean(q_incr_psa)/n_pop,
y = mean(c_incr_psa)/n_pop,
col = "red",
pch = 16, cex = 1.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.