[R] metafor random effects meta-analysis

Viechtbauer Wolfgang (STAT) Wolfgang.Viechtbauer at stat.unimaas.nl
Thu Aug 13 17:32:05 CEST 2009

Correct, it is not possible to fix the residual variance to 1 in the R version of lme(), which is what one (typically) wants to do in meta-analyses, where the sampling variances are assumed to be (approximately) known. This is however possible in S-Plus, if you have access to that. Adding:

control=lmeControl(sigma = 1)

to the lme() call will do the trick.

If that is not an option, then metafor will also not be a solution currently. The model you have in mind is more complicated than the one assumed by the rma.uni() function.

Let me see if I correctly understand the model. Let es_ij be the observed effect size for the ith species in the jth study. Take the example:

es_11 = mu + u_1 + v_1 + e_11
es_21 = mu + u_2 + v_1 + e_21
es_31 = mu + u_3 + v_1 + e_31
es_22 = mu + u_2 + v_2 + e_22
es_13 = mu + u_1 + v_3 + e_13
es_33 = mu + u_3 + v_3 + e_33
es_14 = mu + u_1 + v_4 + e_14

so, if I understand things correctly, you want a random effect for the species (the u's) and you want a random effect for studies (the v's) and the u's and v's are uncorrelated (and also uncorrelated with the e's). Moreover, the same u's (e.g., u_1) from different studies are also uncorrelated. So, the marginal variance-covariance matrix of the first study would look like this:

tau^2_u + tau^2_v + s^2_11  tau^2_v                     tau^2_v
tau^2_v                     tau^2_u + tau^2_v + s^2_21  tau^2_v
tau^2_v                     tau^2_v                     tau^2_u + tau^2_v + s^31

where s^2_11, s^2_21, and s^2_31 are the (approximately) known sampling variances.

If that is the model you have in mind (please correct me if I didn't get it right), then I can at least say that I am working on functions for the metafor package that will allow you to fit such a model in the future. The name rma.uni() (uni for univariate) hints at the fact that there will be something called rma.mv() (mv for multivariate) in a later version of the package. Essentially, the multivariate model allows two sets of random effects (plus the sampling errors), which covers the model you have in mind. These functions still need some extensive testing though before I will make them part of the package.


Wolfgang Viechtbauer
 Department of Methodology and Statistics
 School for Public Health and Primary Care
 University of Maastricht, The Netherlands

----Original Message----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Mark Urban Sent: Thursday, August 13, 2009 16:25
To: r-help at r-project.org
Subject: [R] metafor random effects meta-analysis

> Hello,
> Great to see the new metafor package for meta-analysis.
> I would like to perform a meta-analysis in which I initially calculate
> the intercept of the model with a nested random-effects structure. In
> lme, this would be
> model<- lme(v3~1, random=~1|species/study, weights = varFixed(~Wt),
> method = "REML")
> where multiple effects sizes are measured for some studies and more than
> one study exists for some species.  I would like to treat species as a
> random effect rather than a fixed effect if possible.  I understand that
> lme will not give me the correct weighted answer (something to do with
> not being able to fix the variances at the lowest level?) so that I
> should use metafor.
> However, I only see that metafor accepts moderators and I'm assuming that
> they are treated as non-nested fixed factors, if for example I used:
> x<-cbind(species,study)
> rma.uni(yi=v3,sei=vi,mods=x, method="REML")
> Am I correct in thinking that I cannot obtain the correct weighted random
> effects intercept using lme?
> How can I obtain a weighted purely random-effects model with nested
> factors using metafor or have I misinterpreted something from the metafor
> manual?
> Thanks,
> Mark

More information about the R-help mailing list