**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
**data re-arrangement in a format suitable for polytomous (multinomial) logistic regression
sort study group gen
gen patt=_n
expand 3
sort patt
qui by patt: gen alt=_n
gen chosen=alt==gen
tab alt,gen(a)
gen a2group=a2*group
gen a3group=a3*group
**fitting the model based on the retrospective likelihood – Equation 4.4
eq slope2:a2group
eq slope3:a3group
gllamm alt group _Istudy_* , expand(patt chosen m) i(study) link(mlogit) family(binom) nrf(2) eqs(slope2 slope3) nip(8) weight(wt) adapt
**automatic calculation of confidence intervals for d
lincom [c3]group - [c2]group
**automatic calculation of confidence intervals for lambda
nlcom [c2]group/[c3]group
**alternative parameterization of the retrospective likelihood model
xi i.study i.study*a2 i.study*a3
gllamm alt a2 a3 _IstuXa* a2group a3group, nocons expand(patt chosen o) i(study)
link(mlogit) family(binom) nrf(2) eqs(slope2 slope3 ) nip(8) weight(wt) adapt
**automatic calculation of confidence intervals for lambda
nlcom _b[a2group]/_b[a3group]
**automatic calculation of confidence intervals for d
lincom _b[a3group] -_b[a2group]