Fixed and random effects meta-analysis
metan varlist [if exp] [in range] [weight] [, measure_and_model_options options_for_continuous_data output_options forest_plot_options ]
where measure_and_model_options may be
or rr rd fixed random fixedi peto cornfield chi2 breslow nointeger cc(#) wgt(weightvar) second(model or estimates and description) first(estimates and description)
and where options_for_continuous_data may be
cohen hedges glass nostandard fixed random
and where output_options may be
by(byvar) nosubgroup sgweight log eform efficacy ilevel(#) olevel(#) sortby(varlist) label(namevar yearvar) nokeep notable nograph nosecsub
and where forest_plot_options may be
legend(string) xlabel(#,...) xtick(#,...) boxsca(#) nobox nooverall nowt nostats group1(string) group2(string) effect(string) force
...with further forest_plot_options in the version 9 update
lcols(varlist) rcols(varlist) astext(#) double nohet summaryonly rfdist rflevel(#) null(#) nulloff favours(string # string) firststats(string) secondstats(string) boxopt() diamopt() pointopt() ciopt() olineopt() classic nowarning graph_options
labbe varlist [if exp] [in range] [weight] [, nowt percent or(#) rr(#) rd(#) null logit wgt(weightvar) symbol(symbolstyle) nolegend id(idvar) textsize(#) clockvar(clockvar) gap(#) graph_options
These routines provide facilities to conduct meta-analyses of data from more than one study and to graph the results. Either binary (event) or continuous data from two groups may be combined using the metan command. Additionally, intervention effect estimates with corresponding standard errors or confidence intervals may be meta-analysed. Several meta-analytic methods are available, and the results may be displayed graphically in a Forest plot. A test of whether the summary effect measure is equal to the null is given, as well as a test for heterogeneity, i.e., whether the true effect in all studies is the same. Heterogeneity is also quantified using the I-squared measure (Higgins et al 2003).
metan (the main meta-analysis routine) requires either two, three, four or six variables to be declared. When four variables are specified these correspond to the number of events and non-events in the experimental group followed by those of the control group, and analysis of binary data is performed on the 2x2 table. With six variables, the data are assumed continuous and to be the sample size, mean and standard deviation of the experimental group followed by those of the control group. If three variables are specified these are assumed to be the effect estimate and its lower and upper confidence interval, and it is suggested that these are log transformed for odds ratios or risk ratios and the eform option used. If two variables are specified these are assumed to be the effect estimate and standard error; again, it is recommended that odds ratios or risk ratios are log transformed.
labbe draws a L'Abbe plot for event data (proportion of successes in the two groups). This is an alternative to the graph produced by metan8.
Note that the metan command now requires Stata version 9 and has been updated with several new options. Changes are mainly to graphics options which are collected in the section Further options in the v9 update for metan: Forest plot, or otherwise marked v9 update. The previous version is still available under the name -metan7-
Remarks on funnel (discontinued)
The metafunnel command has more options for funnel plots and version 8 graphics; as such funnel has been removed. See metafunnel (if installed)
Options for metan
+----------------------------------+ ----+ Specifying the measure and model +---------------------------------
These options apply to binary data.
rr pools risk ratios (the default).
or pools odds ratios.
rd pools risk differences.
fixed specifies a fixed effect model using the method of Mantel and Haenszel (the default).
fixedi specifies a fixed effect model using the inverse variance method.
peto specifies that Peto's method is used to pool odds ratios.
random specifies a random effects model using the method of DerSimonian & Laird, with the estimate of heterogeneity being taken from the from the Mantel-Haenszel model.
randomi specifies a random effects model using the method of DerSimonian & Laird, with the estimate of heterogeneity being taken from the inverse-variance fixed-effect model.
cornfield computes confidence intervals for odds ratios by method of Cornfield, rather than the (default) Woolf method.
chi2 displays chi-squared statistic (instead of z) for the test of significance of the pooled effect size. This is available only for odds ratios pooled using Peto or Mantel-Haenszel methods.
breslow produces Breslow-Day test for homogeneity of ORs.
cc(#) defines a fixed continuity correction to add in the case where a study contains a zero cell. By default, metan8 adds 0.5 to each cell of a trial where a zero is encountered when using Inverse-Variance, Der-Simonian & Laird or Mantel-Haenszel weighting to enable finite variance estimators to be derived. However, the cc() option allows the use of other constants (including none). See also the nointeger option.
nointeger allows the cell counts to be non-integers. This may be useful when a variable continuity correction is sought for studies containing zero cells, but also may be used in other circumstances, such as where a cluster-randomised trial is to be incorporated and the "effective sample size" is less than the total number of observations.
wgt(weightvar) specifies alternative weighting for any data type. The effect size is to be computed by assigning a weight of weightvar to the studies. When RRs or ORs are declared, their logarithms are weighted. You should only use this option if you are satisfied that the weights are meaningful.
second(model or estimates and description) (v9 update) A second analysis may be performed using another method, using fixed, random or peto. Alternatively, the user may define their own estimate and 95% CI based on calculations performed externally to metan, along with a description of their method, in the format es lci uci description. The results of this analysis are then displayed in the table and forest plot. Note that if by is used then sub-estimates from the second method are not displayed with user defined estimates, for obvious reasons.
first(estimates and description) (v9 update) Use of this command completely changes the way metan operates, as results are no longer based on any standard methods. The user defines their own estimate, 95% CI and description as in the above, and must supply their own weightings using wgt(weightvar) to control display of box sizes. Note that data must be supplied in the 2 or 3 variable syntax (theta se_theta or es lci uci) and by may not be used used for obvious reasons.
+-----------------+ ----+ Continuous data +--------------------------------------------------
cohen pools standardised mean differences by the method of Cohen (the default).
hedges pools standardised mean differences by the method of Hedges.
glass pools standardised mean differences by the method of Glass.
nostandard pools unstandardised mean differences.
fixed specifies a fixed effect model using the inverse variance method (the default).
random specifies a random effects model using the DerSimonian & Laird method.
nointeger denotes that the number of observations in each arm does not need to be an integer. By default, the first and fourth variables specified (containing N_intervention and N_control respectively) may occasionally be non-integer (see entry for nointeger under binary data).
+--------+ ----+ Output +-----------------------------------------------------------
by() specifies that the meta-analysis is to be stratified according to the variable declared.
sgweight specifies that the display is to present the percentage weights within each subgroup separately. By default metan presents weights as a percentage of the overall total.
log reports the results on the log scale (valid for OR and RR analyses from raw data counts only).
nosubgroup indicates that no within-group results are to be presented. By default metan pools trials both within and across all studies.
eform exponentiates all effect sizes and confidence intervals (valid only when the input variables are log odds ratios or log hazard ratios with standard error or confidence intervals).
efficacy expresses results as the vaccine efficacy (the proportion of cases that would have been prevented in the placebo group that would have been prevented had they received the vaccination). Only available with odds ratios (OR) or risk ratios (RR).
ilevel(#) specifies the coverage (eg 90,95,99 percent) for the individual trial confidence intervals. Default: $S_level. ilevel() and olevel() need not be the same. See set level.
olevel(#) specifies the coverage (eg 90,95,99 percent) for the overall (pooled) trial confidence intervals. Default: $S_level. ilevel() and olevel() need not be the same. See set level.
sortby(varlist) sorts by variable(s) in varlist
label([namevar=namevar], [yearvar=yearvar]) labels the data by its name, year or both. Either or both option/s may be left blank. For the table display the overall length of the label is restricted to 20 characters. The option lcols() will override this if invoked.
nokeep prevents the retention of study parameters in permanent variables (see saved results below).
notable prevents display of table of results.
nograph prevents display of graph.
nosecsub (v9 update) prevents the display of sub-estimates using the second method if second() is used. Note that this is invoked automatically with user-defined estimates.
+-------------+ ----+ Forest plot +------------------------------------------------------
effect() may be used when the effect size and its standard error are declared. This allows the graph to name the summary statistic used.
nooverall revents display of overall effect size on graph (automatically enforces the nowt option).
nowt prevents display of study weight on the graph.
nostats prevents display of study statistics on graph.
counts (v9 update) displays data counts (n/N) for each group when using binary data, or the sample size, mean and SD for each group if mean differences are used (the latter is a new feature).
group1(string), group2(string) may be used with the counts option: the text should contain the names of the two groups.
xlabel() (v9 update) defines x-axis labels. This has been modified so that any number of points may defined. Also, there are no longer any checks made as to whether these points are sensible, so the user may define anything if the force option is used. Points must be comma separated.
xtick() adds tick marks to the x-axis. Points must be comma separated.
force forces the x-axis scale to be in the range specified by xlabel().
boxsca() (v9 update) controls box scaling. This has been modified slightly so that the default is 100 (as in a percentage) and may be increased or decreased as such (e.g., 80 or 120 for 20% smaller or larger respectively)
nobox prevents a "weighted box" being drawn for each study and markers for point estimates only are shown.
texts() (v9 update) specifies font size for text display on graph. This has been modified slightly so that the default is 100 (as in a percentage) and may be increased or decreased as such (e.g., 80 or 120 for 20% smaller or larger respectively)
+------------------------------------------------------+ ----+ Further options for the forest plot in the v9 update +-------------
lcols(varlist), rcols(varlist) define columns of additional data to the left or right of the graph. The first two columns on the right are automatically set to effect size and weight, unless suppressed using the options nostats and nowt. If counts is used this will be set as the third column. textsize() can be used to fine-tune the size of the text in order to acheive a satisfactory appearance. The columns are labelled with the variable label, or the variable name if this is not defined. The first variable specified in lcols() is assumed to be the study identifier and this is used in the table output.
astext(#) specifies the percentage of the graph to be taken up by text. The default is 50 and the percentage must be in the range 10-90.
double allows variables specified in lcols and rcols to run over two lines in the plot. This may be of use if long strings are to be used.
nohet prevents display of heterogeneity statistics in the graph.
summaryonly shows only summary estimates in the graph (may be of use for multiple subgroup analyses)
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(df) x sqrt(se2 + tau2) where t is the t-distribution with k-2 degrees of freedom, se2 is the squared standard error and tau2 the heterogeneity statistic. The CI is then displayed with lines extending from the diamond. Note that with <3 studies the distribution is inestimable and effectively infinite, thus displayed with dotted lines, 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 JPT, Thompson SG (2006)
rflevel(#) specifies the coverage (eg 90,95,99 percent) for the confidence interval of the predictive distribution. Default: $S_level. See set level.
null(#) displays the null line at a user-defined value rather than 0 or 1.
nulloff removes the null hypothesis line from the graph
favours(string # string) applies a label saying something about the treatment effect to either side of the graph (strings are separated by the # symbol). This replaces the feature available in b1title in the previous version of metan.
firststats(string), secondstats(string) labels overall user-defined estimates when these have been specified. Labels are displayed in the position usually given to the heterogeneity statistics.
boxopt(), diamopt(), pointopt(), ciopt(), olineopt() specify options for the graph routines within the program, allowing the user to alter the appearance of the graph. Any options associated with a particular graph command may be used, except some that would cause incorrect graph appearance. For example, diamonds are plotted using the twoway pcspike command, so options for line styles are available (see line options); however, altering the x-y orientation with the option horizontal or vertical is not allowed. So, diamopt(lcolor(green) lwidth(thick)) feeds into a command such as pcspike(y1 x1 y2 x2, lcolor(green) lwidth(thick))
boxopt() controls the boxes and uses options for a weighted marker (e.g., shape, colour; but not size). See marker options
diamopt() controls the diamonds and uses options for pcspike (not horizontal/vertical). See line options
pointopt() controls the point estimate using marker options. See marker options and marker label options
ciopt() controls the confidence intervals for studies using options for pcspike (not horizontal/vertical). See line options
olineopt() controls the overall effect line with options for an additional line (not position). See line options
classic specifies that solid black boxes without point estimate markers are used as in the previous version of metan.
nowarning switches off the default display of a note warning that studies are weighted from random effects anaylses.
graph_options specifies overall graph options that would appear at the end of a twoway graph command. This allows the addition of titles, subtitles, captions etc., control of margins, plot regions, graph size, aspect ratio and the use of schemes. As titles may be added in this way previous options b2title etc. are no longer necessary. See graph options
Options for labbe
nowt declares that the plotted data points are to be the same size.
percent displays the event rates as percentages rather than proportions.
null draws a line corresponding to a null effect (ie p1=p2).
or(#) draws a line corresponding to a fixed odds ratio of #.
rd(#) draws a line corresponding to a fixed risk difference of #.
rr(#) draws a line corresponding to a fixed risk ratio of #. See also the rrn() option.
rrn(#) draws a line corresponding to a fixed risk ratio (for the non-event) of #. The rr() and rrn() options may require explanation. Whereas the OR and RD are invariant to the definition of which of the binary outcomes is the "event" and which is the "non-event", the RR is not. That is, while the command metan a b c d , or gives the same result as metan b a d c , or (with direction changed), an RR analysis does not. The L'Abbe plot allows the display of either or both to be superimposed risk difference.
logit is for use with the or() option; it displays the probabilities on the logit scale ie log(p/1-p). On the logit scale the odds ratio is a linear effect, and so this makes it easier to assess the "fit" of the line.
wgt(weightvar) specifies alternative weighting by the specified variable (default is sample size).
symbol(symbolstyle) allows the symbol to be changed (see help symbolstyle) the default being hollow circles (or points if weights are not used).
nolegend suppresses a legend being displayed (the default if more than one line corresponding to effect measures are specified).
id(idvar) displays marker labels with the specified ID variable idvar. clockvar() and gap() may be used to fine-tune the display, which may become unreadable if studies are clustered together in the graph.
textsize(#) increases or decreases the text size of the id label by specifying # to be more or less than unity. The default is usually satisfactory, but may need to be adjusted.
clockvar(clockvar) specifies the position of idvar around the study point, as if it were a clock face (values must be integers- see clockposstyle). This may be used to organise labels where studies are clustered together. By default, labels are positioned to the left (9 o'clock) if above the null and to the right (3 o'clock) if below. Missing values in clockvar will be assigned the default position, so this need not be specified for all observations.
gap(#) increases or decreases the gap between the study marker and the id label by specifying # to be more or less than unity. The default is usually satisfactory, but may need to be adjusted.
graph_options are options for Stata 8 graphs (see help on graph).
Remarks on metan
For two or three variables, a variance-weighted analysis is performed in a similar fashion to the meta command; the two variable syntax is theta and SE(theta). The 3 variable syntax is theta, lower ci (theta), upper ci (theta). Note that in this situation "theta" is taken to be the logarithm of the effect size if the odds ratio or risk ratio is used. This differs from the equivalent in the meta command. This program does not assume the three variables need log transformation: if odds ratios or risk ratios are combined, it is up to the user to log-transform them first. The eform option may be used to change back to the original scale if needed. By default the confidence intervals are assumed symmetric, and the studies are pooled by taking the variance to be equal to (CI width)/2z.
Note that for graphs on the log scale (that is, ORs or RRs), values outside the range [10e-8,10e8] are not displayed, and similarly graphs of other measures (log ORs, RDs, SMDs) are restricted to the range [-10e8,10e8]. A confidence interval which extends beyond this, or the specified scale if force is used, will have an arrow added at the end of the range.
Further notes on v9 update: If by is used with a string variable the stratification variable is not sorted alpha-numerically and the original order that the groups appear in the data is preserved. This may be of use if a particular display order is required; if not, sortby may be used. The option counts is now available for continuous data and displays sample size, mean and SD in each group. The estimate for heterogeneity between groups from a stratified analysis using the Mantel-Haenszel method, and arguably the Peto method, is invalid. Therefore this is not displayed in the output for either of these methods.
Remarks on labbe
By default the size of the plotting symbol is proportional to the sample size of the study. If weights are specified the plotting size will be proportional to the weight variable. Note that labbe has now been updated to version 8 graphics. All options work the same as in the previous version, and some minor graphics options have been added.
By default, metan adds the following new variables to the data set:
_ES Effect size (ES) _seES Standard error of ES or, when OR or RR are specfied: _selogES the standard error of its logarithm _LCI Lower confidence limit for ES _UCI Upper confidence limit for ES _WT Study percentage weight _SS Study sample size
All examples use a simulated example dataset (Ross Harris 2006)
. use http://fmwww.bc.edu/repec/bocode/m/metan_example_data
Risk difference from raw cell counts, random effects model, "label" specification with counts displayed
. metan tdeath tnodeath cdeath cnodeath, rd random label(namevar=id, yearid=year) counts (click to run)
Sort by year, use data columns syntax. Text size increased, specify percentage of graph as text and two lines per study; suppress stats, weight, heterogeneity stats and table.
. metan tdeath tnodeath cdeath cnodeath, sortby(year) lcols(id year country) rcols (population) textsize(110) astext(60) double nostats nowt nohet notable (click to run)
Analyse continuous data (6 parameter syntax), stratify by type of study, with weights summing to 100 within sub group, second analysis specified, display random effects distribution, show raw data counts, display "favours treatment vs. favours control" labels
. metan tsample tmean tsd csample cmean csd, by(type_study) sgweight fixed second(random) rfdist counts label(namevar = id) favours(Treatment reduces blood pressure # Treatment increases blood pressure) (click to run)
Generate log odds ratio and standard error, analyse with 2 parameter syntax. Graph has exponential form, scale is forced within set limits and ticks added, effect label specified.
. gen logor = ln( (tdeath*cnodeath)/(tnodeath*cdeath) )
. gen selogor = sqrt( (1/tdeath) + (1/tnodeath) + (1/cdeath) + (1/cnodeath) )
. metan logor selogor, eform xlabel(0.5, 1, 1.5, 2, 2.5) force xtick(0.75, 1.25, 1.75, 2.25) effect(Odds ratio) (click to run)
Display diagnostic test data with 3 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) xlabel(0,10,20,30,40,50,60,70,80,90,100) force null(50) label(namevar=id) nooverall notable 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.
. metan OR ORlci ORuci, wgt(bweight) first(0.924 0.753 1.095 Bayesian) firststats(param V=3.86, p=0.012) label(namevar=id) xlabel(0.25, 0.5, 1, 2, 4) force null(1) aspect(1.2) scheme(economist) (click to run)
Variable "counts" defined showing raw data. Options to change the box, effect estimate marker and confidence interval 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 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)
Michael J Bradburn, Jonathan J Deeks, Douglas G Altman. Centre for Statistics in Medicine, University of Oxford, Wolfson College Annexe, Linton Road, Oxford, OX2 6UD, UK
Version 9 update
Ross J Harris (firstname.lastname@example.org), Roger M Harbord, Jonathan A C Sterne. Department of Social Medicine, University of Bristol, Canynge Hall, Whiteladies Road, Bristol BS8 2PR, UK
Other updates and improvements to code and help file
Patrick Royston. MRC Clinical Trials Unit, 222 Euston Road, London, NW1 2DA
Thanks to Vince Wiggins, Kit Baum and Jeff Pitblado of Statacorp who offered advice and helped facilitate the version 9 update. Thanks also to all the people who helped with beta-testing and made comments and suggested improvements.
Higgins JPT, Thompson SG, Deeks JJ, Altman DG. Measuring inconsistency in meta-analyses. BMJ 2003; 327:557-560. http://dx.doi.org/10.1136/bmj.327.7414.557
Higgins JPT, Thompson SG (2006) Presenting random effects meta-analyses: where we are going wrong? (from presentation, work in preparation)
STB: STB-44 sbe24 On-line: help for metan7, metannt meta (if installed), metacum (if installed), metareg (if installed), metabias (if installed), metatrim (if installed), metainf (if installed), galbr (if installed), metafunnel (if installed)