help metareg                                                   (SJ8-4: sbe23_1)


metareg -- Meta-analysis regression (revised)


metareg depvar [indepvars] [if] [in] wsse(varname) [, eform graph randomsize noconstant mm reml eb knapphartung z tau2test level(#) permute(# [, univariable detail joint(varlist1 [| varlist2 ...])]) log maximize_options]

by can be used with metareg; see [D] by.


metareg performs random-effects meta-regression using aggregate-level data.

From a more abstract perspective, it extends vwls by estimating an extra additive component of variance tau2:

y_i = a + B*x_i + u_i + e_i

where a is a constant, u_i is a normal error term with known standard deviations wsse_i that may vary across units, and e_i is a normal error with variance tau2 to be estimated, assumed equal across units. This is a similar model to those fit by the xt commands, except that the within-unit data have been summarized by an effect estimate and its standard error for each unit i.


wsse(varname) specifies the variable containing the standard error of depvar within each study (within-study standard error). All values of varname must be greater than zero. wsse() is required.

eform indicates to output the exponentiated form of the coefficients and to suppress reporting of the constant. This option may be useful when depvar is the logarithm of a ratio measure, such as a log odds-ratio or a log risk-ratio.

graph requests a line graph of fitted values plotted against the first covariate in indepvars, together with the estimates from each study represented by circles. By default, the circle sizes depend on the precision of each estimate (the inverse of its within-study variance), which is the weight given to each study in the fixed-effects model.

randomsize is for use with the graph option. It specifies that the size of the circles will depend on the weights in the random-effects model rather than the precision of each estimate. These random-effects weights depend on the estimate of tau2.

The remaining options will mainly be of interest to more advanced users:

noconstant suppresses the constant term (intercept). This is rarely appropriate in meta-regression.

The mm, reml, and eb options are alternatives that specify the method of estimation of the additive (between-study) component of variance tau2.

mm specifies the use of method of moments to estimate the additive (between-study) component of variance tau2; this is a generalization of the DerSimonian and Laird (1986) method commonly used for random-effects meta-analysis. For speed, this is the default when the permute() option is specified, because it is the only noniterative method.

reml specifies the use of residual maximum likelihood (REML) to estimate the additive (between-study) component of variance tau2. This is the default unless the permute() option is specified. This revised version uses Stata's maximum likelihood facilities to maximize the REML log likelihood. It will therefore not give identical results to the previous version of metareg, which used an approximate iterative method.

eb specifies the use of the "empirical Bayes" method to estimate tau2 (Morris 1983).

knapphartung makes a modification to the variance of the estimated coefficients suggested by Knapp and Hartung (2003), accompanied by the use of a t distribution in place of the standard normal distribution when calculating p-values and confidence intervals. This is the default unless the permute() option is specified.

z requests that the knapphartung modification not be applied and that the standard normal distribution be used to calculate p-values and confidence intervals. This is the default when the permute() option is specified with a fixed-effects model.

tau2test adds to the output two tests of tau2 = 0. The first is based on the residual heterogeneity statistic, Q_res. The second (not available if the mm option is also specified) is a likelihood-ratio test based on the REML log likelihood. These are two tests of the same null hypothesis (the fixed-effects model with tau2 = 0), but the alternative hypotheses are different, as are the distributions of the test statistics under the null, so close agreement of the two tests is not guaranteed. Both tests are typically of little interest because it is more helpful to quantify heterogeneity than to test for it.

level(#) specifies the confidence level, as a percentage, for confidence intervals. The default is level(95) or as set by set level.

permute(...) calculates p-values by using a Monte Carlo permutation test. See Option for permutation test for more information about the option.

log requests the display of the iteration log during estimation of tau2. This is ignored if the mm option is specified, because this uses a noniterative method.

maximize_options are ignored unless estimation of tau2 is by REML. These options control the maximization process; see maximize. You should never need to specify them; they are supported only in case problems in the REML estimation of tau2 are ever reported or suspected.

Option for permutation test

The permute() option calculates p-values by using a Monte Carlo permutation test, as recommended by Higgins and Thompson (2004). To address multiple testing, permute() also calculates p-values for the most- to least-significant covariates, as the same authors also recommend.

The syntax of permute() is

permute(# [, univariable detail joint(varlist1 [| varlist2 ...])])

where # is required and specifies the number of random permutations to perform. Larger values give more precise p-values but take longer.

There are three suboptions:

univariable indicates that p-values should be calculated for a series of single covariate meta-regressions of each covariate in varlist separately, instead of a multiple meta-regression of all covariates in varlist simultaneously.

detail requests more detailed output in the style given by permute.

joint(varlist1 [| varlist2 ...]) specifies that a permutation p-value should also be computed for a joint test of the variables in each varlist.

The eform, level(), and z options have no effect when the permute() option is specified.

Syntax of predict

The syntax of predict following metareg is

predict [type] newvar [if] [in] [, statistic]

where statistic is

xb fitted values; the default stdp standard error of the prediction stdf standard error of the forecast u predicted random effects ustandard standardized predicted random effects xbu prediction including random effects stdxbu standard error of xbu hat leverage (diagonal elements of hat matrix)

These statistics are available both in and out of sample; type predict ... if e(sample) ... if wanted only for the estimation sample.

Options for predict

xb, the default, calculates the linear prediction, x_i*b, that is, the fitted values excluding the random effects.

stdp calculates the standard error of the prediction (the standard error of the fitted values excluding the random effects).

stdf calculates the standard error of the forecast. This gives the standard deviation of the predicted distribution of the true value of depvar in a future study, with the covariates given by varlist. stdf^2 = stdp^2 + tau2.

u calculates the predicted random effects, u_i. These are the best linear unbiased predictions of the random effects, also known as the empirical Bayes (or posterior mean) estimates of the random effects, or as shrunken residuals.

ustandard calculates the standardized predicted random effects, i.e., the predicted random effects, u_i, divided by their (unconditional) standard errors. These may be useful for diagnostics and model checking.

xbu calculates the prediction including random effects, a + B*x_i + u_i, also known as the empirical Bayes estimates of the effects for each study.

stdxbu calculates the standard error of the prediction including random effects.

hat calculates the leverages (the diagonal elements of the projection hat matrix).

Saved results

When the permute() option is not specified, metareg saves the following in e():

Scalars e(N) number of observations e(df_m) model degrees of freedom e(df_Q) degrees of freedom for test of Q=0 e(df_r) residual degrees of freedom (if t tests used) e(remll) REML log likelihood e(chi2_c) chi^2 for comparison test e(F) model F statistic e(tau2) estimate of tau2 e(Q) Cochran's Q e(I2) I-squared e(q_KH) Knapp-Hartung variance modification factor e(remll_c) REML log likelihood, comparison model e(tau2_0) tau2, constant-only model e(chi2) model chi^2

Macros e(cmd) metareg e(predict) program used to implement predict e(wsse) name of wsse() variable e(depvar) name of dependent variable e(method) REML, Method of moments, or Empirical Bayes e(properties) b V

Matrices e(b) coefficient vector e(V) variance-covariance matrix of estimators

Functions e(sample) marks estimation sample


. metareg logrr latitude, wsse(selogrr) eform

. metareg logrr latitude, wsse(selogrr) graph

. metareg smd abstract duration itt, wsse(sesmd) permute(10000)

. metareg smd abstract duration itt, wsse(sesmd) permute(1000, univariable)

. xi: metareg logor, wsse(selogor) permute(1000, joint(


metareg is programmed as a Stata estimation command and so supports many of the commands listed under estcom and postest (except when the permute() option is used). One deliberate exception is lrtest, which is not appropriate after metareg (because the REML log likelihood cannot be used to compare models with different fixed effects, while the method of moments is not based on a likelihood). For this reason, when the REML method is used, the iteration log showing the log likelihood is suppressed by default; specify the log option if you wish to see it.


DerSimonian, R., and N. Laird. 1986. Meta analysis in clinical trials. Controlled Clinical Trials 7: 177-188.

Higgins, J. P. T, and S. G. Thompson. 2004. Controlling the risk of spurious findings from meta-regression. Statistics in Medicine 23: 1663-1682.

Knapp, G., and J. Hartung. 2003. Improved tests for a random effects meta-regression with a single covariate. Statistics in Medicine 22: 2693-2710.

Morris, C. N. 1983. Parametric empirical Bayes inference: Theory and applications. Journal of the American Statistical Association 78: 47-55.

Sharp, S. 1998. sbe23: Meta-analysis regression. Stata Technical Bulletin 42: 16-22. Reprinted in Stata Technical Bulletin Reprints, vol. 7, pp. 148-155. College Station, TX: Stata Press.


Roger M. Harbord Department of Social Medicine University of Bristol, UK


This is a substantial revision of the original version of metareg written by Stephen Sharp (1998), who gave his permission to release this version under the same name and to incorporate his code. Julian Higgins gave advice on the permutation test. Aijing Shang tested early versions and made helpful suggestions. Portions of the new code borrow ideas from official Stata commands such as nbreg, and I thank StataCorp for making such code visible to the user.

A dialog box, written by Thomas J. Steichen, is available for the original version of the metareg command.

Also see

Article: Stata Journal, volume 8, number 4: sbe23_1, Stata Technical Bulletin 42: sbe23

Manual: [R] meta, [R] permute

Online: [R] vwls, [R] permute, meta (if installed), metan (if installed), meta_dialog (if installed)