[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|
Thu Jan 31 20:52:05 CET 2019
I do not really understand your question. It might also help if you post some output from the model.
From: Jose Valdebenito Chavez [mailto:jov23 using bath.ac.uk]
Sent: Thursday, 24 January, 2019 23:57
To: Viechtbauer, Wolfgang (SP); r-sig-meta-analysis using r-project.org
Subject: Re: Obtain means and CIs while accounting for two moderators for plotting purposes in R
That was very clear, many thanks!
I gave it a try using the proportions and it worked perfectly.
Now, because you said that the intercept is not desired in this opportunity, one additional question emerged.
As I mentioned before, I wanted to plot the "overall mean" and then the broken down results of the moderator that I am interest in (Season). For this I was using the outcomes of the model not considering the intercept " mods = ~ Season + Method -1 " and the btt argument as " btt = 1:3 ".
Is this correct? or I should include the intercept?
From: Viechtbauer, Wolfgang (SP) <wolfgang.viechtbauer using maastrichtuniversity.nl>
Sent: 23 January 2019 09:14:54
To: Jose Valdebenito Chavez; r-sig-meta-analysis using r-project.org
Subject: RE: Obtain means and CIs while accounting for two moderators for plotting purposes in R
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:
dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg)
res <- rma(yi, vi, mods = ~ ablat + alloc, data=dat)
### get means / proportions (leaving out the intercept)
### 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])
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).
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
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),
-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.
More information about the R-sig-meta-analysis