Skip to content
Prev 1362 / 5632 Next

[R-meta] Random Effect for Continuous Moderator in Three-Level Meta-Analysis

Hi Andrew,

Yes, this is possible if you install the 'devel' version of metafor. It includes an as-of-yet undocumented 'struct' option, namely "GEN". This allows for random effects terms, such as:

~ x1 + x2 + ... | factor

where x1, x2, and so on can be continuous (but also categorical) variables. So, for the example you used, it would be:

m2.ml <- rma.mv(yi, vi,
                random = ~ I(year-1990.591)| district, struct="GEN",
                method="ML",
                digits = 3,
                data=dat.konstantopoulos2011)

BUT:

1) Unless you want to assume that the average slope is 0, one should also include the same predictor as a fixed effect:

m2.ml <- rma.mv(yi, vi, mods = ~ I(year-1990.591),
                random = ~ I(year-1990.591)| district, struct="GEN",
                method="ML",
                digits = 3,
                data=dat.konstantopoulos2011)

2) 'year' is actually constant within districts, so the use of random slopes for this predictor doesn't make much sense.

Note: The "GEN" structure is undocumented, which implies that this feature is really still in the testing phase.

Best,
Wolfgang