if (FALSE) {
########################
# SAT coaching example;
# load example data:
data("Rubin1981")
# perform meta-analysis:
bma01 <- bayesmeta(y=Rubin1981[,"effect"], sigma=Rubin1981[,"stderr"],
labels=Rubin1981[,"school"], tau.prior="uniform")
# show meta-analysis results:
forestplot(bma01)
# show trace plot:
traceplot(bma01)
##################################
# COPD (meta-regression) example;
# load example data,
# compute effect sizes (log-ORs):
data("KarnerEtAl2014")
karner.exa <- escalc(measure="OR",
ai=tiotropium.exa, n1i=tiotropium.total,
ci=placebo.exa, n2i=placebo.total,
slab=study, data=KarnerEtAl2014)
#################################
# perform "plain" meta-analysis:
bma02 <- bayesmeta(karner.exa,
tau.prior=function(t){dhalfnormal(t, scale=0.5)})
traceplot(bma02, ylab="log-OR",
prior=TRUE, infi=TRUE, taulim=0.53)
forestplot(bma02)
############################
# perform meta-regressions:
# 1st regression;
# specify regressor matrix
# (indicator variables, "short" vs. "long" study duration):
X1 <- cbind("short" = as.numeric(karner.exa$duration == "up to 1 year"),
"long" = as.numeric(karner.exa$duration == "1 year or longer"))
# perform meta-regression
# (two group means, common heterogeneity):
bmr01 <- bmr(karner.exa, X=X1,
tau.prior=function(t){dhalfnormal(t, scale=0.5)})
# show trace plot:
traceplot(bmr01, ylab="log-OR", prior=TRUE,
taulim=0.53, mulim=c(-1, 0.2),
X=rbind("short" = c(1,0),
"long" = c(0,1)))
# 2nd regression;
# specify regressor matrix
# (baseline FEV1, an indicator of disease severity):
X2 <- cbind("intercept" = 1,
"fev1" = karner.exa$baseline.fev1)
# perform meta-regression
# (linear effect of FEV1 on log-OR):
bmr02 <- bmr(karner.exa, X=X2,
tau.prior=function(t){dhalfnormal(t, scale=0.5)})
traceplot(bmr02, ylab="log-OR", prior=TRUE,
taulim=0.53, mulim=c(-1.0, 0.2),
X=rbind("FEV1 = 1.0"=c(1,1.0),
"FEV1 = 1.5"=c(1,1.5),
"FEV1 = 2.0"=c(1,2.0)))
}
Run the code above in your browser using DataLab