K.7. WinBUGS code (Base case analysis)
#Random effects model for multi-arm trials (any number of arms)
model{
for (i in 1:NS)
{ Events[i] <- r[i,1]*equals(t[i,1],1)
Numpatients[i] <- n[i,1]*equals(t[i,1],1) }
totEvents<-sum(Events[])
totNumpatients<-sum(Numpatients[])
BR<- totEvents/totNumpatients
for(i in 1:NS){
w[i,1] <-0
delta[i,t[i,1]]<-0
mu[i] ~ dnorm(0,.0001) # vague priors for 24 trial baselines
for (k in 1:na[i]) {
r[i,k] ~ dbin(p[i,t[i,k]],n[i,k]) # binomial likelihood
logit(p[i,t[i,k]])<-mu[i] + delta[i,t[i,k]] # model
#Deviance residuals for data i
rhat[i,k] <- p[i,t[i,k]] * n[i,k]
dev[i,k] <- 2 * (r[i,k] * (log(r[i,k])-log(rhat[i,k])) + (n[i,k]-r[i,k]) * (log(n[i,k]-r[i,k]) - log(n[i,k]-
rhat[i,k])))
}
sdev[i]<- sum(dev[i,1:na[i]])
for (k in 2:na[i]) {
delta[i,t[i,k]] ~ dnorm(md[i,t[i,k]],taud[i,t[i,k]]) # trial-specific LOR distributions
md[i,t[i,k]] <- d[t[i,k]] - d[t[i,1]] + sw[i,k] # mean of LOR distributions
taud[i,t[i,k]] <- tau *2*(k-1)/k #precision of LOR distributions
w[i,k] <- (delta[i,t[i,k]] - d[t[i,k]] + d[t[i,1]]) #adjustment, multi-arm RCTs
sw[i,k] <-sum(w[i,1:k-1])/(k-1) } # cumulative adjustment for multi-arm trials
}
d[1]<-0
for (k in 2:NT){d[k] ~ dnorm(0,.0001) } # vague priors for basic parameters
sd~dunif(0,2) # vague prior for random effects standard deviation
tau<-1/pow(sd,2)
rr[1]<-1
for (k in 2:NT) {logit(v[k])<-logit(BR)+d[k]
rr[k]<-v[k]/BR } # calculate relative risk
sumdev <- sum(sdev[]) # Calculate residual deviance
# Ranking and prob{treatment k is best}
for (k in 1:NT) {
rk[k]<-NT+1-rank(rr[],k)
best[k]<-equals(NT+1-rank(rr[],k),1)}
# pairwise ORs and RRs
for (c in 1:(NT-1))
{ for (k in (c+1):NT)
{ lor[c,k] <- d[k] - d[c]
log(or[c,k]) <- lor[c,k]
lrr[c,k] <- log(rr[k]) - log(rr[c])
log(rrisk[c,k]) <- lrr[c,k]
}
}
}
# NT=no. treatments, NS=no. studies;
# NB : set up M vectors each r[,]. n[,] and t[,], where M is the Maximum number of treatments
# per trial in the dataset. In this dataset M is 5.
list(NS=34,NT=14)
r[,1] n[,1] r[,2] n[,2] r[,3] n[,3] r[,4] n[,4] r[,5] n[,5] t[,1] t[,2] t[,3] t[,4] t[,5] na[]
1 26 13 28 NA 1 NA 1 NA NA 2 3 NA NA NA 2
0 84 37 84 NA 1 NA 1 NA NA 2 3 NA NA NA 2
0 40 9 79 14 83 44 162 NA NA 2 3 5 10 NA 4
16 157 107 480 176 476 276 490 NA NA 2 3 5 10 NA 4
5 91 33 184 73 183 NA 1 NA NA 2 3 10 NA NA 3
7 45 18 50 NA 1 NA 1 NA NA 2 5 NA NA NA 2
5 33 144 189 NA 1 NA 1 NA NA 2 7 NA NA NA 2
7 229 24 439 NA 1 NA 1 NA NA 2 9 NA NA NA 2
2 214 26 421 NA 1 NA 1 NA NA 2 9 NA NA NA 2
9 29 21 29 NA 1 NA 1 NA NA 1 4 NA NA NA 2
13 32 24 32 NA 1 NA 1 NA NA 1 4 NA NA NA 2
23 123 87 124 NA 1 NA 1 NA NA 1 4 NA NA NA 2
11 62 46 62 NA 1 NA 1 NA NA 1 4 NA NA NA 2
8 107 103 308 174 312 NA 1 NA NA 1 4 6 NA NA 3
19 206 115 227 95 150 NA 1 NA NA 1 4 10 NA NA 3
4 37 15 39 NA 1 NA 1 NA NA 1 6 NA NA NA 2
1 83 12 78 NA 1 NA 1 NA NA 1 6 NA NA NA 2
0 29 84 162 NA 1 NA 1 NA NA 1 8 NA NA NA 2
27 125 85 120 NA 1 NA 1 NA NA 1 8 NA NA NA 2
1 20 10 61 NA 1 NA 1 NA NA 1 8 NA NA NA 2
2 60 47 60 NA 1 NA 1 NA NA 1 8 NA NA NA 2
49 172 69 172 73 172 NA 1 NA NA 3 4 11 NA NA 3
43 252 143 249 NA 1 NA 1 NA NA 3 10 NA NA NA 2
67 128 81 130 NA 1 NA 1 NA NA 4 6 NA NA NA 2
119 205 116 207 NA 1 NA 1 NA NA 4 6 NA NA NA 2
142 365 169 363 NA 1 NA 1 NA NA 4 6 NA NA NA 2
22 49 27 39 NA 1 NA 1 NA NA 4 11 NA NA NA 2
13 27 3 27 NA 1 NA 1 NA NA 4 12 NA NA NA 2
6 28 14 27 NA 1 NA 1 NA NA 4 13 NA NA NA 2
47 65 28 57 NA 1 NA 1 NA NA 4 13 NA NA NA 2
23 60 24 54 NA 1 NA 1 NA NA 4 14 NA NA NA 2
92 153 67 131 NA 1 NA 1 NA NA 4 14 NA NA NA 2
180 231 116 227 NA 1 NA 1 NA NA 4 14 NA NA NA 2
6 89 4 77 NA 1 NA 1 NA NA 4 14 NA NA NA 2
END
list(
d=c(NA,0,0,0,0,0,0,0,0,0,0,0,0,0),
sd=.2,
mu=c(-3,-1,3,-1,0,3,-2,-2,-1,-3,0,-1,2,3,3,2,3,3,1,3,-2,-2,3,-2,3,3,3,1,-1,1,1,-1,1,-1),
delta = structure(.Data =
c(NA,NA,3,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,1,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,N
A,NA,-3,NA,-3,NA,NA,NA,NA,-2,NA,NA,NA,NA,NA,NA,-
1,NA,2,NA,NA,NA,NA,0,NA,NA,NA,NA,NA,NA,1,NA,NA,NA,NA,NA,NA,-
2,NA,NA,NA,NA,NA,NA,NA,NA,1,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-
2,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,-
3,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,1,NA,NA,NA,NA,NA,NA,NA,NA,1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