Statistics for Laboratory Scientists ( 140.615 )

Sample Size and Power Calculations

Examples from class using power.t.test

power.t.test(n=10,delta=5,sd=10)
## 
##      Two-sample t test power calculation 
## 
##               n = 10
##           delta = 5
##              sd = 10
##       sig.level = 0.05
##           power = 0.1838375
##     alternative = two.sided
## 
## NOTE: n is number in *each* group
power.t.test(delta=5,sd=10,power=0.8)
## 
##      Two-sample t test power calculation 
## 
##               n = 63.76576
##           delta = 5
##              sd = 10
##       sig.level = 0.05
##           power = 0.8
##     alternative = two.sided
## 
## NOTE: n is number in *each* group
power.t.test(delta=5,sd=10,power=0.8,alternative="one.sided")
## 
##      Two-sample t test power calculation 
## 
##               n = 50.1508
##           delta = 5
##              sd = 10
##       sig.level = 0.05
##           power = 0.8
##     alternative = one.sided
## 
## NOTE: n is number in *each* group

Some more details

It only matters what the \(\Delta / \sigma\) ratio is.

power.t.test(n=10,delta=5,sd=10)
## 
##      Two-sample t test power calculation 
## 
##               n = 10
##           delta = 5
##              sd = 10
##       sig.level = 0.05
##           power = 0.1838375
##     alternative = two.sided
## 
## NOTE: n is number in *each* group
power.t.test(n=10,delta=0.5,sd=1)
## 
##      Two-sample t test power calculation 
## 
##               n = 10
##           delta = 0.5
##              sd = 1
##       sig.level = 0.05
##           power = 0.1838375
##     alternative = two.sided
## 
## NOTE: n is number in *each* group
power.t.test(n=10,delta=0.5)
## 
##      Two-sample t test power calculation 
## 
##               n = 10
##           delta = 0.5
##              sd = 1
##       sig.level = 0.05
##           power = 0.1838375
##     alternative = two.sided
## 
## NOTE: n is number in *each* group
power.t.test(delta=5,sd=10,power=0.8)
## 
##      Two-sample t test power calculation 
## 
##               n = 63.76576
##           delta = 5
##              sd = 10
##       sig.level = 0.05
##           power = 0.8
##     alternative = two.sided
## 
## NOTE: n is number in *each* group
power.t.test(delta=0.5,power=0.8)
## 
##      Two-sample t test power calculation 
## 
##               n = 63.76576
##           delta = 0.5
##              sd = 1
##       sig.level = 0.05
##           power = 0.8
##     alternative = two.sided
## 
## NOTE: n is number in *each* group

Extracting the sample size or power.

attributes(power.t.test(n=10,delta=0.5))
## $names
## [1] "n"           "delta"       "sd"          "sig.level"   "power"       "alternative" "note"       
## [8] "method"     
## 
## $class
## [1] "power.htest"
power.t.test(n=10,delta=0.5)$power
## [1] 0.1838375
power.t.test(delta=0.5,power=0.8)$n
## [1] 63.76576
ceiling(power.t.test(delta=0.5,power=0.8)$n)
## [1] 64

There is always a (small) chance you reject the null for the wrong reason.

power.t.test(n=10,delta=0.5)$power
## [1] 0.1838375
power.t.test(n=10,delta=0.5,strict=TRUE)$power
## [1] 0.1850957
power.t.test(n=10,delta=1.5)$power
## [1] 0.8869701
power.t.test(n=10,delta=1.5,strict=TRUE)$power
## [1] 0.8869702