Power Calculations for One and Two Sample T-tests
Compute power of t test, or determine parameters to obtain target power.
power_Normal(n1 = NULL, n2 = NULL, delta = NULL, sd1 = 1, sd2 = 1, sig.level = 0.05, power = NULL, equal.sample = TRUE, alternative = c("two.sided", "one.sided"), type = c("two.sample", "one.sample", "paired"), df.method = c("welch", "classical"), strict = FALSE)
n1 |
sample size in group 1, or sample size in each group if equal.sample = TRUE |
n2 |
sample size in group 2 |
delta |
true difference in means |
sd1 |
standard deviation for group 1 |
sd2 |
standard deviation for group 2 |
sig.level |
significance level (Type I error probability) |
power |
power of test (1 minus Type II error probability) |
equal.sample |
equal sample sizes for two groups, see details |
alternative |
one- or two-sided test |
type |
Type of t test |
df.method |
Method for calculating the degrees of default. Possibilities are welch (the default) or classical. |
strict |
Use strict interpretation in two-sided case |
Exactly one of the parameters n1
, n2
, delta
, sd1
, sd2
, power
, and sig.level
must be passed as NULL, and that parameter is determined from the others.
Notice that sd1
, sd2
, sig.level
have non-NULL defaults, so NULL must be explicitly expressed if you want to compute them.
If equal.sample = TRUE
is used, N in output will denote the number in each group.
Object of class "power.htest", a list of the arguments (including the computed one) augmented with note and method elements.
'uniroot' is used to solve power equation for unknowns, so you may see errors from it, notably about inability to bracket the root when invalid arguments are given.
# Calculate power, equal sizes power_Normal(n1 = 150, delta = 5, sd1 = 20, sd2 = 10) # Calculate power, unequal sizes power_Normal(n1 = 150, delta = 5, n2 = 120, sd1 = 10) # Calculate n1, equal sizes power_Normal(delta = 5, power = 0.9, sd1 = 10, sd2 = 12)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.