+ - 0:00:00
Notes for current slide
Notes for next slide

Sample Size and Statistical Power

Aly Lamuri
Indonesia Medical Education and Research Institute

1 / 20

Recap: Hypothesis and significance

  • Null and alternative hypothesis
  • Rejecting the null
  • Should we accept the alternative?
1 / 20

Overview

  • More on p-value
  • Type of statistical error
  • Power analysis as a measure of α and β
  • Equation in calculating sample size
  • Random sampling
1 / 20

P-value: core concepts

  • We can reject the null when we get a p-value < 0.05.
2 / 20

P-value: core concepts

  • We can reject the null when we get a p-value < 0.05. But why?
2 / 20

P-value: core concepts

  • We can reject the null when we get a p-value < 0.05. But why?
  • 0.05 simply reflects a 5% chance
2 / 20

P-value: core concepts

  • We can reject the null when we get a p-value < 0.05. But why?
  • 0.05 simply reflects a 5% chance
  • ...of having a correct null hypothesis
2 / 20

P-value: core concepts

  • We can reject the null when we get a p-value < 0.05. But why?
  • 0.05 simply reflects a 5% chance
  • ...of having a correct null hypothesis
  • Or the way I like to say it:
2 / 20

P-value: core concepts

  • We can reject the null when we get a p-value < 0.05. But why?
  • 0.05 simply reflects a 5% chance
  • ...of having a correct null hypothesis
  • Or the way I like to say it: probability value
2 / 20

P-value: core concepts

  • We can reject the null when we get a p-value < 0.05. But why?
  • 0.05 simply reflects a 5% chance
  • ...of having a correct null hypothesis
  • Or the way I like to say it: probability value
  • When the probability is .small enough, we reject the null
2 / 20

P-value: core concepts

  • We can reject the null when we get a p-value < 0.05. But why?
  • 0.05 simply reflects a 5% chance
  • ...of having a correct null hypothesis
  • Or the way I like to say it: probability value
  • When the probability is .small enough, we reject the null
  • Well, that's not too hard! :)
2 / 20

P-value: a visual example

Let's revisit our last example of a coin toss

set.seed(1)
coin <- sample(c("H", "T"), 10, replace=TRUE, prob=rep(1/2, 2)) %T>% print()
## [1] "T" "T" "H" "H" "T" "H" "H" "H" "H" "T"
3 / 20

P-value: a visual example

Let's revisit our last example of a coin toss

set.seed(1)
coin <- sample(c("H", "T"), 10, replace=TRUE, prob=rep(1/2, 2)) %T>% print()
## [1] "T" "T" "H" "H" "T" "H" "H" "H" "H" "T"
  • We can formulate our hypothesis as:
    • H0:P(X=x)=0.5
    • Ha:P(X=x)0.5
3 / 20

P-value: a visual example

Let's revisit our last example of a coin toss

set.seed(1)
coin <- sample(c("H", "T"), 10, replace=TRUE, prob=rep(1/2, 2)) %T>% print()
## [1] "T" "T" "H" "H" "T" "H" "H" "H" "H" "T"
  • We can formulate our hypothesis as:
    • H0:P(X=x)=0.5
    • Ha:P(X=x)0.5
  • As always, we set H as our outcome of interest
  • Since it is a Bernoulli trial, we assumes it conforms the binomial distribution
3 / 20

P-value: a visual example

Let's revisit our last example of a coin toss

set.seed(1)
coin <- sample(c("H", "T"), 10, replace=TRUE, prob=rep(1/2, 2)) %T>% print()
## [1] "T" "T" "H" "H" "T" "H" "H" "H" "H" "T"
  • We can formulate our hypothesis as:
    • H0:P(X=x)=0.5
    • Ha:P(X=x)0.5
  • As always, we set H as our outcome of interest
  • Since it is a Bernoulli trial, we assumes it conforms the binomial distribution

...but, does it?

3 / 20

P-value: a visual example

binom.test(x=sum(coin == "H"), n=length(coin), p=0.5)
##
## Exact binomial test
##
## data: sum(coin == "H") and length(coin)
## number of successes = 6, number of trials = 10, p-value = 0.8
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
## 0.2624 0.8784
## sample estimates:
## probability of success
## 0.6
3 / 20

P-value: a visual example

binom.test(x=sum(coin == "H"), n=length(coin), p=0.5)
##
## Exact binomial test
##
## data: sum(coin == "H") and length(coin)
## number of successes = 6, number of trials = 10, p-value = 0.8
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
## 0.2624 0.8784
## sample estimates:
## probability of success
## 0.6
  • We have seen this numerous times now
