*! version 4.07 David Fisher 15sep2023

Title

metan -- Perform meta-analysis of aggregate (summary) data

Syntax

metan has the following general syntax:

metan varlist [if] [in] [, options]

where varlist may contain two, three, four or six numeric variables depending upon the structure of the data.

More specifically, metan may have any of the following syntaxes:

Meta-analysis of generic (pre-calculated) effect sizes and their standard errors, with option to supply participant numbers via npts(varname).
Effect sizes must be based on a Normal distribution; for example, log odds-ratios rather than odds ratios.

metan ES seES [if] [in] [, npts(varname) model_spec options_main]

Meta-analysis of generic (pre-calculated) effect sizes and their 95% confidence limits, with option to supply participant numbers via npts(varname).
Confidence intervals are assumed to be symmetric, and the standard error is derived as (UCI - LCI) / 2*1.96.
Hence, confidence limits must be based on a Normal distribution, and have 95% level, or the pooled result will not be accurate.

metan ES lci uci [if] [in] [, npts(varname) model_spec options_main]

Meta-analysis of two-group comparison of binary outcomes,
using the number of events and non-events in the treatment and control groups

metan event_treat noevent_treat event_ctrl noevent_ctrl [if] [in]
[, model_spec options_binary options_main]

Meta-analysis of two-group comparison of continuous outcomes,
using the sample size, mean and standard deviation in the treatment and control groups

metan n_treat mean_treat sd_treat n_ctrl mean_ctrl sd_ctrl [if] [in]
[, model_spec options_continuous options_main]

Meta-analysis of proportions in a single group; note that option proportion must be supplied in this case

metan n_events n_total [if] [in] , proportion
[model_spec options_proportion options_main]

model_spec specifies method(s) for meta-analytic pooling,
including test statistics for the pooled effect,
and estimates and confidence intervals for between-study heterogeneity statistics.
If no model_spec is supplied, the default for two-group comparison of binary outcomes is mhaenszel;
otherwise the default is common. The simplest alternative is random, specifying the DerSimonian-Laird random-effects model.

model_spec has various other options and syntaxes, which are explained on a separate page.
This incorporates all the functionalities of the previous version of metan, including the ability to present multiple results
(e.g. common-effect and random-effects) in the same table and/or forest plot.

options

options_main general options, appropriate with any of the data input syntaxes for metan as described above

options_binary additional options specific to meta-analysis of two-group comparisons of binary outcomes

options_continuous additional options specific to meta-analysis of two-group comparisons of continuous outcomes

options_proportion additional options specific to meta-analysis of single-group proportion data

model_spec specify a model or method for meta-analytic pooling; test statistics; heterogeneity statistics

options_main

Main
lcols(study_id [varlist]) variable to be used to label studies (see also lcols() under "Forest plot and/or saved data")

label([namevar=namevar] [, yearvar=yearvar]) alternative way to label studies

by(subgroup_id [, missing]) subgroup meta-analysis

cumulative cumulative meta-analysis

influence investigate influence of each study in turn on the overall estimate

altwt display study weights from the standard (that is, non-cumulative or non-influence) meta-analysis

Options
citype(ci_type) method of constructing confidence intervals for reporting of individual studies (not pooled results)

