# 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=metafor::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.80
# no bootstrapping will be needed
prop_stronger( q = log(0.8),
M = as.numeric(m$b),
t2 = m$tau2,
se.M = as.numeric(m$vb),
se.t2 = m$se.tau2,
CI.level = 0.95,
tail = "below",
bootstrap = "ifneeded")
# }
# NOT RUN {
# now try a more extreme threshold, q, such that the function will use bootstrapping
# now we will need to pass the final 4 arguments as well
prop_stronger( q = log(0.9),
M = as.numeric(m$b),
t2 = m$tau2,
se.M = as.numeric(m$vb),
se.t2 = m$se.tau2,
CI.level = 0.95,
tail = "below",
# below arguments control bootstrapping
# only 100 iterates for demo purposes (should be higher in practice)
dat = d,
R = 100,
bootstrap = "ifneeded",
yi.name = "yi",
vi.name = "vi" )
# }
# NOT RUN {
##### 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 true 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,
M = m$b,
se.M = m$se,
t2 = m$tau2,
se.t2 = m$se.tau2,
tail = "above",
dat = d,
R = 250 )
# probability of true effect equally strong in opposite direction
q.star = r_to_z(-0.10)
prop_stronger( q = q.star,
M = m$b,
se.M = m$se,
t2 = m$tau2,
se.t2 = m$se.tau2,
tail = "below",
dat = d,
R = 250 )
# }
Run the code above in your browser using DataLab