Nice addition, Wolfagang.
Patricia, I'm adding a couple of points to Wolfgang's informative comments.
First, you may want to set ** test = "knha" ** in your initial rma() call
for the dfs passed to emmeans to be a bit more conservative compared to the
default setting (i.e., test = "z") which translates into * Inf * df for the
t distribution-based inferences used in emmeans.
Second, you can also test the estimated marginal means (EMMs) in additional
ways that might be useful for various applications:
1- Testing contrasts among EMMs for each categorical variable against zero:
joint_tests(sav)
2- Testing EMMs for each categorical variable (rather than contrasts among
them) against zero:
test(emmeans(sav,"wic"), joint=TRUE)
test(emmeans(sav,"info"), joint=TRUE)
3- Jointly testing if the EMMs *across* multiple categorical variables
(blocks) are equal to each other:
com <- comb_facs(sav, c("wic","info")) # my suggestion for emmeans package
added by Russ
joint_tests(com)
Kind regards,
Reza
On Thu, Mar 9, 2023 at 9:51?AM Viechtbauer, Wolfgang (NP) via
R-sig-meta-analysis <r-sig-meta-analysis at r-project.org> wrote:
Dear Patricia,
To start: 'sei = vi' looks wrong. Argument 'sei' is for passing the
standard errors to the rma() function, but 'vi' sounds like a variable
contains sampling variances.
This aside, the answer to your question is yes. You can do this with:
predict(res, newmods=c(1,1), intercept=FALSE).
As for marginal effects, you can use emmprep() together with the emmeans
package (note that you will need to install the 'devel' version of
for this, since emmprep() was recent added;
https://wviechtb.github.io/metafor/#installation).
An example:
library(metafor)
dat <- dat.bangertdrowns2004
res <- rma(yi, vi, mods = ~ wic + info, data=dat)
res
predict(res, newmods=c(1,1), intercept=FALSE)
sav <- emmprep(res)
library(emmeans)
emmeans(sav, specs="1", weights="proportional")
# this is identical to
predict(res, newmods = colMeans(model.matrix(res))[-1], digits=3)
# marginal means for 'wic' and 'info'
emmeans(sav, specs="wic", weights="proportional")
emmeans(sav, specs="info", weights="proportional")
If you do not want proportional weights, then just leave out the
'weights="proportional"' part.
Best,
Wolfgang
-----Original Message-----
From: R-sig-meta-analysis [mailto:
r-sig-meta-analysis-bounces at r-project.org] On
Behalf Of Patricia Ziegelmann via R-sig-meta-analysis
Sent: Thursday, 09 March, 2023 14:17
To: r-sig-meta-analysis at r-project.org
Cc: Patricia Ziegelmann
Subject: [R-meta] margins command
Dear all,
I?m adjusting a simple metaregression model:
meta <- rma(yi = yi,
sei = vi,
mods = ~ risk1 + risk2,
data = data1,
method = "REML")
Both risk1 and risk2 are binary factors.
Is it possible to estimate a confidence interval for a function of the
fitted coefficients, let's say beta[1]+beta[2]?
Also, is there a command like the "margins" to have marginal effects
summaries?
Thanks in advance for any help,
Patricia
--
Patricia Klarmann Ziegelmann
Department of Statistics
Graduate Program in Epidemiology
Universidade Federal do Rio Grande do Sul (UFRGS)
http://lattes.cnpq.br/8486215358933890
Av. Bento Gon?alves, 9500 - Pr?dio 43-111 - Agronomia
91509-900 Porto Alegre - RS - BRAZIL