# [R-meta] Testing for subgroup differences - meta (byvar) vs metafor

Zelniker, Thomas TZELNIKER at BWH.HARVARD.EDU
Wed Dec 6 03:08:12 CET 2017

```Dear all,

I am performing a meta-analysis of e.g. 4 trials. Each of these trials reports results for 2 subgroups (group A and group B). My aim is to meta-analyze and test for interaction between these two subgroups.
The R package meta allows doing this very easily by including the term byvar. However, I am not able to replicate this with the package metafor. Could anyone explain to me how the byvar statement works?

What would be the best approach?

Please find below an example indicating the differences between metafor and meta:

library(meta)
library(metafor)
rm(list = ls())
data(Fleiss93cont)
# Add some (fictious) grouping variables:
Fleiss93cont\$age <- c(55, 65, 55, 65, 55)
Fleiss93cont\$region <- c("Europe", "Europe", "Asia", "Asia", "Europe")
Fleiss93cont\$MD <- with(Fleiss93cont, mean.e - mean.c)
Fleiss93cont\$seMD <- with(Fleiss93cont, sqrt(sd.e^2/n.e + sd.c^2/n.c))

meta_mod <- metagen(MD, seMD,
byvar = region,
data = Fleiss93cont,
tau.common = F,
method.tau = "REML",
hakn = T,
sm = "MD")

# Here the results:
meta_mod
rma(y = MD, sei = seMD, mods = ~ region, data = Fleiss93cont, method = "REML", test = "knha", intercept = T)
rma.mv(MD, V= seMD^2, mods = ~ region, method = "REML",  test="t", random = ~region|study, struct="DIAG", data=Fleiss93cont)

Best regards,
Thomas

________________________________
Dr. Thomas Zelniker, MD, MSc
Research Fellow
TIMI Study Group
Brigham and Women's Hospital | Harvard Medical School
60 Fenwood Rd. | Suite 7022-7024W | Boston, MA 02115 | Ph: 1-617-278-0326
tzelniker at bwh.harvard.edu<mailto:tzelniker at partners.org>  | www.timi.org<http://www.timi.org/>

The information in this e-mail is intended only for the ...{{dropped:14}}

```