level(#) ilevel(#) olevel(#) set confidence level for reporting confidence intervals. Default is c_level; see set level

eform display exponentiated (antilog) effect sizes and confidence limits

effect(string) title for "effect size" column in the output

keepall display all studies in the output, even those for which no effect could be estimated

keeporder display "no effect" studies in the order in which they would otherwise appear (by default these are moved to the end)

labtitle(text) override the default heading for the list of studies

nograph suppress the forest plot

notable suppress printing the table of effect sizes to screen; see also summaryonly

nohet nobetween suppress all heterogeneity statistics, or just between-subgroup heterogeneity statistics

nokeepvars do not add new variables to the dataset

norsample do not even add new variable _rsample recording which observations were used (cf. e(sample))

nooverall nosubgroup nosecsub suppress overall pooling, or pooling within subgroups

ovwt sgwt override default choice of whether to display overall weights or subgroup weights

prefix(prefix) defines a prefix to be added to the names of new variables and/or standard variables in the saved dataset

sortby(varname) ordering of studies in table and forest plot, and for cumulative meta-analysis

wgt(varname) specify a variable containing user-defined weights

Forest plot and/or saved data
allweights display study-specific weights associated with all requested models on the forest plot

hetinfo(het_spec) specify heterogeneity information to display on the forest plot

extraline(yes|no) override the default placement of heterogeneity information in the forest plot

rfdist, rflevel(#) display approximate predictive interval, with optional coverage level (default is c_level; see set level)

lcols(varlist), rcols(varlist) display (and/or save) columns of additional data

npts(npts_option) specify variable containing participant numbers (valid with generic/pre-calculated effect sizes only)

plotid(varname) define groups of observations in which to apply specific plot rendition options

summaryonly show only summary estimates (diamonds) in the forest plot and on screen

saving(saving_option) save data in the form of a "forestplot results set" to filename

clear replace the data in memory with the "results set", instead of saving to a separate file

nowarning suppress the default display of a note warning that studies are weighted from random effects anaylses

forestplot(forestplot_options) other options as described under forestplot

Description

metan performs meta-analysis of aggregate data; that is, data in which each observation represents a summary of a larger study.
Aggregate data may consist of cell counts from a two-group comparison of binary outcomes; sample sizes, means and standard deviations
from a two-group comparison of continuous outcomes; single-group proportion data; or generic (pre-calculated) effect sizes and their standard errors
or 95% confidence limits.

Much of the basic theory of aggregate-data meta-analysis, as implemented in metan, is described in Deeks et al (2001).

Options

Main

label([namevar=namevar] [, yearvar=yearvar])
labels the studies in all output, using names or years or both.
namevar and yearvar must be integer-valued or string.

namevar and/or yearvar may alternatively be specified as the first varname(s) in lcols(varlist)
(see Forest plot and/or saved data options).
In this case, label() is not necessary; note that if specified lcols() and label() will both be honoured by forestplot.

If neither label() or lcols() are supplied, studies will simply be labelled sequentially as "1", "2", etc.
In the absence of [if] [in], the entire dataset in memory will be included
except observations for which varlist is entirely system missing.

by(subgroup_id [, missing]) specifies a variable identifying subgroups of studies (and must therefore be constant within studies),
which must be either integer-valued or string.

missing requests that missing values be treated as potential subgroup identifiers; the default is to exclude them.

If subgroup_id is a string variable, then subgroups are displayed in the order they appear among the included observations
(according to their requested ordering within the analysis; see sortby()).
If subgroup_id is numeric, then subgroups are displayed in numeric order.
Within each subgroup, studies appear in the order they would appear if the entire analysis were restricted to that subgroup.

See also the labtitle() option for over-riding the default heading for the list of studies.

cumulative requests that the meta-analysis be performed cumulatively; that is, performed repeatedly with one study being added each time.
Studies will be added in the order specified by sortby() if present, or else in the order they appear in the dataset.
Pooled effect information (tests of z = 0, heterogeneity etc.) will be based on the model following the addition of the final study.
An example of such an analysis is given in Lau et al (1992).

See also the notes following influence below.

influence requests that each study in turn is removed from the meta-analysis to investigate its influence on the overall result.
Pooled effect information on screen remains identical to that if influence were not specified.
However, in the forest plot the usual diamond shape representing the pooled effect is replaced by vertical lines,
to allow a visual assessment of influence. Note that no formal test of influence is given.

Note that for both cumulative and influence, use of random-effects or variance-correction models
may result in weights greater than 100%, since weights are expressed relative to the total weight in the model with all studies included.
Only a single pooling method may be used with cumulative and influence.

altwt does not alter the effect estimates, but presents the original weights corresponding to each individual study,
rather than the relative weights of each fitted cumulative or influence model.
In other words, presented weights are as if cumulative or influence were not specified.
If applicable, presented participant numbers in the forest plot are treated similarly;
that is, the original participant numbers are presented with altwt,
in preference to either a cumulative sum (if cumulative) or a difference from the total (if influence).

Options

citype(ci_type) specifies how confidence limits for individual studies should be constructed for display purposes.
This option acts independently of both the data input varlist (i.e. data may be presented in a different -- though consistent --
manner to that in which it was supplied) and of how confidence limits for pooled results are constructed
(which will depend upon model_spec). See also level(#)

ci_type is normal by default, specifying use of the Normal distribution (i.e. a z-statistic).

ci_type may also be t, specifying use of the ("Student's") t distribution.
Degrees of freedom may be specified using the df(varname) option;
otherwise degrees of freedom of n-2 are assumed, where n is the study sample size.

Additional ci_types may also be specified with two-group binary comparisons or proportion data.

eform specifies that effect sizes and confidence limits should be exponentiated in the table and forest plot.

effect(string) specifies a heading for the effect size column in the output.

keepall, keeporder request that all values of study_id should be visible in the table and forest plot,
even if no effect could be estimated (e.g. due to insufficient observations or missing data).
For such studies, "(Insufficient data)" will appear in place of effect estimates and weights.

keeporder requests such studies are displayed in their "natural" sort order.
By default, such studies are moved to the end.

labtitle(text) over-rides the default heading for the list of studies, both on-screen and in the forest plot.
By default, this heading is taken from the variable label of the study identifier variable.

With by(), the default heading becomes "studylabel and bylabel" where studylabel, bylabel
are the variable labels of the study identifier and subgroup variable respectively.
This is where labtitle() is arguably most useful.

nograph, notable request the suppression of, respectively,
construction of the forest plot and the table of effect sizes.
See also the option summaryonly, which displays pooled effect sizes but suppresses the individual study estimates.

nohet suppresses heterogeneity statistics in both table and forest plot.

nobetween is an alternative option, which suppresses only the between-subgroup heterogeneity statistics,
retaining the overall and subgroup-specific heterogeneity statistics.
This might be useful in non-standard use-cases where between-subgroup tests are inappropriate or would otherwise cause confusion.

nokeepvars, norsample specify that new variables
should not be added to the dataset upon conclusion of the routine.

nokeepvars suppresses the addition of effect statistics such as _ES, _seES and _NN but retains _rsample.
If appropriate, effect statistics are instead returned in the matrix r(coeffs).

norsample further suppresses the addition of the variable _rsample,
an analogue of e(sample) which identifies which observations were included in the analysis.
Therefore, norsample requests that the data in memory not be changed in any way
upon conclusion of the routine.

nooverall, nosubgroup and nosecsub affect which groups of data are pooled, thus affecting both the table of effect sizes
and the forest plot (if applicable).

nooverall suppresses the overall pooled effect, so that (for instance) subgroups are considered entirely
independently. Between-subgroup heterogeneity statistics are also suppressed.

nosubgroup suppresses the within-subgroup pooled effects, so that subgroups are displayed
separately but with a single overall pooled effect with associated heterogeneity statistics.

nosecsub prevents the display of subgroup effect estimates using the second or further methods, if applicable.

ovwt, sgwt override the default choice of whether to display overall weights or within-subgroup weights
in the screen output and forest plot. Note that this makes no difference to calculations of pooled effect estimates,
as weights are normalised anyway.

sortby(varname) allows user-specified ordering of studies in the table and forest plot, without altering the data in memory.
See also cumulative.

wgt(varname) specifies user-defined weighting for any data type. You should only use this option if you are satisfied that the weights are meaningful.

Regardless of whether a fixed- or random-effects model is specified, pooled effects are calculated as:

theta = sum(w_i y_i) / sum(w_i)

For a fixed-effect model, pooled effect variances are calculated as:

Var(theta) = sum(w_i^2 v_i) / sum(w_i)^2

and for a random-effects model:

Var(theta) = sum(w_i^2 (v_i + tau^2)) / sum(w_i)^2

where v_i are the individual study variances and w_i are the user-defined weights.

Note that the scale of user-defined weights is immaterial, since individual weights are normalised.
Hence, once run, an analysis may be recreated using the option wgt(_WT).
The raw (non-normalised) numbers stored in varname may also be saved and/or displayed using the forest plot options lcols() or rcols().

Forest plot and/or saved data

allweights specifies that weights associated with all requested models be displayed as columns on the right-hand side of the forest plot.
By default, the presented weights are those associated with the first requested model only.

Weights will also be saved within the saved dataset.
Weights associated with the first model will be given the default name _WT.
Weights associated with subsequent models will be given names _WT_suffix, where suffix is a descriptive shorthand for the model.

hetinfo(het_spec) specifies the heterogeneity information to be displayed on the forest plot, which by default is isq pvalue.
het_spec has the following syntax:

het_stat [%fmt] [ het_stat [%fmt] ... ]

where %fmt is an optional format; and het_stat may be any of the following, in any order:

isq I-squared statistic

h H statistic

h2m H-squared statistic (Mittlböck modification)

tausq tau-squared statistic

q Q statistic and degrees of freedom

pvalue p-value corresponding to Q statistic

Note that the statistics I-squared, H and H-squared are by default derived from Q and its degrees of freedom,
unless option isqparam is specified; see metan_spec.

extraline(yes|no) affects the placement of the heterogeneity information (see hetinfo()) within the plot.
By default, heterogeneity information is displayed in brackets following the description of the pooled effect
(e.g. "Overall"). However, if columns of data are to be displayed on the left-hand side (see e.g. lcols())
which would cause text to be overwritten, then the heterogeneity information is moved to a new line immediately below.
extraline(yes) forces a new line to be used when it would otherwise not be;
extraline(no) forces a new line not to be used when it would otherwise would.

rfdist displays the confidence interval of the approximate predictive distribution of a future trial, based on the extent of heterogeneity.
This incorporates uncertainty in the location and spread of the random effects distribution
using the formula t * sqrt(SE^2 + tau^2), where t is the critical value from the Student's t distribution with k-2 degrees of freedom,
SE^2 is the squared standard error and tau^2 is the heterogeneity statistic.
The CI is then displayed with lines extending from the diamond.
Note that with <3 studies the distribution is inestimable and hence not displayed (this behaviour differs from that in metan9);
and where heterogeneity is zero there is still a slight extension as the t-statistic is always greater than the corresponding normal deviate.
For further information see Higgins and Thompson (2009).

rflevel(#) specifies the coverage (e.g. 95 percent) for the confidence interval of the predictive distribution.
Default is c_level; see set level.

lcols(varlist), rcols(varlist) define columns of additional data to the left or right of the graph.
By default, the first two columns on the right contain the effect size and weight. If counts is used this will be set as the third column.
Columns are titled with the variable label, or the variable name if a label is not defined.

Note: the first variable specified in lcols() is assumed to be the study identifier if neither study() nor label() are specified.

summaryonly shows only summary estimates on screen, in the forest plot, and in the saved dataset.
That is, the pooled overall estimate(s) and subgroup-specific estimates are shown/saved, but without the individual study estimates.

When combined with saving() or clear, summaryonly saves additional variables
usually associated with cumulative or influence analysis; for example, Q statistics and degrees of freedom.
This may be of use when running multiple analyses in a loop, where only the summary statistics are needed; see also stacklabel.

npts(varname [, nointeger noplot]) identifies an existing variable which contains participant numbers
to be displayed on-screen and in the forest plot and/or saved dataset.
This option is valid only with generic (pre-calculated) effect sizes.
In other cases, participant numbers are already known, and will be displayed and saved automatically; see e.g. metan_binary.

nointeger allows the participant numbers in varname to contain non-integer values.

noplot requests that participant numbers are displayed on-screen and included in the saved dataset (if appropriate)
but should not appear in the forest plot.

saving(filename [, replace stacklabel]) saves a forestplot "results set" into a Stata data file
for further use or manipulation; see saved datasets.

replace overwrites filename

stacklabel takes the variable label of the left-most column variable (usually study_id),
which would usually appear outside the plot region as the column heading, and instead stores it in the first observation of _LABELS.
This allows multiple such datasets to be appended without this information being lost.

clear is an alternative to saving() which replaces the data in memory with the "results set" data.

Saved results

By default, metan adds new variables to the dataset corresponding to the individual study effect sizes,
standard errors, confidence intervals and weights used by the program.
Amongst other things, this provides a method of obtaining effect sizes and standard errors from other data structures such as 2x2 cell counts;
in a similar way to Stata's built-in meta esize, or escalc within the metafor package in R.
These new variables may be suppressed using the nokeepvars or norsample options.

(Note that these variables are always consistent with the original raw data from individual studies, regardless of other options.
In particular, if options cumulative or influence are specified, these variables will not be consistent with the results table shown on-screen.
To consistently obtain the data shown on-screen and in the forest plot, use "results sets" as described below.)

The following new variables may be added:

_ES Effect size (ES) on the interval scale (e.g. log odds ratio, or transformed proportion)

_seES Standard error of ES

_LCI Lower confidence limit for ES

_UCI Upper confidence limit for ES

_WT Study percentage weight (between 0 and 100) associated with first requested pooling method

_NN Study sample size

_CC Marker of whether continuity correction was applied

_rsample Marker of which observations were used in the analysis

If the prefix(prefix) option is specified, then the variable names above become prefix_ES and so on.

metan also saves the following in r():

(with some variation, and in addition to any scalars saved by forestplot)

Scalars

r(k) Number of included studies k

r(n) Number of included participants

r(eff) Overall pooled effect size

r(se_eff) Standard error of overall pooled effect size

r(Q) Q statistic of heterogeneity (with degrees of freedom k-1)

r(Q_lci) Lower confidence limit for Q; see model_spec

r(Q_uci) Upper confidence limit for Q; see model_spec

r(Isq) Heterogeneity measure I-squared

r(H) Heterogeneity measure H

r(HsqM) Heterogeneity measure H-squared (Mittlböck modification)

r(m) Number of different pooling method(s) used

Macros

r(measure) Name of effect measure

r(citype) Method of constructing study-level confidence intervals

r(model) Pooling method(s) used (e.g. Mantel-Haenszel, fixed-effect, DerSimonian-Laird)

r(model#opts) Options relating to pooling method(s), if applicable

Matrices

r(ovstats) Matrix of overall effects, standard errors, test statistics, p-values, and confidence intervals

r(bystats) Matrix of effects, standard errors etc. by subgroup, for a single pooling method

r(bystats#) Matrices of subgroup effect statistics for multiple pooling methods, if applicable

r(byQ) Matrix of subgroup-specific Q statistics

r(hetstats) Matrix of overall heterogeneity statistics, with confidence intervals where appropriate

r(byhet) Matrices of heterogeneity statistics by subgroup, for a single pooling method

r(byhet#) Matrices of heterogeneity statistics by subgroup for multiple pooling methods, if applicable

The following results may also be saved, depending on the combination of effect measure and model:

Scalars (specific effect measures only)

r(OR), r(RR) Mantel-Haenszel estimates of Odds Ratio or Risk Ratio (if appropriate)

r(chi2) Chi-squared test statistic (if requested)

r(OE), r(V) Overall pooled OE and V statistics (if appropriate)

r(cger), r(tger) Average event rate in control and treatment groups

Scalars (with subgroups only)

r(nby) Number of subgroups

r(Qbet) Measure of between-study heterogeneity (see note below)

r(Qsum) (common-effect models only) Sum of within-subgroup heterogeneity statistics

r(F) (common-effect models only) F-statistic comparing within- and between-subgroup heterogeneity;
equal to (r(Qbet)/(r(nby) - 1)) / (r(Qsum)/((r(k) - 1) - (r(nby) - 1)))
as suggested by Sandercock et al (2002)

Scalars (inverse-variance models only)

r(tausq) Between-study variance tau-squared

r(sigmasq) Average within-study variance

r(Hstar) H statistic calculated using random-effects weights and pooled estimate,
as suggested by van Aert & Jackson (2019)

Scalars (iterative random-effects models only; see mf_mm_root for interpretations of convergence success values)

r(tsq_var) Estimated variance of tau-squared

r(tsq_lci) Lower confidence limit for tau-squared

r(tsq_uci) Upper confidence limit for tau-squared

r(rc_tausq) Whether tau-squared point estimate converged successfully

r(rc_tsq_lci) Whether tau-squared lower confidence limit converged successfully

r(rc_tsq_uci) Whether tau-squared upper confidence limit converged successfully

r(rc_eff_lci) Whether effect estimate lower confidence limit converged successfully

r(rc_eff_uci) Whether effect estimate upper confidence limit converged successfully

Saved datasets

In order to construct a forest plot, metan manipulates the data originally in memory into a format that forestplot understands.
This "forestplot results set" can be saved to a Stata data file using the saving() or clear options, allowing the user to further manipulate it and
hence create highly customised forest plots.

The structure of these "results sets" is such that each row of data will appear in the plot, in the same order (top to bottom).
Variable labels will appear above columns of data within the plot region; value labels and formats (including string justification)
are honoured where possible. See forestplot for further details of how such data is interpreted, and for additional options.

Variables specified in lcols() or rcols() will have their variable names, labels and formats preserved within "results sets".
Otherwise, variables are given standardised names, as follows:

Core variables

_USE Indicates the type of content in each observation (e.g. study effect, pooled effect); see forestplot

_STUDY Value-labelled numeric variable identifying the studies

_LABELS String containing general information to be displayed on the left-hand side of the forestplot, including study names

_ES Effect size (ES) on the interval scale (see saved results)

_seES Standard error of ES (see saved results)

_LCI Lower confidence limit for ES (see saved results)

_UCI Upper confidence limit for ES (see saved results)

_NN Study sample size (see saved results)

_WT Study percentage weight (see saved results)

_EFFECT String containing the effect size and confidence limits together, on the display scale (i.e. exponentiated if specified)

Option-dependent variables

_BY Value-labelled numeric variable identifying study subgroups (see by() option)

_CC Marker of whether continuity correction was applied (see cc option)

_counts1 String containing "events/total" numbers in the research arm (see counts option)

_counts0 String containing "events/total" numbers in the control arm (see counts option)

_counts1msd String containing "mean (SD)" in the research arm (see counts option)

_counts0msd String containing "mean (SD)" in the control arm (see counts option)

_OE Logrank O-E

_V Logrank V

_VE String containing vaccine efficacy and confidence limits (see efficacy option)

_rfLCI Lower confidence limit of approximate predictive distribution (see rfdist option)

_rfUCI Upper confidence limit of approximate predictive distribution (see rfdist option)

_Prop_ES Proportion (see proportion option)

_Prop_LCI Lower confidence limit of proportion (see proportion option)

_Prop_UCI Upper confidence limit of proportion (see proportion option)

With cumulative or influence, additional variables will be saved corresponding to the entries
of r(ovstats) not covered by the above lists, plus Q statistics and degrees of freedom.

Some of these variables have associated characteristics; type char list to see these.

If the prefix(string) option is specified, then the variable names above become string_USE and so on.

Note: Differences from previous versions of metan

This latest version of metan is designed to run under Stata version 11 and upwards,
(with the exception of two random-effects models requiring numerical integration,
handled via an additional user-contributed Mata function written for Stata version 12).
The previous version of metan, v3.04 written for Stata v9 (Harris et al 2008),
remains available within this package under the name metan9.
A still older version, v1.86 written for Stata v7 (Bradburn et al 1998),
also remains available under the name metan7.

This version of metan has been designed with consistency and backwards-compatibility in mind.
However, there are some differences in syntax and behaviour from previous versions. In particular:

The preferred, documented syntax is for most options specific to the forest plot (i.e. those that do not affect the results appearing in the Results Window)
to be placed within the forestplot() option rather than directly to metan. This includes nostats and nowt.
Any previously-valid syntax continues to be supported, but with a message printed to the Results Window as a reminder
that the documented syntax has changed.

Certain options, such as nowt, nohet and summaryonly, now affect the output in the Results Window as well as the forest plot.

For details of other, more specific, changes to syntax and behaviour relating to the forest plot, see forestplot.

Prediction intervals (rfdist) are no longer displayed with dotted lines if the number of studies is less than three;
instead, the interval is simply not displayed at all. A message is printed to the Results Window explaining this.

If rflevel() is different from olevel(), then results from metan may differ slightly from metan9
due to a subtle error in the older code, which has been corrected.

Saved results are now always on the interval scale.
For example: if using binary outcome data,
_ES and _seES might contain the individual study log Risk Ratios and standard errors,
and r(eff) and r(se_eff) the pooled log Risk Ratio and its standard error.
(The variable name _selogES is therefore no longer used.)
This has the advantage of consistency across outcome types, and means that saved results may be passed directly to metan, forestplot
or similar, without needing to take logarithms.

The names of all returned values saved in r() by metan9 continue to be honoured.
(For those interested: this is done using return historical.)

If model_name is mhaenzsel or peto, continuity correction is generally not necessary for pooling,
and may in fact lead to increased bias (see, for example, Bradburn et al 2007).
Hence, in this version of metan, no continuity correction is applied by default with mhaenzsel or peto;
although a correction will be applied (if necessary) to the individual study estimates and weights, for display purposes.
However, in the extreme case that all studies have a zero cell in the same treatment group,
continuity correction becomes necessary for Mantel-Haenszel Risk Ratios and Odds Ratios; in that case the default correction of 0.5 is applied.

The above can be summarized as: by default, metan will analyse the available data in the best way possible.
Note that any of the behaviour described above may be over-ridden by explicit use of the cc() option; see metan_binary.
In particular, if the option cc(0.5) is added to the command line then all results will match with those from metan9.

If a random-effects model is specified, overall and subgroup-specific Q statistics
are based on the inverse-variance common-effect model.
However, between-subgroup heterogeneity is tested by considering the dispersal of subgroup-specific pooled effects
from the weighted average of subgroup effects under the specified model, as described in chapter 19 of Borenstein et al 2009.
Note that under the inverse-variance common-effect model, this approach is equivalent to variance partitioning
as used in previous versions of metan (see metan9 and Deeks et al 2001).

Similar behaviour is seen when specifying user-defined weights with wgt(), except that overall and subgroup-specific Q statistics
measure the dispersal of individual effects from the weighted pooled estimate, using standard inverse-variance weights.
This matches the pre-existing behaviour of metan with the Mantel-Haenszel and Peto methods.
(If a random-effects model is specified with wgt(), Q statistics are calculated under the equivalent common-effect model.)

If model_name is mhaenzsel or peto,
between-subgroup heterogeneity is handled as described above for random-effects models.

Finally, note that model_names random and randomi are now synonymous,
and both will display the inverse-variance estimate of heterogeneity.
If you wish to have the Mantel-Haenzel estimate of heterogeneity displayed on screen,
you could specify model(mh \ random).

Note: Differences from Stata 16's meta suite

In June 2019, Stata version 16 introduced a suite of built-in meta-analysis commands, with the prefix meta.
Forest plots are generated using a new specific Stata graph type (rather than being generated using a combination of twoway commands),
and there is better interface with other built-in Stata estimation commands.
However, there remains a need for a comprehensive, adaptable user-written package which is available to users of earlier and more recent versions of Stata alike.
At the time of writing, metan implements a wider range of random-effects models and additional features,
and forestplot provides far more flexibility to create non-standard plots.

Note also that there is an important difference in the way that metan and Stata 16's meta suite
report heterogenity statistics with random-effects models.
metan views I-squared (and its transformations H and H-squared) as being descriptive of the observed data,
and I-squared is therefore derived from Q regardless of the specified model (unless option isqparam is specified; see model_spec).
By constrast, Stata 16's meta suite reports I-squared based on Q if a common-effect model is specified,
or based on tau-squared if a random-effects model is specified.

Examples

All examples use a simulated example dataset (Ross Harris 2006) originally prepared for metan9.

. use http://fmwww.bc.edu/repec/bocode/m/metan_example_data, clear

Risk difference from raw cell counts, random effects model, "label" specification with counts displayed

. metan tdeath tnodeath cdeath cnodeath,

rd random label(namevar=id, yearvar=year) counts

(click to run)

Same again, but now with three different pooling methods: Mantel-Haenszel common-effect,
Mandel-Paule random-effects, and REML random-effects with Hartung-Knapp-Sidik-Jonkman variance correction.
Note that, although the two random-effects models give two different estimates of tau-squared,
only a single estimate of I-squared is given, derived from the Q statistic of the first model.

. metan tdeath tnodeath cdeath cnodeath,

rd label(namevar=id, yearvar=year) counts

model(mh \ mp \ reml, hksj)

(click to run)

...and same again; but this time with the added option isqparam (see model_spec)
which requests additional derivations of I-squared
based on the tau-squared parameter estimates from the random-effects models.

. metan tdeath tnodeath cdeath cnodeath,

rd label(namevar=id, yearvar=year) counts

model(mh \ mp \ reml, hksj) isqparam

(click to run)

Sort by year, use data columns syntax with all column data left-justified. Specify percentage of graph as text;
suppress stats, weight, heterogeneity stats and table.

. metan tdeath tnodeath cdeath cnodeath, notable

sortby(year) lcols(id year country) rcols(population)

forestplot(astext(60) nostats nowt nohet leftjustify double)

(click to run)

Analyse continuous data (six-parameter syntax), stratify by type of study, with weights summing to 100% within sub group,
display random-effects predictive distribution, show raw data counts, display "favours treatment vs. favours control" labels

. metan tsample tmean tsd csample cmean csd,

label(namevar=id) by(type_study) sgweight random rfdist counts

forestplot(favours(Treatment reduces blood pressure # Treatment increases blood pressure))

(click to run)

Use metan to generate log odds ratio and standard error from the raw cell counts,
then analyse with two-parameter syntax. Graph has exponential form,
scale is forced within set limits and ticks added, effect label specified.

. quietly metan tdeath tnodeath cdeath cnodeath, or nograph

. rename _ES logor

. rename _seES selogor

. metan logor selogor, eform effect(Odds ratio)

forestplot(xlabel(0.5 1 1.5 2 2.5, force) xtick(0.75 1.25 1.75 2.25))

(click to run)

Analyse the number of deaths in the control arm as proportion data,
using the Freeman-Tukey double-arcsine transformation.
By default, the null line is removed and the x-axis range is forced to be from zero to one.

. metan cdeath csample, proportion transform(ftukey) label(namevar=id)

(click to run)

Display diagnostic test data with three-parameter syntax. Weight is number of positive diagnoses, axis label set
and null specified at 50%. Overall effect estimate is not displayed, graph for visual examination only.

. metan percent lowerci upperci, wgt(n_positives) label(namevar=id) nooverall notable

forestplot( xlabel(0(10)100, force) null(50) title(Sensitivity, position(6)) )

(click to run)

User has analysed data with a non-standard technique and supplied effect estimates, weights and description of statistics.
The scheme "Economist" has been used.
Note that this scheme applies a different default line width to area outlines from that applied to simple lines;
therefore we must override the scheme's default when plotting the pooled-effect diamond.

. metan OR ORlci ORuci, label(namevar=id) wgt(bweight)

first(0.924 0.753 1.095 Bayesian) firststats(param V=3.86, p=0.012)

forestplot( xlabel(0.25 0.5 1 2 4, force) null(1) scheme(economist) diamopts(lwidth(thick)) )

(click to run)

The above example used the options first() and firststats().
As of metan version 4, these options are no longer the preferred syntax, although they continue to be supported.
The preferred syntax would instead be (see metan_model):

. metan OR ORlci ORuci, label(namevar=id) wgt(bweight)

model( 0.924 0.753 1.095, label(Bayesian) extralabel(param V=3.86, p=0.012) )

forestplot( xlabel(0.25 0.5 1 2 4, force) null(1) scheme(economist) diamopts(lwidth(thick)) )

(click to run)

Same example again, but this time we use the option clear to replace the data in memory with a "forest plot results set",
which is then edited to contain our user-defined estimates.
Finally, the forest plot is generated, and appears identical to that in the previous example.
This demonstrates some of the flexibility of being able to edit (and otherwise manipulate) forest plot results sets.

Note: the option useopts ensures that no options, defaults, etc. are lost
between the initial call to metan and the final call to forestplot.
For further details, see forestplot.

. preserve

. quietly metan OR ORlci ORuci, wgt(bweight) label(namevar=id) nograph clear

. replace _ES = 0.924 if _USE == 5

. replace _LCI = 0.753 if _USE == 5

. replace _UCI = 1.095 if _USE == 5

. replace _LABELS = "Overall, Bayesian (param V=3.86, p=0.012)" if _USE == 5

. format %-1s _LABELS

. forestplot, useopts xlabel(0.25 0.5 1 2 4, force) null(1) scheme(economist) diamopts(lwidth(thick))

. restore

(click to run)

Variable "counts" defined showing raw data. Options to change the box, effect estimate marker and confidence interval are used,
and the counts variable has been attached to the estimate marker as a label.

. gen counts = ". " + string(tdeath) + "/" + string(tdeath+tnodeath)

+ ", " + string(cdeath) + "/" + string(cdeath+cnodeath)

. metan tdeath tnodeath cdeath cnodeath, lcols(id year) notable

forestplot(range(.3 3) boxopt( mcolor(forest_green) msymbol(triangle))

pointopt( msymbol(triangle) mcolor(gold) msize(tiny)mlabel(counts) mlabsize(vsmall) mlabcolor(forest_green) mlabposition(1))

ciopt( lcolor(sienna) lwidth(medium)))

(click to run)

L'Abbe plot with labelled axes and display of risk ratio and risk difference.

. labbe tdeath tnodeath cdeath cnodeath,

xlabel(0,0.25,0.5,0.75,1) ylabel(0,0.25,0.5,0.75,1)

rr(1.029) rd(0.014) null

(click to run)

Authors

Original authors:
Michael J Bradburn, Jonathan J Deeks, Douglas G Altman.
Centre for Statistics in Medicine, University of Oxford, Oxford, UK

metan v3.04 for Stata v9:
Ross J Harris, Roger M Harbord, Jonathan A C Sterne.
Department of Social Medicine, University of Bristol, Bristol, UK

metan v4.00 and later (including current version):
David Fisher, MRC Clinical Trials Unit at UCL, London, UK.

Email d.fisher@ucl.ac.uk

Acknowledgments

Thanks to Patrick Royston (MRC Clinical Trials Unit at UCL, London, UK) for suggestions of improvements to the code and help file.

Thanks to Vince Wiggins, Kit Baum and Jeff Pitblado of Statacorp who offered advice and helped facilitate the version 9 update.

Thanks to Julian Higgins and Jonathan Sterne (University of Bristol, UK) who offered advice and helped facilitate this latest update,
and thanks to Daniel Klein (Universität Kassel, Germany) for assistance with testing under older Stata versions.

The "click to run" element of the examples in this document is handled using an idea originally developed by Robert Picard.

References

Borenstein M, Hedges LV, Higgins JPT, Rothstein HR. 2009.
Introduction to Meta-analysis. Chichester: Wiley.

Bradburn MJ, Deeks JJ, Altman DG. 1998.
metan — an alternative meta-analysis command.
Stata Technical Bulletin 44: sbe24 (pp 4-15)

Bradburn MJ, Deeks JJ, Berlin JA, Localio AR. 2007.
Much ado about nothing: a comparison of the performance of meta-analytical methods with rare events.
Statistics in Medicine 26: 53-77. doi: 10.1002/sim.2528

Deeks JJ, Altman DG, Bradburn MJ. 2001.
Statistical methods for examining heterogeneity and combining results from several studies in meta-analysis.
In Systematic Reviews in Health Care: Meta-analysis in Context, ed. Egger M, Davey Smith G, Altman DG, 2nd ed., 285-312. London: BMJ Books.

Harris RJ, Bradburn MJ, Deeks JJ, Harbord RM, Altman DG, Sterne JAC. 2008.
metan: fixed- and random-effects meta-analysis.
Stata Journal 8: 3-28

Higgins JPT, Thompson SG, Spiegelhalter DJ. 2009.
A re-evaluation of random-effects meta-analysis.
JRSS Series A 172: 137-159

Lau J, Antman EM, Jimenez-Silva J, Mosteller F, Chalmers TC. 1992.
Cumulative meta-analysis of therapeutic trials for myocardial infarction.
New England Journal of Medicine 327: 248-254

Mittlböck M, Heinzl H. 2006.
A simulation study comparing properties of heterogeneity measures in meta-analyses.
Statistics in Medicine 25: 4321-4333

Sandercock J, Parmar MKB, Torri V, Qian W. 2002.
First-line treatment for advanced ovarian cancer : paclitaxel, platinum and the evidence.
British Journal of Cancer 87: 815-824