[R-meta] Difference between subset (in a loop) and mods in metafor rma.mv
Thankyou Wolfgang, Just for my understanding: "When using the full dataset and using 'Predictor' as a moderator, then it is possible for information to be shared/borrowed from both levels of the moderator within studies." - is this what occurs in a multivariable/multivariate meta-analysis? Regards, Brendan. ------- Original Message -------
On Friday, September 29th, 2023 at 8:56 PM, Viechtbauer, Wolfgang (NP) <wolfgang.viechtbauer at maastrichtuniversity.nl> wrote:
Dear Brendan, Both approaches fit multilevel models. The difference arises because of two reasons: 1) When using the full dataset and using 'Predictor' as a moderator, then it is possible for information to be shared/borrowed from both levels of the moderator within studies. 2) When subsetting based on 'Predictor', you allow the variance components to differ across the two levels of the moderator. This is essentially what is discussed here: https://www.metafor-project.org/doku.php/tips:comp_two_independent_estimates but in the context of a simpler model. Best, Wolfgang
-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-project.org] On
Behalf Of Brendan Pearl via R-sig-meta-analysis
Sent: Friday, 29 September, 2023 12:00
To: r-sig-meta-analysis at r-project.org
Cc: Brendan Pearl
Subject: [R-meta] Difference between subset (in a loop) and mods in metafor
rma.mv
I am trying to understand the difference using the 'subset' and 'mods' options in
rma.mv.
I have run two analyses using rma.mv on the same dataset that has a three level
structure (articles nested within larger studies) and get different results.
In the first example I have given below, is looping over rma.mv and passing a
different predictor to the subset option a univariate meta-analysis? And in the
second example, is passing the predictor to the mods option running a
multivariable meta-analysis?
Study <- c("A","A","B","C","C","D","E","F","F","G")
Article <- c("1","2","3","4","5","6","7","8","9","10")
Predictor <- c("x","x","x","y","y","y","x","x","y","y")
yi <- c(-.2,-.3,-.8,.5,.6,.4,-.1,-.8,.3,.8)
vi <- c(.01,.01,.01,.01,.01,.01,.01,.01,.01,.01)
dat <- data.frame(Study,Article,Predictor,yi,vi)
#FIRST EXAMPLE#Subset analyses
# gives me
#1 x OR = -0.49 [-0.84, -0.13]
#2 y OR = 0.51 [0.31, 0.72]
df_subset <- data.frame(val=as.character(),subset_result=as.character())
for (val in unique(dat$Predictor)){
res_univariate <- rma.mv(yi=yi,
V=vi,
data=dat,
random = ~1 | Study/Article,
subset = Predictor == val,
method = "REML"
)
result <- capture.output(cat(
"OR = ",
format(round(res_univariate$beta, 2),nsmall = 2),
" [",
format(round(res_univariate$ci.lb, 2),nsmall = 2),
", ",
format(round(res_univariate$ci.ub, 2),nsmall = 2),
"]",
sep=""
)
)
df_subset[nrow(df_subset) +1,] = c(
val,
result
)
}
#SECOND EXAMPLE
#Mod analysis
#gives me:
# estimate ci.lb ci.ub
#factor(Predictor)x -0.4825 -0.7246 -0.2404
#factor(Predictor)y 0.5807 0.3386 0.8229
df_mod <- data.frame(val=as.character(),mod_result=as.character())
res_multivariate <- rma.mv(yi=yi,
V=vi,
data=dat,
random = ~1 | Study/Article,
mods = ~ factor(Predictor)-1,
method = "REML"
)
summary(res_multivariate)