# load data:
data("CrinsEtAl2014")
if (FALSE) {
# compute effect sizes (log odds ratios) from count data
# (using "metafor" package's "escalc()" function):
require("metafor")
crins.es <- escalc(measure="OR",
ai=exp.AR.events, n1i=exp.total,
ci=cont.AR.events, n2i=cont.total,
slab=publication, data=CrinsEtAl2014)
print(crins.es)
# perform meta analysis:
crins.ma <- bayesmeta(crins.es, tau.prior=function(t){dhalfcauchy(t,scale=1)})
########################
# generate forest plots
require("forestplot")
# default options:
forestplot(crins.ma)
# exponentiate values (shown in table and plot), show vertical line at OR=1:
forestplot(crins.ma, expo=TRUE, zero=1)
# logarithmic x-axis:
forestplot(crins.ma, expo=TRUE, xlog=TRUE)
# omit prediction interval:
forestplot(crins.ma, predict=FALSE)
# omit shrinkage intervals:
forestplot(crins.ma, shrink=FALSE)
# show more decimal places:
forestplot(crins.ma, digits=3)
# change table values:
# (here: add columns for event counts)
fp <- forestplot(crins.ma, expo=TRUE, plot=FALSE)
labtext <- fp$labeltext
labtext <- cbind(labtext[,1],
c("treatment",
paste0(CrinsEtAl2014[,"exp.AR.events"], "/", CrinsEtAl2014[,"exp.total"]),
"",""),
c("control",
paste0(CrinsEtAl2014[,"cont.AR.events"], "/", CrinsEtAl2014[,"cont.total"]),
"",""),
labtext[,2:3])
labtext[1,4] <- "OR"
print(fp$labeltext) # before
print(labtext) # after
forestplot(crins.ma, labeltext=labtext, expo=TRUE, xlog=TRUE)
# see also the "forestplot" help for more arguments that you may change,
# e.g. the "clip", "xticks", "xlab" and "title" arguments,
# or the "txt_gp" argument for label sizes etc.:
forestplot(crins.ma, clip=c(-4,1), xticks=(-3):0,
xlab="log-OR", title="pediatric transplantation example",
txt_gp = fpTxtGp(ticks = gpar(cex=1), xlab = gpar(cex=1)))
}
Run the code above in your browser using DataLab