Simulation 1: True Effect exists
pvals <- replicate(300, { # 300 studies
t.test(rnorm(35, 20, 15), # random sample (n=35) from the population with mean = 20
rnorm(35, 15, 15) # random sample (n=35) from the population with mean = 15
)$p.value # p-val from the t-test
})
hist(pvals[pvals < 0.05]) # histogram of significant (p < 0.05) p-values when True Effect exists

pvals <- replicate(300, { # 300 studies
t.test(rnorm(35, 20, 15), # random sample (n=35) from the population with mean = 20
rnorm(35, 15, 15) # random sample (n=35) from the population with mean = 15
)$p.value # p-val from the t-test
})
hist(pvals[pvals < 0.05]) # histogram of significant (p < 0.05) p-values when True Effect exists

pvals <- replicate(300, { # 300 studies
t.test(rnorm(35, 20, 15), # random sample (n=35) from the population with mean = 20
rnorm(35, 15, 15) # random sample (n=35) from the population with mean = 15
)$p.value # p-val from the t-test
})
hist(pvals[pvals < 0.05]) # histogram of significant (p < 0.05) p-values when True Effect exists

pvals <- replicate(300, { # 300 studies
t.test(rnorm(35, 20, 15), # random sample (n=35) from the population with mean = 20
rnorm(35, 15, 15) # random sample (n=35) from the population with mean = 15
)$p.value # p-val from the t-test
})
hist(pvals[pvals < 0.05]) # histogram of significant (p < 0.05) p-values when True Effect exists

Simulation 2: True Effect does not exists
pvals <- replicate(300, { # 300 studies
t.test(rnorm(35, 20, 15), # random sample (n=35) from the population with mean = 20
rnorm(35, 20, 15) # random sample (n=35) from the population with mean = 20 (no effect!)
)$p.value # p-val from the t-test
})
hist(pvals[pvals < 0.05]) # histogram of significant (p < 0.05) p-values when True Effect does not exist

pvals <- replicate(300, { # 300 studies
t.test(rnorm(35, 20, 15), # random sample (n=35) from the population with mean = 20
rnorm(35, 20, 15) # random sample (n=35) from the population with mean = 20 (no effect!)
)$p.value # p-val from the t-test
})
hist(pvals[pvals < 0.05]) # histogram of significant (p < 0.05) p-values when True Effect does not exist

pvals <- replicate(300, { # 300 studies
t.test(rnorm(35, 20, 15), # random sample (n=35) from the population with mean = 20
rnorm(35, 20, 15) # random sample (n=35) from the population with mean = 20 (no effect!)
)$p.value # p-val from the t-test
})
hist(pvals[pvals < 0.05]) # histogram of significant (p < 0.05) p-values when True Effect does not exist

pvals <- replicate(300, { # 300 studies
t.test(rnorm(35, 20, 15), # random sample (n=35) from the population with mean = 20
rnorm(35, 20, 15) # random sample (n=35) from the population with mean = 20 (no effect!)
)$p.value # p-val from the t-test
})
hist(pvals[pvals < 0.05]) # histogram of significant (p < 0.05) p-values when True Effect does not exist
