Description Usage Arguments Details Value
simulateTTests
simulates a number of one-sample t-tests on
Normally distributed samples with varying mean mu0 and sample size.
1 2 3 4 5 6 7 8 9 10 11 | simulate_t_tests(
m = 4000,
pi0 = 0.5,
mu.sd = 0.3,
mu.min = 0,
n.lmean = 2,
n.lsd = 2.5,
sample.sd = 1,
seed = NULL,
...
)
|
m |
Number of hypotheses to simulate |
pi0 |
Either a value for the fraction of true null hypotheses for which mu=0, or a vector each of whose entries is the likelihood of a true null hypothesis |
mu.sd |
Standard deviation used to generate the means of the Normal distributions under the alternative hypothesis |
mu.min |
The minumum value of abs(mu) for the means of the Normal distributions under the alternative hypothesis |
n.lmean |
Mean of the sample sizes on a log scale |
n.lsd |
Standard deviation of the sample sizes on a log scale |
sample.sd |
Standard deviation for the Normal distributions |
seed |
Optionally, random seed to set before simulating |
... |
Extra arguments, such as replication (may not be used) |
Each sample and test is constructed according to the following generative process.
The mean of a Normal distribution, mu, is either 0 under the null hypothesis, or
generated as (mu.min
+ abs(Norm(0, mu.sd
)) under the alternative
hypothesis. So, the means are always either positive or 0.
mu.min
can be used to ensure a minimal effect size between the null hypothesis and the
weakest alternative hypothesis (since by default an alternative hypothesis can
be arbitrarily close to being a true null hypothesis).
The sample size of each sample, n, is generated from a log-normal distribution, independent of the means of the Normal distributions. Specifically, it is generated as 2 + round(LNorm(n.lmean, n.lsd)), such that the sample size is never less than 2 (which would make a t-test impossible).
At this point, a random sample of size n is generated from the
Norm(mu, sample.sd
) distribution. A one-sample two-sided t-test
is performed and the p-value obtained.
A data frame, one row per hypothesis, with the columns
p.value |
Two-sided t-test p-value |
n |
Sample size of each sample |
mu |
Mean of each sample |
oracle |
TRUE if the alternative hypothesis holds, and FALSE for a true null hypothesis |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.