I am conducting a multi-level, mixed-effects meta-analysis where effect sizes are clustered within studies. In the R package metafor, I specify my model like this:
rma.mv(data = df,
yi = g ~ 1,
V = varG,
random = ~ 1 | studyID) %>%
robust(cluster = df$studyID) #To calculate robust standard errors
My outcome vector is g, its variance is varG, and my intercept is a random variable clustered within studyID. When I add a moderator to this model, should that also be specified as a random effect? Or is it a fixed effect? So far I haven't found a way to specify a moderator as a random effect using metafor. Instead, this is what I use:
rma.mv(data = df,
yi = g ~ 1 + mod, #This is the same as adding the `mods` argument
V = varG,
random = ~ 1 | studyID) %>%
robust(cluster = df$studyID) #To calculate robust standard errors
I would think that the moderator should be a random variable for the same reason that the intercept is; it depends on the cluster (study), and so if we treat it as fixed we will end up with non-independent residuals. But I'm also new to both meta-analysis and fixed-/random-variables, so I could be approaching this totally wrong.
random = ~ mod | studyID, struct="GEN"(this is currently undocumented, but works as intended). – Wolfgang Jun 01 '21 at 15:39