### load data
dat <- get(data(dat.berkey1998))
### for bdiag() function
require(Matrix)
### construct variance-covariance matrix of the observed outcomes
V <- as.matrix(bdiag(lapply(split(dat[,c("v1i", "v2i")], dat$trial), as.matrix)))
### fit multiple outcomes (meta-regression) model (with ML estimation)
res <- rma.mv(yi, V, mods = ~ outcome + outcome:I(year - 1983) - 1,
random = ~ outcome | trial, struct="UN", data=dat, method="ML")
print(res, digits=3)
Run the code above in your browser using DataLab