**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
**data re-arrangement in a format suitable for logistic regression
reshape long aa ab bb, i(study) j(group)
gen id = _n
rename aa count1
rename ab count2rename bb count3
reshape long count, i(id) j(gen)
drop id
gen wt1=count
xi i.study i.gen
**fitting the model based on the prospective likelihood – Equation 4.1
eq slope2: _Igen_2
eq slope3: _Igen_3
gllamm group _Igen_2 _Igen_3 _Istudy_*,fam(binom) link(logit) i(study ) nrf(2) eqs(slope2 slope3) w(wt) adapt nip(8)
**automatic calculation of confidence intervals for lambda
nlcom _b[_Igen_2]/_b[_Igen_3]
**automatic calculation of confidence intervals for d
lincom _b[_Igen_2] - _b[_Igen_3]