This vignette shows how to transform the deterministic Markov model presented in vignette("homogeneous", "heemod")
in a probabilistic model.
We will start by re-specifying the deterministic models of HIV therapy described previously (a model for monotherapy mono
and a model for combined therapy comb
).
But instead of defining transition probabilities and state values directly in define_matrix()
or define_state()
(as in the previous vignette), parameters will be defined first in a define_parameters()
step. This is because only parameters defined this way can be resampled in a probabilistic analysis.
We have to define common parameters in both models because during probabilistic analysis resampled parameters are replaced for both models. So we cannot have p_AB = 0.202
in model mono
and p_AB = 0.202 * rr
in model comb
, because if we resample the base transition rate to a new value p_AB'
we will have p_AB = p_AB'
in both models, instead of what we expected (we expected p_AB = p_AB' * rr
in model comb
in case you were wondering).
To avoid that problem we use p_XX_base
parameters that are the ones that will be resampled.
param_mono <- define_parameters(
rr = .509,
p_AB_base = .202,
p_AC_base = .067,
p_AD_base = .010,
p_BC_base = .407,
p_BD_base = .012,
p_CD_base = .250,
p_AB = p_AB_base,
p_AC = p_AC_base,
p_AD = p_AD_base,
p_BC = p_BC_base,
p_BD = p_BD_base,
p_CD = p_CD_base,
p_AA = 1 - (p_AB + p_AC + p_AD),
cost_zido = 2278,
cost_lami = 2086,
cost_A = 2756,
cost_B = 3052,
cost_C = 9007
)
We can then define transition probabilities in the comb
model according to base transition probabilities.
param_comb <- modify(
param_mono,
p_AB = p_AB_base * rr,
p_AC = p_AC_base * rr,
p_AD = p_AD_base * rr,
p_BC = p_BC_base * rr,
p_BD = p_BD_base * rr,
p_CD = p_CD_base * rr
)
We cannot use the complement alias C
to specify p_AA
because we will need to resample that value. Only parameters defined with define_parameters()
can be resampled.
mat_trans <- define_matrix(
p_AA, p_AB, p_AC, p_AD,
.000, C, p_BC, p_BD,
.000, .000, C, p_CD,
.000, .000, .000, 1.00
)
State definition remains the same. in this example.
A_mono <- define_state(
cost_health = cost_A,
cost_drugs = cost_zido,
cost_total = discount(cost_health + cost_drugs, .06),
life_year = 1
)
B_mono <- define_state(
cost_health = cost_B,
cost_drugs = cost_zido,
cost_total = discount(cost_health + cost_drugs, .06),
life_year = 1
)
C_mono <- define_state(
cost_health = cost_C,
cost_drugs = cost_zido,
cost_total = discount(cost_health + cost_drugs, .06),
life_year = 1
)
D_mono <- define_state(
cost_health = 0,
cost_drugs = 0,
cost_total = discount(cost_health + cost_drugs, .06),
life_year = 0
)
A_comb <- define_state(
cost_health = cost_A,
cost_drugs = cost_zido + cost_lami,
cost_total = discount(cost_health + cost_drugs, .06),
life_year = 1
)
B_comb <- define_state(
cost_health = cost_B,
cost_drugs = cost_zido + cost_lami,
cost_total = discount(cost_health + cost_drugs, .06),
life_year = 1
)
C_comb <- define_state(
cost_health = cost_C,
cost_drugs = cost_zido + cost_lami,
cost_total = discount(cost_health + cost_drugs, .06),
life_year = 1
)
D_comb <- define_state(
cost_health = 0,
cost_drugs = 0,
cost_total = discount(cost_health + cost_drugs, .06),
life_year = 0
)
Models must be first defined and run as in a standard deterministic analysis.
mod_mono <- define_model(
parameters = param_mono,
transition_matrix = mat_trans,
A_mono,
B_mono,
C_mono,
D_mono
)
## No named state -> generating names.
mod_comb <- define_model(
parameters = param_comb,
transition_matrix = mat_trans,
A_comb,
B_comb,
C_comb,
D_comb
)
## No named state -> generating names.
res_mod <- run_models(
mono = mod_mono,
comb = mod_comb,
cycles = 20,
cost = cost_total,
effect = life_year
)
Now we can define the resampling distributions. The following parameters will be resampled:
Since the log of a relative risk follows a lognormal distribution, relative risk follows a lognormal distribution whose mean is rr
and standard deviantion on the log scale can be deduced from the relative risk confidence interval.
rr ~ lognormal(mean = .509, sdlog = .173)
Usually costs are resampled on a gamma distribution, who has the property of being always positive. Shape and scale parameters of the gamma distribution can be calculated from the mean and standard deviation desired in the distribution. Here we assume that mean = variance.
cost_A ~ make_gamma(mean = 2756, sd = sqrt(2756))
Proportions follow a binomial distribution that can be estimated by giving the mean proportion and the size of the sample used to estimate that proportion.
p_CD ~ prop(prob = .25, size = 40)
Finally multinomial distributions are declared with the number of individuals in each group in the sample used to estimate the proportions. These proportions follow a Dirichlet distribution.
p_AA + p_AB + p_AC + p_AD ~ multinom(721, 202, 67, 10)
rsp <- define_resample(
rr ~ lognormal(mean = .509, sdlog = .173),
cost_A ~ make_gamma(mean = 2756, sd = sqrt(2756)),
cost_B ~ make_gamma(mean = 3052, sd = sqrt(3052)),
cost_C ~ make_gamma(mean = 9007, sd = sqrt(9007)),
p_CD ~ prop(prob = .25, size = 40),
p_AA + p_AB + p_AC + p_AD ~ multinom(721, 202, 67, 10)
)
Now that the distributions of parameters are set we can simply run the probabilistic model as follow:
pm <- run_probabilistic(
model = res_mod,
resample = rsp,
N = 1e2
)
## Running model 'mono'...
## Running model 'comb'...
The results of the analysis can be plotted on the cost-effectiveness plane:
plot(pm, type = "ce")
And as cost-effectiveness acceptability curves:
plot(pm, type = "ac", values = seq(0, 25e3, 1e3))