[R-meta] margins command

Viechtbauer, Wolfgang (NP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Thu Mar 9 16:51:33 CET 2023


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 that 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 metafor 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 using 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 using 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


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