Sample Size Using
Online Calculator
http://powerandsamplesize.com/Calculators/
First connect to Calculators
Select Sample Size Calculator
Power for t-tests
Power for Proportions
One Sample Example
You are trying to detect a mean difference of 18 for a
variable with a standard deviation of 30. How many
subjects are required for a power of 80%.?
The hypotheses to be tested are
H0: = 18
HA: ≠ 18
Select 1-Sample, 2 Sided
Equally for this example
Fill these boxes
sample size will be
calculated in this box
Click on Calculate
Required sample size=22
Using R code for One Sample Example
mu=68
Just modify the R code from the
mu0=50 site 1-Sample, 2 Sided Equally
sd=30
alpha=0.05
beta=0.20
(n=(sd*(qnorm(1-alpha/2)+qnorm(1-beta))/(mu-
mu0))^2)
ceiling(n)# 32
z=(mu-mu0)/sd*sqrt(n)
(Power=pnorm(z-qnorm(1-alpha/2))+pnorm(-z-qnorm(1-
alpha/2)))
Using R code for One Sample Example
Required sample size=24
Two Samples Example
We need to estimate the sample size needed to compare
diastolic blood pressure (DBP) between two groups
(treated & controls) at an -level of 0.05 and a power of
90%. For the treated group (mean=71.5, sd= 6.7). For
the control group (mean=81.5, sd= 7.07).
The hypotheses to be tested are
H0: t= c
HA: t c
Two Samples Example
Select this for two
samples example
Two Samples Example
Enter the largest
standard
deviation here
Click on Calculate
Required sample size is 8 for each group
Using R code
muA=71.5
muB=81.5
kappa=1
sd=7.07
alpha=0.05
beta=0.20
(nB=(1+1/kappa)*(sd*(qnorm(1-alpha/2)+qnorm(1-
beta))/(muA-muB))^2)
ceiling(nB)
z=(muA-muB)/(sd*sqrt((1+1/kappa)/nB))
(Power=pnorm(z-qnorm(1-alpha/2))+pnorm(-z-
qnorm(1-alpha/2)))
Using R code
Required sample size=8 in each group
Two Proportions Example
We need to estimate the sample size needed to compare
success rate for two smoking cessation programs. The
proportion of success in one program is 60% and is 45%
in the other program. The -level is 0.05 and we require a
power of 80%.
The hypotheses to be tested are
H0: 1= 2
HA: 1 2
Two Proportions Example
Select this for two
proportions example
Two Proportions Example
Two Proportions Example
Required sample size=170 in each group
Using R code for Two Proportions
pA=0.60
pB=0.45
kappa=1
alpha=0.05
beta=0.20
(nB=(pA*(1-pA)/kappa+pB*(1-pB))*((qnorm(1-alpha/2)
+ qnorm(1-beta))/(pA-pB))^2)
ceiling(nB)
z=(pA-pB)/sqrt(pA*(1-pA)/nB/kappa+pB*(1-pB)/nB)
(Power=pnorm(z-qnorm(1-alpha/2))+pnorm(-z-qnorm(1-
alpha/2)))
Using R code for Two Proportions
Required sample size=171 in each group