[R-meta] Obtain means and CIs while accounting for two moderators for plotting purposes in R

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Wed Jan 23 10:14:54 CET 2019


Dear Jose,

One can debate whether it is even meaningful to think about an "overall mean (accounting for moderators)" in meta-regression models. After all, by including moderators in the model, what we are saying is that the mean changes depending on the values of those moderators, so what is then the meaning of this overall mean? But leaving aside this discussion, the typical thing to do is to compute a marginal mean here. It is nothing else than the predicted value when fixing the moderators to some 'typical' values. For continuous moderators, one usually uses the mean value. For categorical moderators, one also usually uses the mean (which in essence then gives proportions that reflect how often certain categories occurred in the data).

Here is an example with one continuous and one categorical moderator:

library(metafor)

dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
res <- rma(yi, vi, mods = ~ ablat + alloc, data=dat)
res

### get means / proportions (leaving out the intercept)
colMeans(model.matrix(res))[-1]

### use those means / proportions to get the marginal mean
predict(res, newmods = colMeans(model.matrix(res))[-1])

The predicted value could then be interpreted as the "overall mean" for a population of studies that, on average, are conducted at 33.4 degrees absolute latitude and where 53% of studies use random allocation, 31% use systematic allocation, and the rest uses alternating allocation.

Some prefer not using the observed proportions (i.e., means) for categorical moderators, but instead assume that all categories can occur equally often in the population. That would be:

predict(res, newmods = c(mean(dat$ablat), 1/3, 1/3))

So, 1/3 of studies with random allocation, 1/3 with systematic allocation, and hence 1/3 with alternating allocation.

The same principle extends to more complex cases. In your case, using the observed proportions, it would be:

sav <- predict(model, newmods = colMeans(model.matrix(model))[-1])
sav

If you want to add this result to a forest plot, you can do so with addpoly():

addpoly(sav$pred, sei=sav$se, rows=<number>)

(you still need to specify the row number where the polygon should be added).

Best,
Wolfgang

-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org] On Behalf Of Jose Valdebenito Chavez
Sent: Sunday, 20 January, 2019 14:05
To: r-sig-meta-analysis using r-project.org
Subject: [R-meta] Obtain means and CIs while accounting for two moderators for plotting purposes in R

Dear members,

I am conducting a multivariate random-effect meta-analysis in R using the package metafor.

I am using the function rma.mv and my model has two random variables and two moderators.

I have conducted the analysis without too much trouble and obtained the effects of each moderator variable, as well as each dummy variable within these variables.

A couple of more details:

model <- rma.mv(yi, vi, mods = ~ Season + Method,
               data = d,
               random = list(~1|Taxon, ~1|Study),
               R=list(Taxon=vcv1))

Moderators:

-Season: all seasons, breeding, non breading
-Method: molecular, microscopy, both

Now, I would like to create forest plots for my results, presenting on top of the plot the overall mean (after accounting for Season and Method), and then right below, the broken down results for each dummy variable within Season (while accounting only for the variable Method).

To obtain the broken down results for each dummy variable within Season I have to play around with the btt vector. However, I don't know how can I get the overall mean and CIs values of the meta-analysis while accounting for both moderators.

Any help will be much appreciated.

Note: I know how to create the plot, I just what to obtain the numbers that I want to plot.

Many thanks
Jose


More information about the R-sig-meta-analysis mailing list