tips:computing_adjusted_effects
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
tips:computing_adjusted_effects [2022/04/22 12:09] – Wolfgang Viechtbauer | tips:computing_adjusted_effects [2023/09/11 16:10] – Wolfgang Viechtbauer | ||
---|---|---|---|
Line 37: | Line 37: | ||
<code rsplus> | <code rsplus> | ||
- | res <- rma(yi, vi, data=dat) | + | res1 <- rma(yi, vi, data=dat) |
- | res | + | res1 |
</ | </ | ||
<code output> | <code output> | ||
Line 57: | Line 57: | ||
--- | --- | ||
- | Signif. codes: | + | Signif. codes: |
</ | </ | ||
- | To make the results easier to interpret, we can exponentiate the estimated average log risk ratio (i.e., $-0.7145$) to obtain an estimate of the average risk ratio. This can be done with the '' | + | To make the results easier to interpret, we can exponentiate the estimated average log risk ratio (i.e., $-0.7145$) to obtain an estimate of the average risk ratio.((Strictly speaking, since exponentiation is a non-linear transformation, |
<code rsplus> | <code rsplus> | ||
- | predict(res, transf=exp, digits=2) | + | predict(res1, transf=exp, digits=2) |
</ | </ | ||
<code output> | <code output> | ||
Line 75: | Line 75: | ||
<code rsplus> | <code rsplus> | ||
- | forest(res, xlim=c(-6.8, | + | forest(res1, xlim=c(-6.8, |
| | ||
</ | </ | ||
Line 86: | Line 86: | ||
<code rsplus> | <code rsplus> | ||
- | res <- rma(yi, vi, mods = ~ ablat, data=dat) | + | res2 <- rma(yi, vi, mods = ~ ablat, data=dat) |
- | res | + | res2 |
</ | </ | ||
<code output> | <code output> | ||
Line 111: | Line 111: | ||
--- | --- | ||
- | Signif. codes: | + | Signif. codes: |
</ | </ | ||
- | The results indeed suggest that the size of the average log risk ratio depends on absolute latitude. | + | The results indeed suggest that the size of the average log risk ratio is a function of the absolute latitude |
- | In such a meta-regression model, there is no longer | + | In such a meta-regression model, there is no longer |
<code rsplus> | <code rsplus> | ||
- | predict(res, newmods = mean(dat$ablat), | + | predict(res2, newmods = mean(dat$ablat), |
</ | </ | ||
<code output> | <code output> | ||
Line 131: | Line 131: | ||
<code rsplus> | <code rsplus> | ||
- | forest(res, xlim=c(-6.8, | + | forest(res2, xlim=c(-6.8, |
| | ||
- | | + | |
text(-3.5, 15, " | text(-3.5, 15, " | ||
abline(h=0) | abline(h=0) | ||
- | sav <- predict(res, newmods = mean(dat$ablat)) | + | sav1 <- predict(res1) |
- | addpoly(sav$pred, sei=sav$se, mlab=" | + | addpoly(sav1, |
+ | sav2 <- predict(res2, newmods = mean(dat$ablat)) | ||
+ | addpoly(sav2, row=-2, mlab="Meta-Regression Model (Adjusted Effect)") | ||
</ | </ | ||
- | In the forest plot, the values of the moderator are added as an extra column and the studies are ordered based on their absolute latitude value to make this clearer. Some extra space was also added to the forest plot to add the ' | + | In the forest plot, the values of the moderator are added as an extra column and the studies are ordered based on their absolute latitude value to make this clearer. Some extra space was also added to the forest plot to add the estimate from the standard random-effects model and the ' |
{{ tips: | {{ tips: | ||
Line 149: | Line 151: | ||
<code rsplus> | <code rsplus> | ||
- | res <- rma(yi, vi, mods = ~ alloc, data=dat) | + | res3 <- rma(yi, vi, mods = ~ alloc, data=dat) |
- | res | + | res3 |
</ | </ | ||
<code output> | <code output> | ||
Line 178: | Line 180: | ||
</ | </ | ||
- | The intercept reflects the estimated average log risk ratio for level '' | + | The intercept reflects the estimated average log risk ratio for level '' |
First, we can compute the estimated average risk ratios for the three levels with: | First, we can compute the estimated average risk ratios for the three levels with: | ||
<code rsplus> | <code rsplus> | ||
- | predict(res, newmods = c(0,0), transf=exp, digits=2) | + | predict(res3, newmods = c(0,0), transf=exp, digits=2) |
- | predict(res, newmods = c(1,0), transf=exp, digits=2) | + | predict(res3, newmods = c(1,0), transf=exp, digits=2) |
- | predict(res, newmods = c(0,1), transf=exp, digits=2) | + | predict(res3, newmods = c(0,1), transf=exp, digits=2) |
</ | </ | ||
<code output> | <code output> | ||
Line 194: | Line 196: | ||
</ | </ | ||
- | Note: The output above was obtained with '' | + | Note: The output above was obtained with '' |
- | But what should we do if we want to compute an ' | + | But what should we do if we want to compute an ' |
<code rsplus> | <code rsplus> | ||
- | colMeans(model.matrix(res))[-1] | + | colMeans(model.matrix(res3))[-1] |
</ | </ | ||
<code output> | <code output> | ||
Line 209: | Line 211: | ||
<code rsplus> | <code rsplus> | ||
- | predict(res, newmods = colMeans(model.matrix(res))[-1], transf=exp, digits=2) | + | predict(res3, newmods = colMeans(model.matrix(res3))[-1], transf=exp, digits=2) |
</ | </ | ||
<code output> | <code output> | ||
Line 220: | Line 222: | ||
What do these column means above actually represent? They are in fact proportions and indicate that 53.8% of the trials used random allocation (i.e., 7 out of the 13), 30.8% used systematic allocation (i.e., 4 out of the 13), and hence 15.4% used alternating allocation (i.e., 2 out of the 13). The predicted effect computed above is therefore an estimate for a population of studies where the relative frequencies of the different allocation methods are like those observed in the 13 trials included in the meta-analysis. | What do these column means above actually represent? They are in fact proportions and indicate that 53.8% of the trials used random allocation (i.e., 7 out of the 13), 30.8% used systematic allocation (i.e., 4 out of the 13), and hence 15.4% used alternating allocation (i.e., 2 out of the 13). The predicted effect computed above is therefore an estimate for a population of studies where the relative frequencies of the different allocation methods are like those observed in the 13 trials included in the meta-analysis. | ||
- | But we are not restricted to setting the proportions in this way. Another | + | But we are not restricted to setting the proportions in this way. Another approach is to assume that the population to which we want to generalize includes studies where each allocation method is used equally often. For a three-level factor, we then need to set the values for the two dummy variables to 1/3. This yields: |
<code rsplus> | <code rsplus> | ||
- | predict(res, newmods = c(1/3,1/3), transf=exp, digits=2) | + | predict(res3, newmods = c(1/3,1/3), transf=exp, digits=2) |
</ | </ | ||
<code output> | <code output> | ||
Line 235: | Line 237: | ||
<code rsplus> | <code rsplus> | ||
- | res <- rma(yi, vi, mods = ~ ablat + alloc, data=dat) | + | res4 <- rma(yi, vi, mods = ~ ablat + alloc, data=dat) |
- | res | + | res4 |
</ | </ | ||
<code output> | <code output> | ||
Line 268: | Line 270: | ||
<code rsplus> | <code rsplus> | ||
- | predict(res, newmods = colMeans(model.matrix(res))[-1], transf=exp, digits=2) | + | predict(res4, newmods = colMeans(model.matrix(res4))[-1], transf=exp, digits=2) |
</ | </ | ||
<code output> | <code output> | ||
Line 278: | Line 280: | ||
Some may scoff at the idea of computing such an ' | Some may scoff at the idea of computing such an ' | ||
+ | |||
+ | ==== Addendum: Using the emmeans Package ==== | ||
+ | |||
+ | The [[https:// | ||
+ | |||
+ | <code rsplus> | ||
+ | install.packages(" | ||
+ | library(emmeans) | ||
+ | </ | ||
+ | |||
+ | For the model that included only '' | ||
+ | |||
+ | <code rsplus> | ||
+ | sav <- emmprep(res2) | ||
+ | emmeans(sav, | ||
+ | </ | ||
+ | <code output> | ||
+ | | ||
+ | | ||
+ | |||
+ | Confidence level used: 0.95 | ||
+ | Intervals are back-transformed from the log scale | ||
+ | </ | ||
+ | |||
+ | Similarly, for the model that included the '' | ||
+ | |||
+ | <code rsplus> | ||
+ | sav <- emmprep(res3) | ||
+ | emmeans(sav, | ||
+ | </ | ||
+ | <code output> | ||
+ | | ||
+ | | ||
+ | |||
+ | Results are averaged over the levels of: alloc | ||
+ | Confidence level used: 0.95 | ||
+ | Intervals are back-transformed from the log scale | ||
+ | </ | ||
+ | |||
+ | Note that the default is to use equal weighting of the levels that are averaged over, so we had to explicitly set '' | ||
+ | |||
+ | <code rsplus> | ||
+ | emmeans(sav, | ||
+ | </ | ||
+ | <code output> | ||
+ | | ||
+ | | ||
+ | |||
+ | Results are averaged over the levels of: alloc | ||
+ | Confidence level used: 0.95 | ||
+ | Intervals are back-transformed from the log scale | ||
+ | </ | ||
+ | |||
+ | Finally, for the model that included both '' | ||
+ | |||
+ | <code rsplus> | ||
+ | sav <- emmprep(res4) | ||
+ | emmeans(sav, | ||
+ | </ | ||
+ | <code output> | ||
+ | | ||
+ | | ||
+ | |||
+ | Results are averaged over the levels of: alloc | ||
+ | Confidence level used: 0.95 | ||
+ | Intervals are back-transformed from the log scale | ||
+ | </ | ||
+ | |||
+ | Note that these results are identical to the ones we obtained earlier using the '' | ||
==== References ==== | ==== References ==== |
tips/computing_adjusted_effects.txt · Last modified: 2024/06/07 12:32 by Wolfgang Viechtbauer