The simulation relied on several distributions to randomly draw values for various settings such as the sample size or random effects. These distributions are visualized here for demonstration.
# Clear workspace
rm(list = ls())
suppressPackageStartupMessages({
library("here")
library("openxlsx")
})
van Erp et al. (2017) collected between-study heterogeneity estimates of meta-analyses published in Psychological Bulletin between 1990 and 2013. The respective database was provided under a public domain license. Here, the distributions of these estimates are summarized for meta-analyses using correlations as effect sizes.
# Read database
<- openxlsx::read.xlsx(
dat ::here("data", "Data 1990-2013 with tau values.xlsx"),
heresheet = 1
)
# Select entries with correlations
<- dat[!is.na(dat$'tau'), ]
dat <- dat[dat$'Type.of.ES' %in% c("Weighted Pearson's r",
dat "Pearson's r",
"Unweighted Pearson's r"), ]
# Number of estimates
length(dat$tau)
## [1] 202
# Distribution of estimates
hist(dat$tau, main = "Random effects", xlab = "tau", prob = TRUE)
# Distribution used for simulation
<- abs(rnorm(100000, 0, .20))
tau repeat {
> .50] <- tau[tau > .50] / 2
tau[tau if (all(tau <= .50)) break
}lines(density(tau))
# Quantiles of estimates
round(quantile(dat$tau, c(.05, .25, .50, .75, .95)), 2)
## 5% 25% 50% 75% 95%
## 0.00 0.08 0.16 0.22 0.36
round(quantile(tau, c(.05, .25, .50, .75, .95)), 2)
## 5% 25% 50% 75% 95%
## 0.01 0.06 0.13 0.23 0.37
range(dat$tau)
## [1] 0.00 0.52
range(tau)
## [1] 4.093092e-07 4.999593e-01
rm(tau)
# Random draws
<- rgamma(100000, 1.3, 1 / 250) + 50
n repeat {
> 900] <- n[n > 900] / 2
n[n if (all(n <= 900)) break
}<- round(n)
n
# Distribution of estimates
hist(n, main = "Sample size", xlab = "Sample size", prob = TRUE)
# Quantiles of estimates
round(quantile(n, c(.05, .25, .50, .75, .95)), 2)
## 5% 25% 50% 75% 95%
## 80 168 295 483 743
range(n)
## [1] 50 900
rm(n)
# Random draws
<- round(runif(100000, 5, 50))
k
# Distribution of estimates
hist(k, main = "Number of effects", xlab = "Number of effects", prob = TRUE)
# Quantiles of estimates
round(quantile(k, c(.05, .25, .50, .75, .95)), 2)
## 5% 25% 50% 75% 95%
## 7 16 28 39 48
range(k)
## [1] 5 50
rm(k)
# Random draws
<- round(runif(100000, .65, .95), 2)
rxx
# Distribution of estimates
hist(rxx, main = "Reliability", xlab = "Reliability", prob = TRUE)
# Quantiles of estimates
round(quantile(rxx, c(.05, .25, .50, .75, .95)), 2)
## 5% 25% 50% 75% 95%
## 0.67 0.73 0.80 0.87 0.93
range(rxx)
## [1] 0.65 0.95
rm(rxx)