Power

One of the errors is we could make is to reject the null when it is false, this is called the Power = 1 - beta, which can be reduced with a large n.

Power Calculation

Power Calculation

The calculation for Power looks like the the calculation for alpha, but when calculating power we plug in a different values of mu and n. 

For example, if you plot and take Power to be the area under the curve of the blue plot, after the black bar you see that

as the noise increases, there is less power:

More Noise Less Power

More Noise Less Power

and power increases with more data:

More Data More Power

More Data More Power

Arguments of power.t.test - n: number of observations (per group)

  • delta : true difference in means

  • sd : standard deviation

  • sig.level : significance level (Type I error probability)

  • power : power of test (1 minus Type II error probability)

  • type : string specifying the type of t test. Can be abbreviated.

  • alternative : one- or two-sided test. Can be abbreviated.

  • strict : use strict interpretation in two-sided case

  • tol : numerical tolerance used in root finding, the default providing (at least) four significant digits.

mu0 = 30
mua = 32
sigma = 4
alpha = 0.05
n = 16
z = qnorm(1 - alpha)
pnorm(mu0 + z * sigma/sqrt(n), mean = mu0, sd = sigma/sqrt(n), lower.tail = FALSE)
## [1] 0.05
#[1] 0.05 ##[1] 0.01 ###[1] 0.1
pnorm(mu0 + z * sigma/sqrt(n), mean = mua, sd = sigma/sqrt(n), lower.tail = FALSE)
## [1] 0.63876
#[1] 0.6388 ##[1] 0.3720806 ###[1] 0.7637596

Power depends on the effect size,

power.t.test(n = 16, delta = 2/4, sd = 1, type = "one.sample", alt = "one.sided")$power
## [1] 0.6040329
#[1] 0.6040329
power.t.test(n = 16, delta = 2, sd = 4, type = "one.sample", alt = "one.sided")$power
## [1] 0.6040329
#[1] 0.6040329
power.t.test(n = 16, delta = 100, sd = 200, type = "one.sample", alt = "one.sided")$power
## [1] 0.6040329
#[1] 0.6040329

or modified: Power Curves

we can calculate the sample size:

power.t.test(power = 0.8, delta = 2/4, sd = 1, type = "one.sample", alt = "one.sided")$n
## [1] 26.13751
#[1] 26.13751
power.t.test(power = 0.8, delta = 2, sd = 4, type = "one.sample", alt = "one.sided")$n
## [1] 26.13751
#[1] 26.13751
power.t.test(power = 0.8, delta = 100, sd = 200, type = "one.sample", alt = "one.sided")$n
## [1] 26.13751
#[1] 26.13751

here we would makr n=27.

or get delta from a given n:

power.t.test(power = 0.8, n = 3, sd = 4, type = "one.sample", alt = "one.sided")$delta
## [1] 9.1891
#[1] 9.1891
power.t.test(power = 0.8, n = 300, sd = 4, type = "one.sample", alt = "one.sided")$delta
## [1] 0.5755219
#[1] 0.5755219
power.t.test(power = 0.8, n = 3000, sd = 4, type = "one.sample", alt = "one.sided")$delta
## [1] 0.1816282
#[1] 0.1816282

Learn more: