*! version 3.1 13jul2015

Demonstration for the mvmeta package in Stata: getting the data into mvmeta format
Ian White

How to run this tutorial

You will need to install the mvmeta package as described in the main demonstration.

mvmeta expects the data to be organised with one line per study,
with each line containing the estimates and their variances for that study.
The estimates must be named as a common stub followed by a unique ending,
and the variances must be named as a (different) common stub followed by a repeated ending.
Ideally, covariances are also included, named as the variance stub followed by two endings.

Let's make that more concrete by inputting the p53 data.
These data are described in
the main demonstration.
The data are the estimated log hazard ratios (lnHR)
for mutant vs. normal p53 gene for two outcomes.

The data for overall survival look like this:

study estimate std.error
1 -.18 .56
2 .79 .24
3 .21 .66
4 -.63 .29
5 1.01 .48
6 -.64 .4

and the corresponding data for disease-free survival
(which was only reported in 3 studies) look like this:

study estimate std.error
1 -.58 .56
4 -1.02 .39
6 -.69 .4

We enter these using lnHR as the stub for the log hazard ratios
and selnHR as a stub for the standard errors,
and using abbreviations os for overall survival and dfs
for disease-free survival:

clear
input study lnHRos selnHRos lnHRdfs selnHRdfs
1 -.18 .56 -.58 .56
2 .79 .24 . .
3 .21 .66 . .
4 -.63 .29 -1.02 .39
5 1.01 .48 . .
6 -.64 .4 -.69 .4
end

Note that we have entered missing values for disease-free survival in studies 2, 3 and 5.

mvmeta requires variables representing the variances.
These must be named as <stub><ending><ending>. We choose VlnHR as the stub for the variances, so:

gen VlnHRosos = selnHRos^2

gen VlnHRdfsdfs = selnHRdfs^2

These data are now in the format required by mvmeta and can be analysed
as shown in the main demonstration.

If we also knew the within-study covariances, we could have input them with the main data.
If we knew the within-study correlations, we could have input them with the main data (say as variable corrosdfs)
and then computed the covariances using gen VlnHRosdfs = corrosdfs*selnHRos*selnHRdfs.