[R-meta] margins command
Reza Norouzian
rnorouz|@n @end|ng |rom gm@||@com
Thu Mar 9 18:08:01 CET 2023
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 using 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 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
> _______________________________________________
> R-sig-meta-analysis mailing list @ R-sig-meta-analysis using r-project.org
> To manage your subscription to this mailing list, go to:
> https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
>
[[alternative HTML version deleted]]
More information about the R-sig-meta-analysis
mailing list