rma.uni {metafor} | R Documentation |
Function to fit the meta-analytic fixed- and random-effects models with or without moderators via the general linear (mixed-effects) model. See the documentation of the metafor-package for more details on these models.
rma.uni(yi, vi, sei, ai, bi, ci, di, n1i, n2i, m1i, m2i, sd1i, sd2i, xi, mi, ri, ni, mods=NULL, data=NULL, intercept=TRUE, slab=NULL, subset=NULL, measure="GEN", add=1/2, to="only0", vtype="LS", method="REML", weighted=TRUE, level=95, digits=4, btt=NULL, tau2=NULL, knha=FALSE, control=list()) rma(yi, vi, sei, ai, bi, ci, di, n1i, n2i, m1i, m2i, sd1i, sd2i, xi, mi, ri, ni, mods=NULL, data=NULL, intercept=TRUE, slab=NULL, subset=NULL, measure="GEN", add=1/2, to="only0", vtype="LS", method="REML", weighted=TRUE, level=95, digits=4, btt=NULL, tau2=NULL, knha=FALSE, control=list())
yi |
vector of length k with the observed effects sizes or outcomes. See ‘Details’. |
vi |
vector of length k with the corresponding sampling variances. See ‘Details’. |
sei |
vector of length k with the corresponding standard errors. See ‘Details’. |
ai |
see below and the documentation of the escalc function for more details. |
bi |
see below and the documentation of the escalc function for more details. |
ci |
see below and the documentation of the escalc function for more details. |
di |
see below and the documentation of the escalc function for more details. |
n1i |
see below and the documentation of the escalc function for more details. |
n2i |
see below and the documentation of the escalc function for more details. |
m1i |
see below and the documentation of the escalc function for more details. |
m2i |
see below and the documentation of the escalc function for more details. |
sd1i |
see below and the documentation of the escalc function for more details. |
sd2i |
see below and the documentation of the escalc function for more details. |
xi |
see below and the documentation of the escalc function for more details. |
mi |
see below and the documentation of the escalc function for more details. |
ri |
see below and the documentation of the escalc function for more details. |
ni |
see below and the documentation of the escalc function for more details. |
mods |
an optional argument to include one or more moderators in the model. A single moderator can be given as a vector of length k specifying the values of the moderator. Multiple moderators are specified by giving a matrix with k rows and p' columns. |
data |
an optional data frame containing the variables given to the arguments above. |
intercept |
logical, indicating whether an intercept term should be added to the model (default is TRUE ). |
slab |
an optional vector with unique labels for the k studies. |
subset |
an optional vector indicating the subset of studies that should be used for the analysis. This can be a logical vector of length k or a numeric vector indicating the indices of the observations to include. |
measure |
a character string indicating the type of data supplied to the function. When measure="GEN" (default), the observed effect sizes or outcomes and corresponding sampling variances (or standard errors) should be supplied to the function via the yi , vi , and sei arguments (only one of the two, vi or sei , needs to be specified). Alternatively, one can set measure to one of the effect size or outcome measures described under the documentation for the escalc function and supply the needed data via the appropriate arguments. |
add |
see the documentation of the escalc function. |
to |
see the documentation of the escalc function. |
vtype |
see the documentation of the escalc function. |
method |
a character string specifying whether a fixed- or a random/mixed-effects model should be fitted. A fixed-effects model (with or without moderators) is fitted when using method="FE" . Random/mixed-effects models are fitted by setting method equal to one of the following: "HE" , "DL" , "SJ" , "ML" , "REML" , or "EB" . Default is "REML" . See ‘Details’. |
weighted |
logical indicating whether weighted (default) or unweighted least squares should be used to fit the model. |
level |
a numerical value between 0 and 100 specifying the confidence interval level (default is 95). |
digits |
an integer specifying the number of decimal places to which the printed results should be rounded (default is 4). |
btt |
an optional vector of indices specifying which coefficients to include in the omnibus test of moderators. See ‘Details’. |
tau2 |
an optional numerical value to specify the amount of (residual) heterogeneity in a random- or mixed-effects model (instead of estimating it). Useful for sensitivity analyses (e.g., for plotting results as a function of tau^2). |
knha |
logical specifying whether the method by Knapp and Hartung (2003) should be used for adjusting test statistics and confidence intervals (default is FALSE ). See ‘Details’. |
control |
optional list of control values for the iterative estimation algorithms. Defaults to an empty list, which means that default values are defined inside the function. See ‘Note’. |
Specifying the Data
The function can be used in conjunction with any of the usual effect size or outcome measures used in meta-analyses (e.g., log odds ratios, log risk ratios, risk differences, mean differences, standardized mean differences, raw correlation coefficients, correlation coefficients transformed with Fisher's r-to-z transformation, and so on). Simply supply the observed outcomes via the yi
argument and the corresponding sampling variances via the vi
argument (or supply the standard errors, the square root of sampling variances, via the sei
argument). In this case, one should set measure="GEN"
(the default).
Alternatively, the function can automatically calculate many effect size or outcome measures (and the corresponding sampling variances) when supplied with the needed data. The escalc
function describes which measures are currently implemented and what data/arguments should then be specified. The measure
argument should then be set to the desired measure.
Specifying the Model
Assuming the observed outcomes and corresponding sampling variances are supplied via yi
and vi
, the fixed-effects model is fitted with rma(yi, vi, method="FE")
. The random-effects model is fitted with the same code but setting method
to one of the various estimators for the amount of heterogeneity:
method="HS"
= Hunter-Schmidt estimator
method="HE"
= Hedges estimator
method="DL"
= DerSimonian-Laird estimator
method="SJ"
= Sidik-Jonkman estimator
method="ML"
= maximum-likelihood estimator
method="REML"
= restricted maximum-likelihood estimator
method="EB"
= empirical Bayes estimator.
One or more moderators can be included in these models via the mods
argument. A single moderator can be given as a (row or column) vector of length k specifying the values of the moderator. Multiple moderators are specified by giving a matrix with k rows and p' columns (e.g., using mods = cbind(mod1, mod2, mod3)
, where mod1
, mod2
, mod3
correspond to the names of the variables for the three moderator variables). A fixed-effects with moderators model is then fitted by setting method="FE"
, while a mixed-effects model is fitted by specifying one of the estimators for the amount of (residual) heterogeneity given earlier. The intercept is automatically included in the model, unless intercept=FALSE
is used.
Omnibus Test of Parameters
In models with more than one independent variable, an omnibus test of all the regression coefficients is conducted that excludes the intercept (the first coefficient) if the option intercept=TRUE
is used (which is the default). If intercept=FALSE
, then the omnibus test includes all of the coefficients in the model. Alternatively, one can specify the indices of the coefficients to test via the btt
argument. For example, use btt=c(3,4)
to only include the third and fourth coefficient from the model in the test.
Categorical Moderators
Categorical moderator variables can be included in the model in the same way that appropriately (dummy) coded categorical independent variables can be included in linear models. You have to do the dummy coding yourself or use the model.matrix
function to do the coding for you. An example is shown below.
Knapp & Hartung Adjustment
By default, the test statistics of the individual coefficients in the model (and the corresponding confidence intervals) are based on the normal distribution, while the omnibus test is based on a chi-square distribution with m degrees of freedom (m being the number of coefficients tested). The Knapp and Hartung (2003) method (knha=TRUE
) is an adjustment to the standard errors of the estimated coefficients, which helps to account for the uncertainty in the estimate of the amount of (residual) heterogeneity and leads to different reference distributions. Individual coefficients and confidence intervals are then based on the t-distribution with k-p degrees of freedom (p being the total number of coefficients in the model), while the omnibus test statistic then uses an F-distribution with m and k-p degrees of freedom. The Knapp and Hartung (2003) method is only meant to be used in the context of random- or mixed-effects models.
An object of class c("rma.uni", "rma")
. The object is a list containing the following components:
b |
estimated coefficients of the model. |
se |
standard errors of the coefficients. |
zval |
test statistics of the coefficients. |
pval |
p-values for the test statistics. |
ci.lb |
lower bound of the confidence intervals for the coefficients. |
ci.ub |
upper bound of the confidence intervals for the coefficients. |
vb |
variance-covariance matrix of the estimated coefficients. |
tau2 |
estimated amount of (residual) heterogeneity. Always 0 when method="FE" . |
se.tau2 |
estimated standard error of the estimated amount of (residual) heterogeneity when using ML or REML estimation (NA otherwise). |
k |
number of outcomes included in the model fitting (equal to length(yi) unless subset was used or if there are missing data). |
p |
number of coefficients in the model (including the intercept). |
m |
number of coefficients included in the omnibus test of coefficients. |
QE |
test statistic for the test of (residual) heterogeneity. |
QEp |
p-value for the test of (residual) heterogeneity. |
QM |
test statistic for the omnibus test of coefficients. |
QMp |
p-value for the omnibus test of coefficients. |
I2 |
value of I^2 (only for the random-effects model; NA otherwise). |
H2 |
value of H^2 (only for the random-effects model; NA otherwise). |
int.only |
logical that indicates whether the model only includes an intercept. |
yi, vi, X |
the vector of outcomes, the corresponding sampling variances, and the design matrix of the model. |
fit.stats |
a list with the log likelihood, deviance, AIC, and BIC values under the unrestricted and restricted likelihood. |
... |
some additional elements/values. |
The results of the fitted model are neatly formated and printed with the print.rma.uni
function. If you also want the fit statistics, use summary.rma
(or use the fitstats.rma
function to extract them). Full versus reduced model comparisons in terms of fit statistics and likelihoods can be obtained with anova.rma.uni
.
Predicted/fitted values can be obtained with predict.rma.uni
and fitted.rma
. For best linear unbiased predictions, see blup.rma.uni
.
The residuals.rma
, rstandard.rma.uni
, and rstudent.rma.uni
functions extract raw and standardized residuals. Additional case diagnostics (e.g., to determine influential studies) can be obtained with the influence.rma.uni
function. For models without moderators, leave-one-out diagnostics can also be obtained with leave1out.rma.uni
.
A confidence interval for the amount of (residual) heterogeneity in the random/mixed-effects model can be obtained with cint.rma.uni
.
Forest, funnel, and radial plots (the latter only for models without moderators) are drawn with forest.rma
, funnel.rma
, and radial.rma
. The qqnorm.rma.uni
function provides a normal QQ plot of the standardized residuals. One can also just call plot.rma.uni
on the fitted model object to obtain various plots at once.
Tests for publication bias (or more accurately, for funnel plot asymmetry) can be obtained with ranktest.rma
and regtest.rma
.
For models without moderators, a cumulative meta-analysis (i.e., adding one obervation at a time) can be obtained with cumul.rma.uni
.
Other assessor functions include coef.rma
, vcov.rma
, logLik.rma
, and hatvalues.rma.uni
.
The ML, REML, and EB estimators of tau^2 are obtained via the Fisher scoring algorithm, which is robust to poor starting values and usually converges quickly (Harville, 1977; Jennrich & Sampson, 1976). By default, the starting value is set equal to the value of the Hedges estimator and the algorithm terminates when the change in the estimated value of tau^2 is smaller than 10^(-5) from one iteration to the next. The maximum number of iterations is 50 by default. A different starting value, threshold, and maximum number of iterations can be specified via the control
argument by setting control=list(tau2.init=value, threshold=value, maxiter=value)
. Information on the evolution of the algorithm is obtained with control=list(verbose=TRUE)
.
All of the heterogeneity estimators except SJ can in principle yield negative estimates for the amount of (residual) heterogeneity. However, negative estimates of tau^2 are outside of the parameter space. For the HS, HE, and DL estimators, negative estimates are therefore truncated to zero. For ML, REML, and EB estimation, the Fisher scoring algorithm makes use of step halving to guarantee a non-negative estimate. For those brave enough to step into risky territory, there is the option to set the lower bound of tau^2 equal to some other value besides zero with control=list(tau2.min=value)
.
The Hunter-Schmidt estimator for the amount of heterogeneity is defined in Hunter and Schmidt (1990) only in the context of the random-effects model when analyzing correlation coefficients. A general version of this estimator for the random-effects model not specific to any particular outcome measure is described in Viechtbauer (2005). The same idea can be easily extended to the mixed-effects model and is implemented here.
Outcomes with non-positive sampling variances are problematic. If a sampling variance is equal to zero, then its weight will be 1/0 for fixed-effects models when using weighted estimation. Switching to unweighted estimation is a possible solution then. For random/mixed-effects model, some estimators of tau^2 are undefined when there is at least one sampling variance equal to zero. Other estimators may work, but it may still be necessary to switch to unweighted model fitting, especially when the estimate of tau^2 turns out to be zero.
If you get a ‘singular matrix’ error when using the function, then this means that there is a linear relationship between the moderator variables included in the model. For example, two moderators that correlated perfectly would cause this error. Deleting (redundant) moderator variables from the model as needed should solve this problem.
Finally, some general words of caution about the assumptions underlying the models are warranted:
vi
values) are treated as if they were known constants. This (usually) implies that the distributions of the test statistics and corresponding confidence intervals are only exact and have nominal coverage when the within-study sample sizes are large (i.e., when the error in the sampling variance estimates is small). Certain outcome measures (e.g., the arc-sine transformed risk difference and Fisher's r-to-z transformed correlation coefficient) are based on variance stabilizing transformations that also help to make the assumption of known sampling variances much more reasonable.
Wolfgang Viechtbauer; wvb@www.wvbauer.com; http://www.wvbauer.com/
DerSimonian, R. & Laird, N. (1986) Meta-analysis in clinical trials. Controlled Clinical Trials, 7, 177–188.
Harville, D. A. (1977) Maximum likelihood approaches to variance component estimation and to related problems. Journal of the American Statistical Association, 72, 320–338.
Hedges, L. V. (1983) A random effects model for effect sizes. Psychological Bulletin, 93, 388–395.
Hedges, L. V. & Olkin, I. (1985) Statistical methods for meta-analysis. San Diego, CA: Academic Press.
Hunter, J. E. & Schmidt, F. L. (1990). Methods of meta-analysis: Correcting error and bias in research findings. Newbury Park, CA: Sage.
Jennrich, R. I. & Sampson, P. F. (1976) Newton-Raphson and related algorithms for maximum likelihood variance component estimation. Technometrics, 18, 11–17.
Knapp, G. & Hartung, J. (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 (with discussion). Journal of the American Statistical Association, 78, 47–65.
Raudenbush, S. W. (1994) Random effects models. In H. C. Cooper & L. V. Hedges (Eds.), The handbook of research synthesis (pp. 301–321). New York: Russell Sage Foundation.
Sidik, K. & Jonkman, J. N. (2005a) A note on variance estimation in random effects meta-regression. Journal of Biopharmaceutical Statistics, 15, 823–838.
Sidik, K. & Jonkman, J. N. (2005b) Simple heterogeneity variance estimation for meta-analysis. Journal of the Royal Statistical Society, Series C, 54, 367–384.
Viechtbauer, W. (2005) Bias and efficiency of meta-analytic variance estimators in the random-effects model. Journal of Educational and Behavioral Statistics, 30, 261–293.
### load BCG vaccine data data(dat.bcg) ### calculate log risk ratios and corresponding sampling variances dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg) dat <- cbind(dat.bcg, dat) ### random-effects model rma(yi, vi, data=dat, method="REML") ### mixed-effects model with two moderators (absolute latitude and publication year) rma(yi, vi, mods=cbind(ablat, year), data=dat, method="REML") ### supplying the raw data directly to the function rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, mods=cbind(ablat, year), data=dat, measure="RR", method="REML") ### dummy coding of the allocation factor alloc.random <- ifelse(dat$alloc == "random", 1, 0) alloc.alternate <- ifelse(dat$alloc == "alternate", 1, 0) alloc.systematic <- ifelse(dat$alloc == "systematic", 1, 0) ### test the allocation factor (in the presence of the other moderators) ### note: "alternate" is the reference level of the allocation factor ### note: the intercept is the first coefficient, so btt=c(2,3) rma(yi, vi, mods=cbind(alloc.random, alloc.systematic, year, ablat), data=dat, method="REML", btt=c(2,3)) ### use model.matrix() to code the factor and set up the design matrix ### careful: X already includes the intercept, so need to use intercept=FALSE X <- model.matrix(~ factor(alloc) + year + ablat, data=dat) rma(yi, vi, mods=X, intercept=FALSE, data=dat, method="REML", btt=c(2,3))