# [R-meta] metafor::matreg() and its workflow

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Thu Dec 9 18:17:16 CET 2021

```>-----Original Message-----
>From: Stefanou Revesz [mailto:stefanourevesz using gmail.com]
>Sent: Tuesday, 07 December, 2021 23:41
>To: Viechtbauer, Wolfgang (SP)
>Cc: R meta
>Subject: Re: metafor::matreg() and its workflow
>
>Hi Wolfgang,
>
>Once again, thank you for the chapter and the two useful resources.
>For concreteness, are the last two lines OK to use or other solutions
>exist?
>
>Many thanks,
>Stefanou
>
>set.seed(0)
>dat <- dat.craft2003
>dat\$Xwb <- rnorm(nrow(dat),rnorm(nrow(dat),9,4),2)
>
>tmp <- rcalc(ri ~ var1 + var2| study, ni=ni, data=dat)
>V <- tmp\$V
>dat\$var1.var2 <- tmp\$dat\$var1.var2
>
>dat\$var1.var2 <- factor(dat\$var1.var2,
>                        levels=c("acog.perf", "asom.perf",
>"conf.perf", "acog.asom", "acog.conf", "asom.conf"))
>
>res <- rma.mv(ri~ 0+var1.var2+sport+Xwb, V, random = ~ var1.var2 |
>study, struct="UN", data=dat)
>
>R <- vec2mat(coef(res)[1:6]) # Is this OK?

The first 6 coefficients are the estimated pooled correlations when 'sport' is I and when Xwb is 0. If this is what you want, then this is ok.

>matreg(1, 2:4, R=R, V=vcov(res)[1:6,1:6]) # Is this OK?

If the above is ok, then this is ok.

Best,
Wolfgang
```