Calculates sample size or power for a two-sample normal mean test.
Usage
one_norm_size(mu, mu0, sd, alpha, beta = NULL, n = NULL)
Arguments
- mu
Numeric. True mean.
- mu0
Numeric. Null hypothesis mean.
- sd
Numeric. Standard deviation.
- alpha
Numeric. Type I error rate.
- beta
Numeric (optional). Type II error rate. Required for sample size calculation.
- n
Integer (optional). Sample size. Required for power calculation.
Value
Numeric. Returns sample size (if beta is given), or power (if n is given).
Note
Only one of beta (for sample size calculation) or n (for power calculation) should be specified.
Required arguments:
For sample size: "mu", "mu0", "sd", "alpha", "beta"
For power: "mu", "mu0", "sd", "alpha", "n"
Examples
# Sample size
one_norm_size(mu = 2, mu0 = 1.5, sd = 1,
alpha = 0.05, beta = 0.2)
#> [1] 32
# Power
one_norm_size(mu = 2, mu0 = 1.5, sd = 1,
alpha = 0.05, n = 32)
#> [1] 0.8074304