The metafor Package

A Meta-Analysis Package for R

User Tools

Site Tools


tips:weights_in_rma.mv_models

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
tips:weights_in_rma.mv_models [2021/04/16 07:46] Wolfgang Viechtbauertips:weights_in_rma.mv_models [2021/11/08 15:16] Wolfgang Viechtbauer
Line 11: Line 11:
 dat <- dat.bcg dat <- dat.bcg
 dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat, dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat,
-              slab=paste0(dat$author, ", ", dat$year))+              slab=paste0(author, ", ", year))
 dat dat
 </code> </code>
Line 36: Line 36:
  
 <code rsplus> <code rsplus>
-res.fe <- rma(yi, vi, data=dat, method="FE")+res.ee <- rma(yi, vi, data=dat, method="EE")
 res.re <- rma(yi, vi, data=dat) res.re <- rma(yi, vi, data=dat)
 </code> </code>
Line 43: Line 43:
  
 <code rsplus> <code rsplus>
-w.fe.re <- cbind( +w.ee.re <- cbind( 
-paste0(formatC(weights(res.fe), format="f", digits=1, width=4), "%"),+paste0(formatC(weights(res.ee), format="f", digits=1, width=4), "%"),
 paste0(formatC(weights(res.re), format="f", digits=1, width=4), "%")) paste0(formatC(weights(res.re), format="f", digits=1, width=4), "%"))
 </code> </code>
Line 52: Line 52:
 <code rsplus> <code rsplus>
 forest(dat$yi, dat$vi, xlim=c(-11,5), ylim=c(-2.5, 16), header=TRUE, atransf=exp, forest(dat$yi, dat$vi, xlim=c(-11,5), ylim=c(-2.5, 16), header=TRUE, atransf=exp,
-       at=log(c(1/16, 1/4, 1, 4, 8)), digits=c(2L,4L), ilab=w.fe.re, ilab.xpos=c(-6,-4))+       at=log(c(1/16, 1/4, 1, 4, 8)), digits=c(2L,4L), ilab=w.ee.re, ilab.xpos=c(-6,-4))
 abline(h=0) abline(h=0)
-addpoly(res.fe, row=-1, atransf=exp)+addpoly(res.ee, row=-1, atransf=exp)
 addpoly(res.re, row=-2, atransf=exp) addpoly(res.re, row=-2, atransf=exp)
-text(-6, 15, "FE Model", font=2)+text(-6, 15, "EE Model", font=2)
 text(-4, 15, "RE Model", font=2) text(-4, 15, "RE Model", font=2)
 text(-5, 16, "Weights", font=2) text(-5, 16, "Weights", font=2)
Line 68: Line 68:
 In the RE model, the estimates are weighted with $w_i = 1 / (\hat{\tau}^2 + v_i)$. Therefore, not only the sampling variance, but also the (estimated) amount of heterogeneity (i.e., the variance in the underlying true effects) is taken into consideration when determining the weights. When $\hat{\tau}^2$ is large (relative to the size of the sampling variances), then the weights actually become quite similar to each other. Hence, smaller (less precise) studies may receive almost as much as weight as larger (more precise) studies. We can in fact see this happening in the present example. While the three studies mentioned above still receive the largest weights, their weights are now much more similar to those of the other studies. As a result, the summary estimate is not as strongly pulled to the right by the TPT Madras study. In the RE model, the estimates are weighted with $w_i = 1 / (\hat{\tau}^2 + v_i)$. Therefore, not only the sampling variance, but also the (estimated) amount of heterogeneity (i.e., the variance in the underlying true effects) is taken into consideration when determining the weights. When $\hat{\tau}^2$ is large (relative to the size of the sampling variances), then the weights actually become quite similar to each other. Hence, smaller (less precise) studies may receive almost as much as weight as larger (more precise) studies. We can in fact see this happening in the present example. While the three studies mentioned above still receive the largest weights, their weights are now much more similar to those of the other studies. As a result, the summary estimate is not as strongly pulled to the right by the TPT Madras study.
  
-The weights used in fixed- and random-effects models are the inverse of the model-implied variances of the observed outcomes. For example, in the RE model, the model considers two sources of variability that affect the observed outcomes: sampling variability ($v_i$) and heterogeneity ($\hat{\tau}^2$). The sum of these two sources of variability is $\hat{\tau}^2 + v_i$ and the weights are therefore $w_i = 1 / (\hat{\tau}^2 + v_i)$. The summary estimate is then simply the weighted average of the estimates, namely $$\hat{\mu} = \frac{\sum_{i=1}^k w_i y_i}{\sum_{i=1}^k w_i}.$$ By comparing+The weights used in equal- and random-effects models are the inverse of the model-implied variances of the observed outcomes. For example, in the RE model, the model considers two sources of variability that affect the observed outcomes: sampling variability ($v_i$) and heterogeneity ($\hat{\tau}^2$). The sum of these two sources of variability is $\hat{\tau}^2 + v_i$ and the weights are therefore $w_i = 1 / (\hat{\tau}^2 + v_i)$. The summary estimate is then simply the weighted average of the estimates, namely $$\hat{\mu} = \frac{\sum_{i=1}^k w_i y_i}{\sum_{i=1}^k w_i}.$$ By comparing
  
 <code rsplus> <code rsplus>
Line 271: Line 271:
 <code rsplus> <code rsplus>
 data.frame(k = c(table(dat$district)), data.frame(k = c(table(dat$district)),
-           weight = sapply(split(wi, dat$district), sum))+           weight = tapply(wi, dat$district, sum))
 </code> </code>
 <code output> <code output>
Line 294: Line 294:
 ==== Conclusions ==== ==== Conclusions ====
  
-The example above shows that the weighting scheme underlying more complex models (that can be fitted with the ''rma.mv()'' function) is not as simple as in the 'standard' fixed- and random-effects models (that can be fitted with the ''rma()'' function). Depending on the random effects included in the model (and the var-cov matrix of the sampling errors), the model may imply a certain degree of covariance between the estimates, which needs to be taken into consideration when estimating the fixed effects (e.g., the pooled/summary estimate) and their corresponding standard errors.+The example above shows that the weighting scheme underlying more complex models (that can be fitted with the ''rma.mv()'' function) is not as simple as in the 'standard' equal- and random-effects models (that can be fitted with the ''rma()'' function). Depending on the random effects included in the model (and the var-cov matrix of the sampling errors), the model may imply a certain degree of covariance between the estimates, which needs to be taken into consideration when estimating the fixed effects (e.g., the pooled/summary estimate) and their corresponding standard errors.
  
 **Note:** James Pustejovsky has written up a very nice [[https://www.jepusto.com/weighting-in-multivariate-meta-analysis/|blog post]] which goes even deeper into this topic. **Note:** James Pustejovsky has written up a very nice [[https://www.jepusto.com/weighting-in-multivariate-meta-analysis/|blog post]] which goes even deeper into this topic.
tips/weights_in_rma.mv_models.txt · Last modified: 2023/08/03 13:37 by Wolfgang Viechtbauer