**Stata code for fitting the various models described in the manuscript
**The commands can be run interactively or in batch mode (i.e. in a do-file)
**The mvmeta and gllamm packages are required in order to run the code
**Fixed effects models are not considered here, for simplicity
**Data input for the discrete outcome meta-analysis
**Data are taken from the study of Kato et al, 1999
**Data are listed in the form of Table 1 of the manuscript
clear
set more off
input study aa0 ab0 bb0 aa1 ab1 bb1
1 3 34 44 2 20 83
2 4 30 49 3 17 62
3 17 84 48 3 30 31
4 5 32 63 5 23 52
5 12 62 119 8 39 133
6 9 48 47 6 34 68
7 18 134 363 20 214 483
end
** calculation of the log(Odds Ratios)
gen b1=log(( ab1/ aa1)/( ab0/aa0))
gen b2=log(( bb1/ aa1)/( bb0/aa0))
** calculation of the variances
gen V11=1/aa0 +1/ab0+1/aa1 +1/ab1
gen V22=1/aa0 +1/aa1+1/bb0 +1/bb1
** calculation of the covariance
gen V12=1/aa0 +1/aa1
** fitting the model of Equation 3.7 using REML
mvmeta b V,vars(b1 b2)
** retrieve the covariance matrix
matrix v=e(V)
**calculation of lambda
di _b[b1]/_b[b2]
**calculation of standard error of lambda – Equation 5.6
di sqrt( v[1,1]/_b[b2]^2 + v[2,2]*_b[b1]^2/_b[b2]^4 -2*v[1,2]*_b[b1]/_b[b2]^3 )
**automatic calculation of confidence intervals for lambda
nlcom _b[b1]/_b[b2]
**calculation of d
di _b[b2] - _b[b1]
**calculation of standard error of d – Equation 5.2
di sqrt( v[1,1] + v[2,2] - 2*v[1,2] )
**automatic calculation of confidence intervals for d
lincom _b[b2] - _b[b1]