### copy data into 'dat' and examine data
dat <- dat.colditz1994
dat
if (FALSE) {
### load metafor package
library(metafor)
### calculate log risk ratios and corresponding sampling variances
dat <- escalc(measure="RR", ai=tpos, bi=tneg,
ci=cpos, di=cneg, data=dat,
slab=paste0(author, ", ", year))
dat
### random-effects model
res <- rma(yi, vi, data=dat)
res
### average risk ratio with 95% CI
predict(res, transf=exp)
### mixed-effects model with absolute latitude and publication year as moderators
res <- rma(yi, vi, mods = ~ ablat + year, data=dat)
res
### predicted average risk ratios for 10-60 degrees absolute latitude
### holding the publication year constant at 1970
predict(res, newmods=cbind(seq(from=10, to=60, by=10), 1970), transf=exp)
### note: the interpretation of the results is difficult because absolute
### latitude and publication year are strongly correlated (the more recent
### studies were conducted closer to the equator)
plot(ablat ~ year, data=dat, pch=19, xlab="Publication Year", ylab="Absolute Lattitude")
cor(dat$ablat, dat$year)
}
Run the code above in your browser using DataLab