3 / 20

P-value: a visual example

binom.test(x=sum(coin == "H"), n=length(coin), p=0.5)
##
## Exact binomial test
##
## data: sum(coin == "H") and length(coin)
## number of successes = 6, number of trials = 10, p-value = 0.8
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
## 0.2624 0.8784
## sample estimates:
## probability of success
## 0.6
  • We have seen this numerous times now
  • But we have yet to unravel the secret behind this magic!
3 / 20

P-value: a visual example

binom.test(x=sum(coin == "H"), n=length(coin), p=0.5)
##
## Exact binomial test
##
## data: sum(coin == "H") and length(coin)
## number of successes = 6, number of trials = 10, p-value = 0.8
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
## 0.2624 0.8784
## sample estimates:
## probability of success
## 0.6
  • We have seen this numerous times now
  • But we have yet to unravel the secret behind this magic!
  • Why did we fail to reject the null hypothesis?
3 / 20

P-value: a visual example

binom.test(x=sum(coin == "H"), n=length(coin), p=0.5)
##
## Exact binomial test
##
## data: sum(coin == "H") and length(coin)
## number of successes = 6, number of trials = 10, p-value = 0.8
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
## 0.2624 0.8784
## sample estimates:
## probability of success
## 0.6
  • We have seen this numerous times now
  • But we have yet to unravel the secret behind this magic!
  • Why did we fail to reject the null hypothesis?
  • Or rather, why does the p-value > 0.05?
3 / 20

P-value: a visual example

binom.test(x=sum(coin == "H"), n=length(coin), p=0.5)
##
## Exact binomial test
##
## data: sum(coin == "H") and length(coin)
## number of successes = 6, number of trials = 10, p-value = 0.8
## alternative hypothesis: true probability of success is not equal to 0.5
## 95 percent confidence interval:
## 0.2624 0.8784
## sample estimates:
## probability of success
## 0.6
  • We have seen this numerous times now
  • But we have yet to unravel the secret behind this magic!
  • Why did we fail to reject the null hypothesis?
  • Or rather, why does the p-value > 0.05?

Question: What's the probability of having 6 H out of 10 Bernoulli trials? Is it < 5%?

3 / 20

P-value: a visual example

P(X=6):XB(10,0.5)

dbinom(6, 10, 0.5)
## [1] 0.2051

We can manually calculate the p-value as the sum of P(X6)

2 * (dbinom(6:10, 10, 0.5) %>% sum())
## [1] 0.7539

Question: How if we preserve the ratio of event (3:5) using more trials?

3 / 20

P-value: a visual example

P(X=60):XB(100,0.5)

dbinom(60, 100, 0.5)
## [1] 0.01084

And we the p-value would be:

2 * (dbinom(60:100, 100, 0.5) %>% sum())
## [1] 0.05689

Question: We preserved the ratio, why has the probability changed?

3 / 20

P-value: take home notes

  • Theoretically, p-value is difficult to understand
  • But in practice, it tells you the probability of having a correct H0
  • Low p-value reject H0
4 / 20
4 / 20

Overview

  • More on p-value
  • Type of statistical error
  • Power analysis as a measure of α and β
  • Equation in calculating sample size
  • Random sampling
4 / 20

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?
5 / 20
  • When p-value < 0.05, we reject the H0
  • And 0.05 is a number we agreed upon
  • We know why we choose the number, but what is 0.05?

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?

Example, please?

Suppose we are conducting a study on a potential cancer therapy. We knew giving the patient a placebo may affect their recovery rate by 50%. We are certain giving the new treatment will increase the probability. Tested on 50 patients, 35 showed signs of better quality of life.

5 / 20

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?

Example, please?

Suppose we are conducting a study on a potential cancer therapy. We knew giving the patient a placebo may affect their recovery rate by 50%. We are certain giving the new treatment will increase the probability. Tested on 50 patients, 35 showed signs of better quality of life.

Concept check

  • Considering I.I.D, does it follow a Bernoulli trial?
  • If so, how do we model its distribution?
  • What are the parameters for our distribution?
  • What formal test can we use to determine significance?
5 / 20

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?

Modelling the distribution

CuredB(50,0.5)

5 / 20

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?

Modelling the distribution

CuredB(50,0.5)

Stating the hypothesis

H0:P(X=35)=0.5Ha:P(X=35)>0.5

5 / 20

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?

Statistical test

binom.test(35, 50, 0.5, alternative="greater")
##
## Exact binomial test
##
## data: 35 and 50
## number of successes = 35, number of trials = 50, p-value = 0.003
## alternative hypothesis: true probability of success is greater than 0.5
## 95 percent confidence interval:
## 0.5763 1.0000
## sample estimates:
## probability of success
## 0.7
5 / 20

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?

