The metafor Package

A Meta-Analysis Package for R

User Tools

Site Tools


tips:i2_multilevel_multivariate

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:i2_multilevel_multivariate [2021/01/06 10:58] – [General Equation for I^2] Wolfgang Viechtbauertips:i2_multilevel_multivariate [2022/03/18 09:48] Wolfgang Viechtbauer
Line 1: Line 1:
-===== I^2 for Multilevel and Multivariate Models =====+===== $\boldsymbol{I^2}$ for Multilevel and Multivariate Models =====
  
 The $I^2$ statistic was introduced by Higgins and Thompson in their seminal 2002 paper and has become a rather popular statistic to report in meta-analyses, as it facilitates the interpretation of the amount of heterogeneity present in a given dataset.  The $I^2$ statistic was introduced by Higgins and Thompson in their seminal 2002 paper and has become a rather popular statistic to report in meta-analyses, as it facilitates the interpretation of the amount of heterogeneity present in a given dataset. 
Line 26: Line 26:
 <code rsplus> <code rsplus>
 k <- res$k k <- res$k
-wi <- 1/dat$vi+wi <- 1/res$vi
 vt <- (k-1) * sum(wi) / (sum(wi)^2 - sum(wi^2)) vt <- (k-1) * sum(wi) / (sum(wi)^2 - sum(wi^2))
 100 * res$tau2 / (res$tau2 + vt) 100 * res$tau2 / (res$tau2 + vt)
Line 34: Line 34:
 </code> </code>
  
-==== General Equation for $\boldsymbol{I}^2$ ====+==== General Equation for $\boldsymbol{I^2}$ ====
  
 Before we continue with more complex models, it is useful to point out a more general equation for computing $I^2,$ which also applies to models involving moderator variables (i.e., mixed-effects meta-regression models). This will also become important when dealing with models where sampling errors are no longer independent. So, let us define $$\mathbf{P} = \mathbf{W} - \mathbf{W} \mathbf{X} (\mathbf{X}' \mathbf{W} \mathbf{X})^{-1} \mathbf{X}' \mathbf{W},$$ where $\mathbf{W}$ is (for now) a diagonal matrix with the inverse sampling variances (i.e., $1/v_i$) along the diagonal and $\mathbf{X}$ is the model matrix. In the random-effects model, $\mathbf{X}$ is just a column vector with 1's, but in meta-regression models, it will contain additional columns with the values of the moderator variables. Then we define $$I^2 = 100\% \times \frac{\hat{\tau}^2}{\hat{\tau}^2 + \frac{k-p}{\mathrm{tr}[\mathbf{P}]}},$$ where $\mathrm{tr}[\mathbf{P}]$ denotes the trace of the $\mathbf{P}$ matrix (i.e., the sum of the diagonal elements) and $p$ denotes the number of columns in $\mathbf{X}$. Before we continue with more complex models, it is useful to point out a more general equation for computing $I^2,$ which also applies to models involving moderator variables (i.e., mixed-effects meta-regression models). This will also become important when dealing with models where sampling errors are no longer independent. So, let us define $$\mathbf{P} = \mathbf{W} - \mathbf{W} \mathbf{X} (\mathbf{X}' \mathbf{W} \mathbf{X})^{-1} \mathbf{X}' \mathbf{W},$$ where $\mathbf{W}$ is (for now) a diagonal matrix with the inverse sampling variances (i.e., $1/v_i$) along the diagonal and $\mathbf{X}$ is the model matrix. In the random-effects model, $\mathbf{X}$ is just a column vector with 1's, but in meta-regression models, it will contain additional columns with the values of the moderator variables. Then we define $$I^2 = 100\% \times \frac{\hat{\tau}^2}{\hat{\tau}^2 + \frac{k-p}{\mathrm{tr}[\mathbf{P}]}},$$ where $\mathrm{tr}[\mathbf{P}]$ denotes the trace of the $\mathbf{P}$ matrix (i.e., the sum of the diagonal elements) and $p$ denotes the number of columns in $\mathbf{X}$.
Line 40: Line 40:
 Let's try this out for the example above: Let's try this out for the example above:
 <code rsplus> <code rsplus>
-W <- diag(1/dat$vi)+W <- diag(1/res$vi)
 X <- model.matrix(res) X <- model.matrix(res)
 P <- W - W %*% X %*% solve(t(X) %*% W %*% X) %*% t(X) %*% W P <- W - W %*% X %*% solve(t(X) %*% W %*% X) %*% t(X) %*% W
Line 103: Line 103:
 Based on the discussion above, it is now very easy to generalize the concept of $I^2$ to such a model (see also Nakagawa & Santos, 2012). That is, we can first compute: Based on the discussion above, it is now very easy to generalize the concept of $I^2$ to such a model (see also Nakagawa & Santos, 2012). That is, we can first compute:
 <code rsplus> <code rsplus>
-W <- diag(1/dat$vi)+W <- diag(1/res$vi)
 X <- model.matrix(res) X <- model.matrix(res)
 P <- W - W %*% X %*% solve(t(X) %*% W %*% X) %*% t(X) %*% W P <- W - W %*% X %*% solve(t(X) %*% W %*% X) %*% t(X) %*% W
tips/i2_multilevel_multivariate.txt · Last modified: 2022/10/24 10:10 by Wolfgang Viechtbauer