# load example data:
data("CrinsEtAl2014")
# determine corresponding prior parameters:
TP <- TurnerEtAlPrior("surgical", "pharma", "placebo / control")
print(TP)
# a prior 95 percent interval for tau:
TP$qprior(c(0.025,0.975))
if (FALSE) {
# compute effect sizes (log odds ratios) from count data
# (using "metafor" package's "escalc()" function):
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.ma01 <- bayesmeta(crins.es, tau.prior=TP$dprior)
# for comparison perform analysis using weakly informative Cauchy prior:
crins.ma02 <- bayesmeta(crins.es, tau.prior=function(t){dhalfcauchy(t,scale=1)})
# show results:
print(crins.ma01)
print(crins.ma02)
# compare estimates; heterogeneity (tau):
rbind("Turner prior"=crins.ma01$summary[,"tau"], "Cauchy prior"=crins.ma02$summary[,"tau"])
# effect (mu):
rbind("Turner prior"=crins.ma01$summary[,"mu"], "Cauchy prior"=crins.ma02$summary[,"mu"])
# illustrate heterogeneity priors and posteriors:
par(mfcol=c(2,2))
plot(crins.ma01, which=4, prior=TRUE, taulim=c(0,2),
main="informative log-normal prior")
plot(crins.ma02, which=4, prior=TRUE, taulim=c(0,2),
main="weakly informative half-Cauchy prior")
plot(crins.ma01, which=3, mulim=c(-3,0),
main="informative log-normal prior")
abline(v=0, lty=3)
plot(crins.ma02, which=3, mulim=c(-3,0),
main="weakly informative half-Cauchy prior")
abline(v=0, lty=3)
par(mfrow=c(1,1))
# compare prior and posterior 95 percent upper limits for tau:
TP$qprior(0.95)
crins.ma01$qposterior(0.95)
qhalfcauchy(0.95)
crins.ma02$qposterior(0.95)
}
Run the code above in your browser using DataLab