5 / 20

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?
  • We are assuming the Ha>H0
  • How do we picture α in our figure?
5 / 20

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?

5 / 20

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?
  • Shaded region of α determine the probability of getting a type I error
  • On the other hand, β reflects the type II error
  • However, the value of β depends on Ha distribution
5 / 20
  • Assuming Ha coming from similar distribution as H0, we just need to determine its parameter
  • P as the parameter could be anything as long as P>0.5
  • For our convenience, we shall have P=0.7 to construct the second distribution

Significance level

  • 0.05 is our significance level α
  • Higher α more chance to reject the H0 incorrect rejection?
  • More sample more chance to reject the H0 incorrect rejection?

5 / 20

Statistical error

Type I

  • Incorrectly rejecting the H0
  • Reflected as α shaded area to the right of H0 distribution
  • A false positive

Type II

  • Incorrectly accepting the H0
  • Reflected as β shaded area to the left of Ha distribution
  • A false negative
6 / 20

Overview

  • More on p-value
  • Type of statistical error
  • Power analysis
  • Equation in calculating sample size
  • Random sampling
6 / 20

Power=1β

  • Correctly reject the H0 when it is actualy false
  • Prospective vs. retrospective?
  • Help you determine the minimum required sample
7 / 20
  • Retrospective: to see whether or not we have conducted a correct procedure to reject the H0
  • Prospective: to calculate a sufficient minimal sample size needed

Power=1β

  • Correctly reject the H0 when it is actualy false
  • Prospective vs. retrospective?
  • Help you determine the minimum required sample

Caveats

  • Depends on formal methods to use
  • Does not generalize well
  • Give a best case scenario estimate
7 / 20
  • Retrospective: to see whether or not we have conducted a correct procedure to reject the H0
  • Prospective: to calculate a sufficient minimal sample size needed
  • There are other method to calculate the sample size
  • We don't have to solely rely on power analysis

Things to consider...

Power

Sample size

Effect size

Alpha

7 / 20

Power

Sample size

Effect size

Alpha

7 / 20
  • These four are inter-related
  • Adjustment on one governs the others
  • Each one is a function of another

Effect size

  • Disclaimer: this is just an overview, not an in-detailed explanation
  • Effect size measures a true difference between two hypotheses
  • Numerous conventions exists
  • Higher effect size higher power
  • One of the most difficult to obtain!
8 / 20

Obtaining an effect size

  • Literature review
  • Pilot study
  • Cohen's recommendation
9 / 20

Literature review:

  • Published articles may have done similar investigation on different population
  • Use their data to estimate the desired effect size
  • Meta-analysis technique is sometimes applicable to make a better estimate

Obtaining an effect size

  • Literature review
  • Pilot study
  • Cohen's recommendation
9 / 20

Pilot study:

  • By conducting a pilot study, we can get data reflecting our future study
  • Time consuming, but giving a closer estimate
  • A good chance to resolve any unanticipated issue

Obtaining an effect size

  • Literature review
  • Pilot study
  • Cohen's recommendation
9 / 20

Cohen's recommendation:

  • Depends on what formal test to use
  • Separated into small, medium and large effect size

Example, please?

10 / 20

We will re-examine our last example on a novel cancer drug

Example, please?

Let XB(n,p)

10 / 20

Example, please?

Let XB(n,p)

sig=x:P(X=1α | n,H0)β=P(Xsig | n,H1)Power=1β

10 / 20

We can calculate power when we know the probability function and its parameters

Example, please?

# Set H0, sample size, significance level (alpha)
h0 <- 0.5; size <- 50; alpha.rate <- 0.05
# Find significance value
alpha.value <- qbinom(1 - alpha.rate, size, prob=h0) %T>% print()
## [1] 31
# Determine H1
h1 <- 0.7
# Calculate beta
beta.value <- dbinom(0:alpha.value, size, prob=h1) %>% sum() %T>% print()
## [1] 0.1406
# Calculate power
1 - beta.value
## [1] 0.8594
10 / 20

Example, please?

10 / 20
  • Of course we can "reverse engineer" the calculation to obtain required sample size using known power
  • But the math can be quite... challenging :)
  • Thankfully, we have some ready-to-use packages to do the computation for us (yay to them!)

Overview

  • More on p-value
  • Type of statistical error
  • Power analysis as a measure of α and β
  • Equation in calculating sample size
  • Random sampling
10 / 20

