### load BCG vaccine data
data(dat.bcg)
### meta-analysis of the log relative risks using a random-effects model
res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg,
measure="RR", data=dat.bcg, method="REML")
### average relative risk with 95\% CI
predict(res, transf=exp)
### mixed-effects model with absolute latitude as a moderator
res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, mods = ~ ablat,
measure="RR", data=dat.bcg, method="REML")
### predicted average relative risks for given absolute latitude values
predict(res, transf=exp, addx=TRUE)
### predicted average relative risks for 10-60 degrees absolute latitude
predict(res, newmods=c(10, 20, 30, 40, 50, 60), transf=exp)
### mixed-effects model with two moderators (absolute latitude and publication year)
res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, mods = ~ ablat + year,
measure="RR", data=dat.bcg, method="REML")
### predicted average relative risks for 10 and 60 degrees latitude in 1950 and 1980
predict(res, newmods=cbind(c(10,60,10,60),c(1950,1950,1980,1980)), transf=exp, addx=TRUE)
### mixed-effects model with two moderators (one of which is a factor)
res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, mods= ~ ablat + factor(alloc),
measure="RR", data=dat.bcg, method="REML")
### examine how the factor was actually coded for the studies in the dataset
predict(res, addx=TRUE)
### predictd average relative risks at 30 degrees for the three factor levels
### note: the contrast (dummy) variables need to specified explicitly here
predict(res, newmods=c(30, 0, 0), addx=TRUE) # for alternate allocation
predict(res, newmods=c(30, 1, 0), addx=TRUE) # for random allocation
predict(res, newmods=c(30, 0, 1), addx=TRUE) # for systematic allocation
Run the code above in your browser using DataLab