Power calculations for one and two sample t tests
Compute the power of the one- or two- sample t test, or determine parameters to obtain a target power.
power.t.test(n = NULL, delta = NULL, sd = 1, sig.level = 0.05, power = NULL, type = c("two.sample", "one.sample", "paired"), alternative = c("two.sided", "one.sided"), strict = FALSE, tol = .Machine$double.eps^0.25)
- number of observations (per group)
- true difference in means
- standard deviation
- significance level (Type I error probability)
- power of test (1 minus Type II error probability)
- string specifying the type of t test. Can be abbreviated.
- one- or two-sided test. Can be abbreviated.
- use strict interpretation in two-sided case
- numerical tolerance used in root finding, the default providing (at least) four significant digits.
Exactly one of the parameters
sig.level must be passed as
NULL, and that
parameter is determined from the others. Notice that the last two have
non-NULL defaults, so NULL must be explicitly passed if you want to
strict = TRUE is used, the power will include the probability of
rejection in the opposite direction of the true effect, in the two-sided
case. Without this the power will be half the significance level if the
true difference is zero.
- Object of class
"power.htest", a list of the arguments (including the computed one) augmented with
uniroot is used to solve the power equation for unknowns, so
you may see errors from it, notably about inability to bracket the
root when invalid arguments are given.
power.t.test(n = 20, delta = 1) power.t.test(power = .90, delta = 1) power.t.test(power = .90, delta = 1, alternative = "one.sided")