Equation in calculating sample size

  • As in calculating effect sizes, we have numerous equations to apply
  • None fits all size, depends on our research context
  • We will see popular ones used in general and biomedical science
11 / 20

General equation

n=(Z1α2+Z1βES)2

n: Number of minimal sample size
Z1α2: Significance value in a standardized normal distribution
Z1β: Power value in a standardized normal distribution
ES: Effect size

12 / 20

For different purposes, we need different effect size estimation

General equation

n=(Z1α2+Z1βES)2

Dichotomous outcome, one sample

H0:p=p0ES=p1p0p(1p)

12 / 20

General equation

n=(Z1α2+Z1βES)2

Dichotomous outcome, two independent samples

H0:p1=p2ES=|p1=p2|p(1p)

12 / 20

General equation

n=(Z1α2+Z1βES)2

Continuous outcome, one sample

H0:μ=μ0ES=|μ1=μ0|σ

12 / 20

General equation

n=(Z1α2+Z1βES)2

Continuous outcome, two independent samples

H0:μ1=μ2ES=|μ1=μ2|σ

12 / 20

General equation

n=(Z1α2+Z1βES)2

Continuous outcome, two matched samples

H0:μd=0ES=μdσd

12 / 20

Problems

  • Different study design may require different solution
  • Different field of knowledge has its own preferences
  • What do we do as biomedical scientists?













J. Charan and T. Biswas. “How to calculate sample size for different study designs in medical research?” In: Indian Journal of Psychological Medicine 35.2 (2013), p. 121. DOI: 10.4103/0253-7176.116232.

13 / 20

Cross-sectional

Qualitative variable

n=Z1α22p(1p)d2

Quantitative variable

n=Z1α22σ2d2

Z1α2: Significance value in a standardized normal distribution
d: Absolute error as determined by the researcher
p: Estimated proportion
σ: Standard deviation

14 / 20

Statistics obtained from literature review or a pilot study

Case-control

Qualitative variable

n=r+1r(p)(1p)(Zβ+Zα2)2(p1p2)2

Quantitative variable

n=r+1rσ2(Zβ+Zα2)2(p1p2)2

r: Ratio of control to case
p: Average of exposed samples proportion
σ: Standard deviation from previous publication
p1p2: Difference in proportion as previously reported
Zβ: β value in a standardized normal distribution

15 / 20

β value depends on power, i.e. 0.84 for 80% of power and 1.28 for 90%

Clinical trial / experimental

Qualitative variable

n=2P(1P)(Zα2+Zβ)2(p1p2)2

Quantitative variable

n=2σ2(Zα2+Zβ)2d2

σ: Standard deviation from previous publication
P: Pooled prevalence from both groups
p1p2: Difference in proportion as previously reported

16 / 20

Overview

  • More on p-value
  • Type of statistical error
  • Power analysis as a measure of α and β
  • Equation in calculating sample size
  • Random sampling
16 / 20

Random sampling

Non-Probability

  • Convenience
  • Quota
17 / 20

Random sampling

Non-Probability

  • Convenience
  • Quota

Probability

  • Simple
  • Systematic
  • Stratified
17 / 20

Non-Probability random sampling

Convenience

  • Based on availability
  • Representativeness is unknown
  • Useful in preliminary study
18 / 20

Non-Probability random sampling

Convenience

  • Based on availability
  • Representativeness is unknown
  • Useful in preliminary study

Quota

  • As in convenient sampling
  • We set the desired proportion of our sample
  • Proportion based on specific criteria, e.g. age, sex, etc.
18 / 20

Probability random sampling

Simple

  • Random sample from a list of all subjects in a population
  • Each subject has an equal chance to participate
  • Useful in a small population
19 / 20

Probability random sampling

Simple

  • Random sample from a list of all subjects in a population
  • Each subject has an equal chance to participate
  • Useful in a small population

Systematic

  • Subject selection not entirely random
  • As in random sampling, requires an enumeration of all subjects
  • Systematically select the subject based on a certain criteria, e.g. every nth subject
19 / 20

Probability random sampling

Simple

  • Random sample from a list of all subjects in a population
  • Each subject has an equal chance to participate
  • Useful in a small population

Systematic

  • Subject selection not entirely random
  • As in random sampling, requires an enumeration of all subjects
  • Systematically select the subject based on a certain criteria, e.g. every nth subject

Stratified / cluster

  • Split subjects into stratified / clustered groups
  • Do random sampling from each group
  • Stratified preserves ordinality, i.e. the order is important
19 / 20

Query?

20 / 20

Recap: Hypothesis and significance

  • Null and alternative hypothesis
  • Rejecting the null
  • Should we accept the alternative?
1 / 20
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow