# NOT RUN {
##### Example 1: BCG Vaccine and Tuberculosis Meta-Analysis #####
# calculate effect sizes for example dataset
d = metafor::escalc(measure="RR", ai=tpos, bi=tneg,
ci=cpos, di=cneg, data=metadat::dat.bcg)
# fit random-effects model
# note that metafor package returns on the log scale
m = metafor::rma.uni(yi= d$yi, vi=d$vi, knha=TRUE,
measure="RR", method="REML" )
# pooled point estimate (RR scale)
exp(m$b)
# estimate the proportion of effects stronger than RR = 0.70
# as recommended, use the calibrated approach for both point estimation and CI
# bootstrap reps should be higher in practice (e.g., 1000)
# here using fewer for speed
prop_stronger( q = log(0.7),
tail = "below",
estimate.method = "calibrated",
ci.method = "calibrated",
dat = d,
yi.name = "yi",
vi.name = "vi",
R = 100)
# warning goes away with more bootstrap iterates
# no Shapiro p-value because we haven't provided the dataset and its variable names
# now use the parametric approach (Mathur & VanderWeele 2018)
# no bootstrapping will be needed for this choice of q
prop_stronger( q = log(0.7),
M = as.numeric(m$b),
t2 = m$tau2,
se.M = as.numeric(m$vb),
se.t2 = m$se.tau2,
tail = "below",
estimate.method = "parametric",
ci.method = "parametric",
bootstrap = "ifneeded")
##### Example 2: Meta-Analysis of Multisite Replication Studies #####
# replication estimates (Fisher's z scale) and SEs
# from moral credential example in reference #2
r.fis = c(0.303, 0.078, 0.113, -0.055, 0.056, 0.073,
0.263, 0.056, 0.002, -0.106, 0.09, 0.024, 0.069, 0.074,
0.107, 0.01, -0.089, -0.187, 0.265, 0.076, 0.082)
r.SE = c(0.111, 0.092, 0.156, 0.106, 0.105, 0.057,
0.091, 0.089, 0.081, 0.1, 0.093, 0.086, 0.076,
0.094, 0.065, 0.087, 0.108, 0.114, 0.073, 0.105, 0.04)
d = data.frame( yi = r.fis,
vi = r.SE^2 )
# meta-analyze the replications
m = metafor::rma.uni( yi = r.fis, vi = r.SE^2, measure = "ZCOR" )
# probability of population effect above r = 0.10 = 28%
# convert threshold on r scale to Fisher's z
q = r_to_z(0.10)
# bootstrap reps should be higher in practice (e.g., 1000)
# here using only 100 for speed
prop_stronger( q = q,
tail = "above",
estimate.method = "calibrated",
ci.method = "calibrated",
dat = d,
yi.name = "yi",
vi.name = "vi",
R = 100 )
# probability of population effect equally strong in opposite direction
q.star = r_to_z(-0.10)
prop_stronger( q = q.star,
tail = "below",
estimate.method = "calibrated",
ci.method = "calibrated",
dat = d,
yi.name = "yi",
vi.name = "vi",
R = 100 )
# BCa fails to converge here
# }
Run the code above in your browser using DataLab