# load data:
data("SchmidliEtAl2017")
# show data:
SchmidliEtAl2017
if (FALSE) {
# derive log-SDs and their standard errors:
dat <- cbind(SchmidliEtAl2017,
logstdev = log(SchmidliEtAl2017$stdev),
logstdev.se = sqrt(0.5/SchmidliEtAl2017$df))
dat
# alternatively, use "metafor::escalc()" function:
es <- escalc(measure="SDLN",
yi=log(stdev), vi=0.5/df, ni=N,
slab=study, data=SchmidliEtAl2017)
es
# perform meta-analysis of log-stdevs:
bm <- bayesmeta(y=dat$logstdev,
sigma=dat$logstdev.se,
label=dat$study,
tau.prior=function(t){dhalfnormal(t, scale=sqrt(2)/4)})
# or, alternatively:
bm <- bayesmeta(es,
tau.prior=function(t){dhalfnormal(t, scale=sqrt(2)/4)})
# draw forest plot (see Fig.1):
forestplot(bm, zero=NA,
xlab="log standard deviation")
# show heterogeneity posterior:
plot(bm, which=4, prior=TRUE)
# posterior of log-stdevs, heterogeneity,
# and predictive distribution:
bm$summary
# prediction (standard deviations):
exp(bm$summary[c(2,5,6),"theta"])
exp(bm$qposterior(theta=c(0.025, 0.25, 0.50, 0.75, 0.975), predict=TRUE))
# compute required sample size (per arm):
power.t.test(n=NULL, delta=8, sd=10.9, power=0.8)
power.t.test(n=NULL, delta=8, sd=14.0, power=0.8)
# check UISD:
uisd(es, indiv=TRUE)
uisd(es)
1 / sqrt(2)
# compute predictive distribution's ESS:
ess(bm, uisd=1/sqrt(2))
# actual total sample size:
sum(dat$N)
# illustrate predictive distribution
# on standard-deviation-scale (Fig.2):
x <- seq(from=5, to=20, length=200)
plot(x, (1/x) * bm$dposterior(theta=log(x), predict=TRUE), type="l",
xlab=expression("predicted standard deviation "*sigma[k+1]),
ylab="predictive density")
abline(h=0, col="grey")
}
Run the code above in your browser using DataLab