### copy data into 'dat' and examine data
dat <- dat.berkey1998
dat
if (FALSE) {
### load metafor package
library(metafor)
### construct block diagonal var-cov matrix of the observed outcomes based on variables v1i and v2i
V <- vcalc(vi=1, cluster=author, rvars=c(v1i, v2i), data=dat)
### fit multiple outcomes (meta-regression) model (with REML estimation)
res <- rma.mv(yi, V, mods = ~ 0 + outcome, random = ~ outcome | trial, struct="UN", data=dat)
print(res, digits=3)
### test/estimate difference between the two outcomes
anova(res, X=c(1,-1))
### fit model including publication year as moderator for both outcomes (with ML estimation)
res <- rma.mv(yi, V, mods = ~ 0 + outcome + outcome:I(year - 1983),
random = ~ outcome | trial, struct="UN", data=dat, method="ML")
print(res, digits=3)
}
Run the code above in your browser using DataLab