Hips4: Bayesian approaches to multiple sources of evidence and uncertainty in complex cost-effectiveness modelling
The last of the four hip-replacement examples puts the whole problem together. Hips1 evaluated one prosthesis in closed form, Hips2 replaced that with patient-level simulation, and Hips3 allowed the revision hazard to be uncertain. Here two prostheses are compared, Charnley and Stanmore, and the difference between them is estimated from external trial data rather than assumed. The evidence is M = 3 studies, each reporting revisions out of operations in both arms: 1683 of 28525, 7 of 200 and 33 of 208 on Charnley, against 28 of 865, 9 of 213 and 69 of 982 on Stanmore. The studies differ in design, so each carries a quality weight, 0.5, 1 and 0.2 respectively. The cost-effectiveness side keeps all the Hips1 inputs and adds a second column for Stanmore: a higher set-up cost, 4402 against 4052, and a higher revision cost, 5640 against 5290.
The evidence is synthesised on the complementary log-log scale, with a study-specific baseline and half the log hazard ratio placed either side of it, so that the counts in the two arms share a common contrast:
\[\begin{aligned} r^C_i &\sim \text{Binomial}(p^C_i, n^C_i), \qquad \text{cloglog}(p^C_i) = \text{base}_i - \tfrac{1}{2}\log\text{HR}_i \\ r^S_i &\sim \text{Binomial}(p^S_i, n^S_i), \qquad \text{cloglog}(p^S_i) = \text{base}_i + \tfrac{1}{2}\log\text{HR}_i \\ \log\text{HR}_i &\sim \text{Normal}(\text{LHR},\ w_i \tau_h) \end{aligned}\]
In the @bugs model the link is written the other way round, as pC[i] = cexpexp(...), using the inverse of the complementary log-log. The study log hazard ratios are random effects around a pooled LHR, and, because BUGS parameterises the normal by precision, multiplying the common precision tauh by the quality weight $w_i$ makes a low-quality study effectively noisier and so less influential. The between-study standard deviation sigmah is given a normal prior with mean 0.2 and precision 400, truncated to positive values, and HR = exp(LHR) is the pooled hazard ratio.
That hazard ratio feeds the Markov model. As in Hips3, the Charnley revision hazard in strata $k$ is h[1, k] = exp(logh[k]) with logh[k] normal about logh0[k] at precision tau = 25, and the Stanmore hazard is simply h[2, k] = HR * h[1, k]. The five-state model is then run once per prosthesis per strata, and the two runs are differenced to give incremental costs C.incr, incremental QALYs BQ.incr and an incremental cost-effectiveness ratio for each strata, plus population versions weighted by p.strata. Uncertainty from the trials, from the between-study variation and from the strata hazards all propagates into these quantities at once. The model also evaluates P.CEA, the posterior probability that Stanmore is cost-effective, at 100 willingness-to-pay values KK from 200 to 20000 pounds per QALY in steps of 200, which traces out a cost-effectiveness acceptability curve. The example is in Volume 3 of the classic BUGS examples; see also the OpenBUGS version of this example.
The model definition, data, initial values, and published reference results shown here all come from JuliaBUGS.BUGSExamples.VOLUME_3.hips4, which ships with the package.
Model
using JuliaBUGS
example = JuliaBUGS.BUGSExamples.VOLUME_3.hips4
example.model_defquote
for i = 1:M
rC[i] ~ dbin(pC[i], nC[i])
rS[i] ~ dbin(pS[i], nS[i])
pC[i] = cexpexp(base[i] - logHR[i] / 2)
pS[i] = cexpexp(base[i] + logHR[i] / 2)
base[i] ~ dunif(-100, 100)
logHR[i] ~ dnorm(LHR, tauHR[i])
tauHR[i] = qualweights[i] * tauh
end
LHR ~ dunif(-100, 100)
HR = exp(LHR)
tauh = 1 / (sigmah * sigmah)
sigmah ~ truncated(dnorm(0.2, 400), 0, nothing)
for k = 1:K
logh[k] ~ dnorm(logh0[k], tau)
h[1, k] = exp(logh[k])
h[2, k] = HR * h[1, k]
end
for k = 1:K
for n = 1:2
for t = 1:N
ct[n, k, t] = inprod(pi[n, k, t, :], c[n, :]) / pow(1 + var"delta.c", t - 1)
end
C[n, k] = C0[n] + sum(ct[n, k, :])
for t = 1:N
blt[n, k, t] = inprod(pi[n, k, t, :], bl[:]) / pow(1 + var"delta.b", t - 1)
end
BL[n, k] = sum(blt[n, k, :])
for t = 1:N
bqt[n, k, t] = inprod(pi[n, k, t, :], bq[:]) / pow(1 + var"delta.b", t - 1)
end
BQ[n, k] = sum(bqt[n, k, :])
for t = 2:N
Lambda[n, k, t, 1, 1] = (1 - gamma[n, k, t]) - lambda[k, t]
Lambda[n, k, t, 1, 2] = gamma[n, k, t] * var"lambda.op"
Lambda[n, k, t, 1, 3] = gamma[n, k, t] * (1 - var"lambda.op")
Lambda[n, k, t, 1, 4] = 0
Lambda[n, k, t, 1, 5] = lambda[k, t]
Lambda[n, k, t, 2, 1] = 0
Lambda[n, k, t, 2, 2] = 0
Lambda[n, k, t, 2, 3] = 0
Lambda[n, k, t, 2, 4] = 0
Lambda[n, k, t, 2, 5] = 1
Lambda[n, k, t, 3, 1] = 0
Lambda[n, k, t, 3, 2] = 0
Lambda[n, k, t, 3, 3] = 0
Lambda[n, k, t, 3, 4] = 1 - lambda[k, t]
Lambda[n, k, t, 3, 5] = lambda[k, t]
Lambda[n, k, t, 4, 1] = 0
Lambda[n, k, t, 4, 2] = rho * var"lambda.op"
Lambda[n, k, t, 4, 3] = rho * (1 - var"lambda.op")
Lambda[n, k, t, 4, 4] = (1 - rho) - lambda[k, t]
Lambda[n, k, t, 4, 5] = lambda[k, t]
Lambda[n, k, t, 5, 1] = 0
Lambda[n, k, t, 5, 2] = 0
Lambda[n, k, t, 5, 3] = 0
Lambda[n, k, t, 5, 4] = 0
Lambda[n, k, t, 5, 5] = 1
gamma[n, k, t] = h[n, k] * (t - 1)
end
pi[n, k, 1, 1] = 1 - var"lambda.op"
pi[n, k, 1, 2] = 0
pi[n, k, 1, 3] = 0
pi[n, k, 1, 4] = 0
pi[n, k, 1, 5] = var"lambda.op"
for t = 2:N
for s = 1:S
pi[n, k, t, s] = inprod(pi[n, k, t - 1, :], Lambda[n, k, t, :, s])
end
end
end
end
for k = 1:K
var"C.incr"[k] = C[2, k] - C[1, k]
var"BQ.incr"[k] = BQ[2, k] - BQ[1, k]
var"ICER.strata"[k] = var"C.incr"[k] / var"BQ.incr"[k]
end
for m = 1:100
for k = 1:12
var"P.CEA.strata"[m, k] = _step(KK[m] * var"BQ.incr"[k] - var"C.incr"[k])
end
var"P.CEA"[m] = _step(KK[m] * var"mean.BQ.incr" - var"mean.C.incr")
end
for n = 1:2
var"mean.C"[n] = inprod(var"p.strata"[:], C[n, :])
var"mean.BQ"[n] = inprod(var"p.strata"[:], BQ[n, :])
end
var"mean.C.incr" = var"mean.C"[2] - var"mean.C"[1]
var"mean.BQ.incr" = var"mean.BQ"[2] - var"mean.BQ"[1]
var"mean.ICER" = var"mean.C.incr" / var"mean.BQ.incr"
endThe program as it appears in the original BUGS distribution:
print(example.original_syntax_program)model {
# Evidence
#########
for (i in 1 : M){ # loop over studies
rC[i] ~ dbin(pC[i], nC[i]) # number of revisions on Charnley
rS[i] ~ dbin(pS[i], nS[i]) # number of revisions on Stanmore
cloglog(pC[i]) <- base[i] - logHR[i]/2
cloglog(pS[i]) <- base[i] + logHR[i]/2
base[i] ~ dunif(-100,100)
# log hazard ratio for ith study
logHR[i] ~ dnorm(LHR,tauHR[i])
tauHR[i] <- qualweights[i] * tauh # precision for ith study weighted by quality weights
}
LHR ~ dunif(-100,100)
log(HR) <- LHR
tauh <- 1 / (sigmah * sigmah)
sigmah ~ dnorm( 0.2, 400)T(0, ) # between-trial sd = 0.05 (prior constrained to be positive)
for(k in 1 : K) {
logh[k] ~ dnorm(logh0[k], tau)
h[1, k] <- exp(logh[k]) # revision hazard for Charnley
h[2, k] <- HR * h[1, k] # revision hazard for Stanmore
}# Cost-effectiveness model
######################
for(k in 1 : K) { # loop over strata
for(n in 1 : 2) { # loop over protheses
# Cost and benefit equations in closed form:
####################################
# Costs
for(t in 1 : N) {
ct[n, k, t] <- inprod(pi[n, k, t, ], c[n, ]) / pow(1 + delta.c, t - 1)
}
C[n,k] <- C0[n] + sum(ct[n, k, ])
# Benefits - life expectancy
for(t in 1 : N) {
blt[n, k, t] <- inprod(pi[n, k, t, ], bl[]) / pow(1 + delta.b, t - 1)
}
BL[n, k] <- sum(blt[n, k, ])
# Benefits - QALYs
for(t in 1 : N) {
bqt[n, k, t] <- inprod(pi[n, k, t, ], bq[]) / pow(1 + delta.b, t - 1)
}
BQ[n, k] <- sum(bqt[n, k, ])
# Markov model probabilities:
#######################
# Transition matrix
for(t in 2:N) {
Lambda[n, k, t, 1, 1] <- 1 - gamma[n, k, t] - lambda[k, t]
Lambda[n, k, t, 1, 2] <- gamma[n, k, t] * lambda.op
Lambda[n, k, t, 1, 3] <- gamma[n, k, t] *(1 - lambda.op)
Lambda[n, k, t, 1, 4] <- 0
Lambda[n, k, t, 1, 5] <- lambda[k, t]
Lambda[n, k, t, 2, 1] <- 0
Lambda[n, k, t, 2, 2] <- 0
Lambda[n, k, t, 2, 3] <- 0
Lambda[n, k, t, 2, 4] <- 0
Lambda[n, k ,t, 2, 5] <- 1
Lambda[n, k, t, 3, 1] <- 0
Lambda[n, k, t, 3, 2] <- 0
Lambda[n, k, t, 3, 3] <- 0
Lambda[n, k, t, 3, 4] <- 1 - lambda[k, t]
Lambda[n, k, t, 3, 5] <- lambda[k, t]
Lambda[n, k, t, 4, 1] <- 0
Lambda[n, k, t, 4, 2] <- rho * lambda.op
Lambda[n, k, t, 4, 3] <- rho * (1 - lambda.op)
Lambda[n, k, t, 4, 4] <- 1 - rho - lambda[k, t]
Lambda[n, k, t, 4, 5] <- lambda[k, t]
Lambda[n, k, t, 5, 1] <- 0
Lambda[n, k, t, 5, 2] <- 0
Lambda[n, k, t, 5, 3] <- 0
Lambda[n, k, t, 5, 4] <- 0
Lambda[n, k, t, 5, 5] <- 1
gamma[n, k, t] <- h[n, k] * (t - 1)
}
# Marginal probability of being in each state at time 1
pi[n, k, 1, 1] <- 1 - lambda.op pi[n, k, 1, 2] <- 0 pi[n, k, 1, 3] <- 0
pi[n, k, 1, 4] <- 0 pi[n, k, 1, 5] <- lambda.op
# Marginal probability of being in each state at time t>1
for(t in 2 : N) {
for(s in 1 : S) {
pi[n, k,t, s] <- inprod(pi[n, k, t - 1, ], Lambda[n, k, t, , s])
}
}
}
}
# Incremental costs and benefits
##########################
for(k in 1 : K) {
C.incr[k] <- C[2, k] - C[1, k]
BQ.incr[k] <-BQ[2, k] - BQ[1, k]
ICER.strata[k] <- C.incr[k] / BQ.incr[k]
}
# Probability of cost effectiveness @ KK pounds per QALY
# (values of KK considered range from 200 to 20000 in 200 pound increments)
for(m in 1 : 100) {
for(k in 1 : 12) {
P.CEA.strata[m,k] <- step(KK[m] * BQ.incr[k] - C.incr[k])
}
P.CEA[m] <- step(KK[m] * mean.BQ.incr - mean.C.incr)
}
# overall incremental costs and benefit
for(n in 1 : 2) {
mean.C[n] <- inprod(p.strata[], C[n, ])
mean.BQ[n] <- inprod(p.strata[], BQ[n, ])
}
mean.C.incr <- mean.C[2] - mean.C[1]
mean.BQ.incr <- mean.BQ[2] - mean.BQ[1]
mean.ICER <- mean.C.incr / mean.BQ.incr }Data
example.data(N = 60, K = 12, S = 5, M = 3, rho = 0.04, var"lambda.op" = 0.01, logh0 = [-6.119, -6.119, -6.119, -6.438, -6.438, -6.438, -6.377, -6.377, -6.377, -6.725, -6.725, -6.725], tau = 25, C0 = [4052, 4402], c = [0 5290 … 0 0; 0 5640 … 0 0], bl = [1, 0, 1, 1, 0], bq = [0.938, -0.622, -0.3387, 0.938, 0.0], var"delta.c" = 0.06, var"delta.b" = 0.06, var"p.strata" = [0.02, 0.03, 0.07, 0.13, 0.1, 0.0, 0.02, 0.04, 0.1, 0.22, 0.26, 0.01], lambda = [0.0017 0.0017 … 0.1958 0.1958; 0.0044 0.0044 … 0.1958 0.1958; … ; 0.0578 0.0578 … 0.1503 0.1503; 0.1503 0.1503 … 0.1503 0.1503], KK = [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000 … 18200, 18400, 18600, 18800, 19000, 19200, 19400, 19600, 19800, 20000], rC = [1683, 7, 33], nC = [28525, 200, 208], rS = [28, 9, 69], nS = [865, 213, 982], qualweights = [0.5, 1.0, 0.2])Compiling the model
model = JuliaBUGS.compile(example.model_def, example.data, example.inits)BUGSModel (parameters are in transformed (unconstrained) space, with dimension 8):
Model parameters:
logh[12], logh[11], logh[10], logh[9], logh[8], logh[7], logh[6], logh[5], logh[4], logh[3], logh[2], logh[1]
LHR
logHR[3], logHR[2], logHR[1]
sigmah
base[3], base[2], base[1]
Variable sizes and types:
bl: size = (5,), type = Vector{Int64}
lambda: size = (12, 60), type = Matrix{Float64}
S: type = Int64
BL: size = (2, 12), type = Matrix{Float64}
logh: size = (12,), type = Vector{Float64}
blt: size = (2, 12, 60), type = Array{Float64, 3}
delta.c: type = Float64
tau: type = Int64
mean.BQ.incr: type = Float64
mean.BQ: size = (2,), type = Vector{Float64}
Lambda: size = (2, 12, 60, 5, 5), type = Array{Float64, 5}
LHR: type = Float64
mean.ICER: type = Float64
c: size = (2, 5), type = Matrix{Int64}
pi: size = (2, 12, 60, 5), type = Array{Float64, 4}
rC: size = (3,), type = Vector{Int64}
C.incr: size = (12,), type = Vector{Float64}
N: type = Int64
M: type = Int64
p.strata: size = (12,), type = Vector{Float64}
delta.b: type = Float64
pS: size = (3,), type = Vector{Float64}
bqt: size = (2, 12, 60), type = Array{Float64, 3}
qualweights: size = (3,), type = Vector{Float64}
bq: size = (5,), type = Vector{Float64}
rS: size = (3,), type = Vector{Int64}
mean.C: size = (2,), type = Vector{Float64}
mean.C.incr: type = Float64
tauh: type = Float64
C: size = (2, 12), type = Matrix{Float64}
ct: size = (2, 12, 60), type = Array{Float64, 3}
pC: size = (3,), type = Vector{Float64}
P.CEA.strata: size = (100, 12), type = Matrix{Float64}
BQ: size = (2, 12), type = Matrix{Float64}
BQ.incr: size = (12,), type = Vector{Float64}
nS: size = (3,), type = Vector{Int64}
sigmah: type = Float64
gamma: size = (2, 12, 60), type = Array{Float64, 3}
rho: type = Float64
h: size = (2, 12), type = Matrix{Float64}
tauHR: size = (3,), type = Vector{Float64}
nC: size = (3,), type = Vector{Int64}
P.CEA: size = (100,), type = Vector{Float64}
ICER.strata: size = (12,), type = Vector{Float64}
logHR: size = (3,), type = Vector{Float64}
K: type = Int64
KK: size = (100,), type = Vector{Int64}
C0: size = (2,), type = Vector{Int64}
logh0: size = (12,), type = Vector{Float64}
lambda.op: type = Float64
HR: type = Float64
base: size = (3,), type = Vector{Float64}
The example's own initial values are passed in here. Several of these models fail from random starting values, so example.inits is not optional in practice; a second set is available as example.inits_alternative.
See Getting Started for the recipe that takes a compiled model to posterior samples.
Reference results
The posterior summaries published with the original example. A converged chain should reproduce these up to Monte Carlo error.
example.reference_results(var"BQ.incr[1]" = (mean = 0.1392, std = 0.0619), var"BQ.incr[2]" = (mean = 0.1154, std = 0.05106), var"BQ.incr[3]" = (mean = 0.08319, std = 0.03693), var"BQ.incr[4]" = (mean = 0.03889, std = 0.01744), var"BQ.incr[5]" = (mean = 0.02016, std = 0.009124), var"BQ.incr[6]" = (mean = 0.01352, std = 0.006099), var"BQ.incr[7]" = (mean = 0.1302, std = 0.0577), var"BQ.incr[8]" = (mean = 0.1118, std = 0.04939), var"BQ.incr[9]" = (mean = 0.08488, std = 0.03763), var"BQ.incr[10]" = (mean = 0.04113, std = 0.01848), var"BQ.incr[11]" = (mean = 0.02194, std = 0.009888), var"BQ.incr[12]" = (mean = 0.01536, std = 0.006892), var"C.incr[1]" = (mean = -105.0, std = 251.0), var"C.incr[2]" = (mean = -38.62, std = 209.2), var"C.incr[3]" = (mean = 62.14, std = 152.7), var"C.incr[4]" = (mean = 211.7, std = 72.68), var"C.incr[5]" = (mean = 277.4, std = 38.26), var"C.incr[6]" = (mean = 301.3, std = 25.61), var"C.incr[7]" = (mean = -75.88, std = 232.5), var"C.incr[8]" = (mean = -25.19, std = 201.1), var"C.incr[9]" = (mean = 57.93, std = 154.8), var"C.incr[10]" = (mean = 204.6, std = 76.55), var"C.incr[11]" = (mean = 271.5, std = 41.24), var"C.incr[12]" = (mean = 295.0, std = 28.76), HR = (mean = 0.6054, std = 0.1584), var"ICER.strata[1]" = (mean = -9624.0, std = 1.346e6), var"ICER.strata[2]" = (mean = -9435.0, std = 1.399e6), var"ICER.strata[3]" = (mean = -10320.0, std = 1.703e6), var"ICER.strata[4]" = (mean = -16720.0, std = 3.395e6), var"ICER.strata[5]" = (mean = -41420.0, std = 8.35e6), var"ICER.strata[6]" = (mean = -18120.0, std = 6.573e6), var"ICER.strata[7]" = (mean = -9118.0, std = 1.306e6), var"ICER.strata[8]" = (mean = -9113.0, std = 1.36e6), var"ICER.strata[9]" = (mean = -10120.0, std = 1.655e6), var"ICER.strata[10]" = (mean = -11560.0, std = 2.555e6), var"ICER.strata[11]" = (mean = -19530.0, std = 5.045e6), var"ICER.strata[12]" = (mean = -12830.0, std = 5.1e6), var"P.CEA[30]" = (mean = 0.7457, std = 0.4354), var"P.CEA[50]" = (mean = 0.8662, std = 0.3404), var"P.CEA.strata[30,1]" = (mean = 0.9293, std = 0.2562), var"P.CEA.strata[30,2]" = (mean = 0.9197, std = 0.2717), var"P.CEA.strata[30,3]" = (mean = 0.8854, std = 0.3185), var"P.CEA.strata[30,4]" = (mean = 0.571, std = 0.4949), var"P.CEA.strata[30,5]" = (mean = 0.0392, std = 0.1941), var"P.CEA.strata[30,6]" = (mean = 0.00045, std = 0.02121), var"P.CEA.strata[30,7]" = (mean = 0.9258, std = 0.2621), var"P.CEA.strata[30,8]" = (mean = 0.9173, std = 0.2754), var"P.CEA.strata[30,9]" = (mean = 0.8892, std = 0.3139), var"P.CEA.strata[30,10]" = (mean = 0.6146, std = 0.4867), var"P.CEA.strata[30,11]" = (mean = 0.0718, std = 0.2582), var"P.CEA.strata[30,12]" = (mean = 0.0018, std = 0.04239), var"P.CEA.strata[50,1]" = (mean = 0.9491, std = 0.2198), var"P.CEA.strata[50,2]" = (mean = 0.944, std = 0.2298), var"P.CEA.strata[50,3]" = (mean = 0.9276, std = 0.2591), var"P.CEA.strata[50,4]" = (mean = 0.7882, std = 0.4086), var"P.CEA.strata[50,5]" = (mean = 0.2678, std = 0.4428), var"P.CEA.strata[50,6]" = (mean = 0.02395, std = 0.1529), var"P.CEA.strata[50,7]" = (mean = 0.9473, std = 0.2233), var"P.CEA.strata[50,8]" = (mean = 0.9429, std = 0.2319), var"P.CEA.strata[50,9]" = (mean = 0.929, std = 0.2567), var"P.CEA.strata[50,10]" = (mean = 0.8093, std = 0.3929), var"P.CEA.strata[50,11]" = (mean = 0.35, std = 0.477), var"P.CEA.strata[50,12]" = (mean = 0.06165, std = 0.2405))