Tests For Binomial Data & Proportions: "Statistics Are The Grammar of Science."
Tests For Binomial Data & Proportions: "Statistics Are The Grammar of Science."
Tests For Binomial Data & Proportions: "Statistics Are The Grammar of Science."
• Tests for binomial data are just as powerful as test for normally distributed
data because we reference the known binomial distribution
Binomial distribution
• Binomial distribution is a family of distributions because the shape
references both the number of experiments/observations (e.g.
Bernoulli trail) (n) and the probability of “getting a success” (p)
4 B Y
5 B N Survival Survival
GROUPS n p
YES No
6 B Y Species A 8 12 20 0.4
… … … Species B 16 4 20 0.8
Proportion (p) is simply the total number of YES divided by the total observations (n)
Z-Test for Proportions
One Sample One Tailed Test 𝑠𝑖𝑔𝑛𝑎𝑙
𝑧𝑎𝑐𝑡𝑢𝑎𝑙 =
𝑛𝑜𝑖𝑠𝑒
What is the probability that the true
population proportion falls above/below a 𝑝−𝑎
cutoff value (a)? 𝑧𝑎𝑐𝑡𝑢𝑎𝑙 =
𝑝∗ 1−𝑝
Example: 𝐻𝑂 : 𝑝 < 𝑎 𝐻𝑎 : 𝑝 > 𝑎 𝑛
Example: Does species B have a survival rate P-value (in R): pnorm(z)
larger than 50% (arbitrary value)?
𝐻𝑂 : 𝑝𝐵 < 50 𝐻𝑎 : 𝑝𝐵 > 50
Survival Survival
GROUPS n p
YES No
0.8−0.5
𝑧𝑎𝑐𝑡𝑢𝑎𝑙 = = 3.3 Species A 8 12 20 0.4
0.8∗ 0.2
20
Species B 16 4 20 0.8
pnorm(3.3) = 0.99
(right tail, but we need the left tail)
One sample one-tailed Z-test in R (better/easier option):
1-pnrom(3.3) = 0.0005 install.packages("corpora")
Reject Ho library(corpora)
z.score.pval(16,20,0.5, alternative=”greater”)
Z-Test for Proportions
One Sample Two Tailed Test 𝑠𝑖𝑔𝑛𝑎𝑙
𝑧𝑎𝑐𝑡𝑢𝑎𝑙 =
𝑛𝑜𝑖𝑠𝑒
What is the probability that the true
population proportion is equal to a cutoff 𝑝−𝑎
value (a)? 𝑧𝑎𝑐𝑡𝑢𝑎𝑙 =
𝑝∗ 1−𝑝
Example: 𝐻𝑂 : 𝑝 = 𝑎 𝐻𝑎 : 𝑝 ≠ 𝑎 𝑛
Example: Does species B have a survival rate P-value (in R): pnorm(z)
equal to 50% (arbitrary value)?
𝐻𝑂 : 𝑝𝐵 = 50 𝐻𝑎 : 𝑝𝐵 ≠ 50
Survival Survival
GROUPS n p
YES No
0.8−0.5
𝑧𝑎𝑐𝑡𝑢𝑎𝑙 = = 3.3 Species A 8 12 20 0.4
0.8∗ 0.2
20
Species B 16 4 20 0.8
pnorm(3.3) = 0.99
(right tail, but we need the left tail)
One sample two-tailed Z-test in R (better/easier option):
1-pnrom(3.3) = 0.0005 install.packages("corpora")
Reject Ho library(corpora)
z.score.pval(16,20,0.5, alternative=”two.sided”)
Z-Test for Proportions 𝑠𝑖𝑔𝑛𝑎𝑙
𝑧𝑎𝑐𝑡𝑢𝑎𝑙 =
𝑛𝑜𝑖𝑠𝑒
Two Sample Two-Tailed Test
𝑧𝑎𝑐𝑡𝑢𝑎𝑙
Do samples A (p1) and B (p2) come from the 𝑝1 − 𝑝2
same population? =
𝑛 𝑛
Pooled SE 𝑝 1 − 𝑝 ∗ 𝑛 1+∗ 𝑛2
1 2
Example: 𝐻𝑂 : 𝑝1 = 𝑝2 𝐻𝑎 : 𝑝1 ≠ 𝑝2
𝑛1 𝑝1 + 𝑛2 𝑝2
𝑝=
𝑛1 + 𝑛2
Example: Is survival rate of Species A
significantly different from Species B? P-value (in R): pnorm(z)
𝐻𝑂 : 𝑝𝐴 = 𝑝𝐵 𝐻𝑎 : 𝑝𝑎 ≠ 𝑝𝐵
Survival Survival
GROUPS n p
YES No
0.8−0.4
𝑧𝑎𝑐𝑡𝑢𝑎𝑙 = = 2.67
0.15 Species A 8 12 20 0.4
Species B 16 4 20 0.8
pnorm(2.67) = 0.99
(right tail, but we need the left tail)
We cannot use the z.score.pval()
1-pnrom(2.67) = 0.0004 function for two samples because does not
Reject Ho allow for a pooled SE
Chi-Squared Test for Proportions 𝒙𝟐
Comparison between 2 or more groups
Survival Survival
GROUPS n p
Is there a treatment effect? YES No
If answer is YES, then use pairwise comparisons with adjusted
Species A 8 12 20 0.4
p-values to find it
Species B 16 4 20 0.8
Example: Is there any significant difference
between survival proportions? Species C 24 16 40 0.6
Example: 𝐻𝑂 : 𝑝𝐴 = 𝑝𝐵 = 𝑝𝐶
𝐻𝑎 : 𝑇ℎ𝑒 𝑝𝑟𝑜𝑝𝑜𝑟𝑖𝑡𝑜𝑛𝑠 𝑎𝑟𝑒 𝑛𝑜𝑡 𝑒𝑞𝑢𝑎𝑙
Procedure:
1) Calculate TOTALS
2) Calculate AVERAGE %
• This is called Expected %
• E.g. If there was no effect or A=B=C
3) Calculate number of Expected Outcome
for each treatment level
4) Calculate 𝒙𝟐 (chi-squared statistic)
Chi-Squared Test for Proportions 𝒙𝟐
Comparison between 2 or more groups
Survival Survival
GROUPS n p
Is there a treatment effect? YES No
If answer is YES, then use pairwise comparisons with adjusted
Species A 8 12 20 0.4
p-values to find it
Species B 16 4 20 0.8
Example: Is there any significant difference
between survival proportions? Species C 24 16 40 0.6
Example: 𝐻𝑂 : 𝑝𝐴 = 𝑝𝐵 = 𝑝𝐶
𝐻𝑎 : 𝑇ℎ𝑒 𝑝𝑟𝑜𝑝𝑜𝑟𝑖𝑡𝑜𝑛𝑠 𝑎𝑟𝑒 𝑛𝑜𝑡 𝑒𝑞𝑢𝑎𝑙 TOTALS 48 32 80
AVERAGE % 0.6 0.4
Procedure:
1) Calculate TOTALS
2) Calculate AVERAGE %
• This is called Expected %
• E.g. If there was no effect or A=B=C
3) Calculate number of Expected Outcome
for each treatment level
4) Calculate 𝒙𝟐 (chi-squared statistic)
Chi-Squared Test for Proportions 𝒙𝟐
Comparison between 2 or more groups
Survival Survival
GROUPS n p
Is there a treatment effect? YES No
If answer is YES, then use pairwise comparisons with adjusted
Species A 8 12 20 0.4
p-values to find it
Species B 16 4 20 0.8
Example: Is there any significant difference
between survival proportions? Species C 24 16 40 0.6
Example: 𝐻𝑂 : 𝑝𝐴 = 𝑝𝐵 = 𝑝𝐶
𝐻𝑎 : 𝑇ℎ𝑒 𝑝𝑟𝑜𝑝𝑜𝑟𝑖𝑡𝑜𝑛𝑠 𝑎𝑟𝑒 𝑛𝑜𝑡 𝑒𝑞𝑢𝑎𝑙 TOTALS 48 32 80
AVERAGE % 0.6 0.4
Procedure: GROUPS YES NO
1) Calculate TOTALS
Species A 12 8
2) Calculate AVERAGE %
• This is called Expected % Species B 12 8
• E.g. If there was no effect or A=B=C
Species C 24 16
3) Calculate number of Expected Outcome
for each treatment level
4) Calculate 𝒙𝟐 (chi-squared statistic) 𝐸𝑥𝑝𝑒𝑐𝑡𝑒𝑑 𝑂𝑢𝑡𝑐𝑜𝑚𝑒 = 𝑛 ∗ 𝐸𝑥𝑝𝑒𝑐𝑡𝑒𝑑%
Chi-Squared Test for Proportions 𝒙𝟐
Comparison between 2 or more groups
Survival Survival
GROUPS n p
Is there a treatment effect? YES No
If answer is YES, then use pairwise comparisons with adjusted
Species A 8 12 20 0.4
p-values to find it
Species B 16 4 20 0.8
Example: Is there any significant difference
between survival proportions? Species C 24 16 40 0.6
Example: 𝐻𝑂 : 𝑝𝐴 = 𝑝𝐵 = 𝑝𝐶
𝐻𝑎 : 𝑇ℎ𝑒 𝑝𝑟𝑜𝑝𝑜𝑟𝑖𝑡𝑜𝑛𝑠 𝑎𝑟𝑒 𝑛𝑜𝑡 𝑒𝑞𝑢𝑎𝑙 TOTALS 48 32 80
AVERAGE % 0.6 0.4
Procedure: GROUPS YES NO
1) Calculate TOTALS
Species A 12 8
2) Calculate AVERAGE %
• This is called Expected % Species B 12 8
• E.g. If there was no effect or A=B=C
Species C 24 16
3) Calculate number of Expected Outcome
for each treatment level 𝑛 2
𝑜𝑏𝑠𝑒𝑟𝑣𝑒𝑑 − 𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑
𝑥2 =
4) Calculate 𝒙𝟐 (chi-squared statistic) 𝑖 𝑛𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑
Chi-Squared Test for Proportions 𝒙𝟐
Comparison between 2 or more groups
Survival Survival
GROUPS n p
Is there a treatment effect? YES No
If answer is YES, then use pairwise comparisons with adjusted
Species A 8 12 20 0.4
p-values to find it
Species B 16 4 20 0.8
Example: Is there any significant difference
between survival proportions? Species C 24 16 40 0.6
Example: 𝐻𝑂 : 𝑝𝐴 = 𝑝𝐵 = 𝑝𝐶
𝐻𝑎 : 𝑇ℎ𝑒 𝑝𝑟𝑜𝑝𝑜𝑟𝑖𝑡𝑜𝑛𝑠 𝑎𝑟𝑒 𝑛𝑜𝑡 𝑒𝑞𝑢𝑎𝑙 TOTALS 48 32 80
AVERAGE % 0.6 0.4
𝑛 𝑜𝑏𝑠𝑒𝑟𝑣𝑒𝑑 − 𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑 2
𝑥2 = GROUPS YES NO
𝑖 𝑛𝑒𝑥𝑝𝑒𝑐𝑡𝑒𝑑
Species A 12 8
P-value (in R): pchisq(x2,df)
Species B 12 8
pchisq(6.667,2) = 0.96
(right tail, but we need the left tail) Species C 24 16
1-pchisq(6.667,2) = 0.04
Degrees of freedom (df) = number of groups - 1
Reject Ho and follow up with pairwise test
with adjusted p-values
Chi-Squared Test for Proportions 𝒙𝟐
Comparison between 2 or more groups
Survival Survival
GROUPS n p
Is there a treatment effect? YES No
If answer is YES, then use pairwise comparisons with adjusted
Species A 8 12 20 0.4
p-values to find it
Species B 16 4 20 0.8
Example: Is there any significant difference
between survival proportions? Species C 24 16 40 0.6
Example: 𝐻𝑂 : 𝑝𝐴 = 𝑝𝐵 = 𝑝𝐶
𝐻𝑎 : 𝑇ℎ𝑒 𝑝𝑟𝑜𝑝𝑜𝑟𝑖𝑡𝑜𝑛𝑠 𝑎𝑟𝑒 𝑛𝑜𝑡 𝑒𝑞𝑢𝑎𝑙 TOTALS 48 32 80
AVERAGE % 0.6 0.4
GROUPS YES NO
Expected