A general equation to consider, assuming α = 0.05 and β = 0.20, and a one-sided test (see Crawley: Statistics: An Introduction Using R. John Wiley & Sons (West Sussex, UK), p. 9, 2005 [ISBN 0470022981]), is:
n ≈ (8 x s^2)/δ^2
where s^2 is the variance of the response and δ represents the difference in means between the two samples (remember that the Student’s t Test is used to compare the mean of two normally distributed samples, preferably of equal size and variance – for more information see Student’s t Test (Biostatistics Text)). If your variance is 10, and you want to detect a difference of 2 between two sample means, you need an n of 20. If your variance is 20, and you want to detect a difference of 1.5 between two sample means, you need an n of 71
To use a two-sided test:
n ≈ (16 x s^2)/δ^2
Programming in R
To make a sample size calculation in R, you need to know whether you are using a one-sided or two-sided test, what your power (1-β) is going to be, what the variance (s^2) in samples is (note that standard deviation, abbreviated sd in the R equation, is the square root of the variance), and the difference in the sample means (δ). As an example, enter the following text:
power.t.test(type = “one.sample”,power=0.8,sd=sqrt(10),delta=2)
Repeating the above example using R, we find sample sizes of 21.62 and 71.71, respectively
> power.t.test(type = “one.sample”,power=0.8,sd=sqrt(10),delta=2) One-sample t test power calculation n = 21.62146 delta = 2 sd = 3.162278 sig.level = 0.05 power = 0.8 alternative = two.sided > power.t.test(type = “one.sample”,power=0.8,sd=sqrt(20),delta=1.5) One-sample t test power calculation n = 71.71226 delta = 1.5 sd = 4.472136 sig.level = 0.05 power = 0.8 alternative = two.sided Retrieved from “http://openanesthesia.wpengine.com/w/index.php?title=Power_Analysis_for_Student%27s_t_Test&oldid=6438”