Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Chi-square Tests

Topics to be covered
• Chi-square Goodness of fit test
– Expected proportions
• Chi-square test of independence
– Is one factor associated with another?

Qualitative
Data

2 or more
1 pop. pop.
Proportion Independence

2 pop.

Z Test Z Test  2 Test  2 Test


Goodness of Fit test
Assumptions:
• 1 or more categories
• Independent observations
• A sample size of at least 10
• Random sampling
• All observations must be used
• For the test to be accurate, the expected frequency
should be at least 5
Conducting Chi-Square Analysis
Goodness of Fit Test
1) Make a hypothesis based on your basic biological question
1) Ho : The sample data came from a population having X ratio of frequencies
2) Ha: The sample data came from a population that DOES NOT have X ratio of
frequencies
2) Determine the expected frequencies
3) Create a table with observed frequencies, expected frequencies,
and chi-square values using the formula:
2 = ∑ [(O-E)2 / E]

4) Find the degrees of freedom: K-1 ( K is the number of categories)


5) Find the chi-square statistic in the Chi-Square Distribution table
Conclusions
5) If your calculated chi-square value > chi-square
statistic, you must reject your null hypothesis
 Ha: The sample data came from a population that
DOES NOT have X ratio of frequencies
6) IF your calculate chi-square value < chi-square
statistic, you CANNOT reject your null
hypothesis.
 Ho : The sample data came from a population
having X ratio of frequencies
Example 1
• Researcher Hope crossbreeds a polled and horned
breed of cattle. She hypothesised that that this will
result in a 3:1 phenotypic ratio of polled to horned
cattle. She randomly samples 100 offspring and
observes the frequency of polled to horned cattle is
84:16. Does this sample come from a population
having a 3:1 ratio of polled to horned cattle?
Example : Solution
1. State Hypotheses
Ho : The sample data came from a population
having a 3:1 ratio of polled to horned cattle
Ha: The sample data came from a population that
does not have a 3:1 ratio of polled to horned
cattle
α = 0.05
REMEMBER α is the significance level ( the probability
of making a type 1 error : probability of rejecting a true
null hypothesis)
Example : Solution
2. Calculate Expected Frequencies and calculate
Chi square value:
Observed Expected O–E (O-E)2 (O-E)2 / E

Polled 84 (3/4)*100 = 75 84 – 75 = 9 81 81/75 = 1.08

Horned 16 (1/4)*100 =25 16 – 25 = -9 81 81/25 = 3.24

TOTAL 100 100

Expected ratio 3:1 3) 2 = ∑ [(O-E)2 / E] 4) Degrees of Freedom = K – 1


75% Polled = 1.08 + 3.24 =2–1
25% horned = 4.32 =1
Example : Solution
5. Comparing Chi-square values
Calculate Chi – Square value = 4.320
Chi – Square statistic (from table) = 3.841

Conclusion: Since the calculated Chi-Square Value > Chi Square


Statistic ( 4.320 > 3.841) then we must reject Ho and accept Ha.
i.e. the cattle did not come from a population with a ratio of 3:1
polled: horned cattle
Example 2
• Researcher Luke wishes believes the sex ratio
of squirrels in Siparia is 1:1. She conducts an
experiment by which 60 squirrels are captured
and sexed. Using the data below test if this
hypothesis is true.
– Observed frequencies : 37 females; 23 males
Example 2 : Solution
1. State Hypotheses
Ho : The sample data came from a population
having a 1:1 ratio of male to female squirrels
Ha: The sample data came from a population that
does not have a 1:1 ratio of male to female
squirrels
α = 0.05
REMEMBER α is the significance level ( the probability
of making a type 1 error : probability of rejecting a true
null hypothesis)
Example 2 : Solution
2. Calculate Expected Frequencies and calculate
Chi square value:
Observed Expected O–E (O-E)2 (O-E)2 / E

Male 37 (1/2)*60 = 30 37 - 30 = 7 49 49/30 = 1.633

Female 23 (1/2)*60 = 30 23 – 30 = -7 49 49/30 = 1.633

TOTAL 60 60

Expected 1:1 3) 2 = ∑ [(O-E)2 / E] 4) Degrees of Freedom = K – 1


50% Male = 1.633+ 1.633 =2–1
50% Female = 3.266 =1
Example : Solution
5. Comparing Chi-square values
Calculate Chi – Square value = 3.226
Chi – Square statistic (from table) = 3.841

Conclusion: Since the calculated Chi-Square Value < Chi Square


Statistic ( 3.266< 3.841) then we cannot reject Ho. i.e. we must
conclude the squirrels came from a population with a sex ratio of
1:1
Example 3
• Researcher Karina wishes to determine if the
ratio of bulls to cows sent to a slaughterhouse
is 4:1. An experiment is conducted on which
100 animals were randomly selected from the
slaughter-line and sexed

• Observed frequencies: Bulls 70; Cows 30.


Example 3 - Solution
1) State Hypothesis
• Ho: Sample data came from a distribution with sex ratio of
4:1
• Ha: Sample data came from a distribution with that does not
have sex ratio of 4:1
2) Calculate expected frequencies (DRAW TABLE)
• Observed : Bulls 70; Cows 30.
• Expected ratio (4:1)
3) Calculate chi-square value
• 2 = ∑ [(O-E)2 / E]
4) Determine degrees of freedom
• Number of categories – 1 =
5) Compare Chi-square values
Example 4
• Researcher Phillips believes that caprines are
equally likely to give birth to 1, 2 or 3 kids. She
conducts a study of 60 Caprine parturitions,
and reported 30 animals had one kid, 20 had
two kids and 10 had three kids. Using the data
above test her hypothesis.
• Hint: Degree of freedom ( k-1) = 3-1 = 2
Example 4 - Solution
1) State Hypothesis
• Ho:
• Ha:
2. Calculate expected frequencies (DRAW TABLE)
• Observed :
• Expected ratio
3. Calculate chi-square value
• 2 = ∑ [(O-E)2 / E]
4. Determine degrees of freedom
• Number of categories – 1 =
5. Compare Chi-square values
Example 5
• Scientists believe that certain quarters of a cow are
more likely to come down with mastitis. Researcher
Evelyn believes the ratio of mastitis in the different
quarters are LF:RF:LB:RB is 9:3:3:1. She conducts an
experiment randomly testing cows with mastitis in
Carlsen Field and attains the following data. Test if
the observed data follows Evelyn’s Hypothesis.

Quarter Number with Mastitis


LF 152
RF 39
LB 53
RB 6
Example 5 - Solution
1) State Hypothesis
• Ho:
• Ha:
2. Calculate expected frequencies (DRAW TABLE)
• Observed :
• Expected ratio
3. Calculate chi-square value
• 2 = ∑ [(O-E)2 / E]
4. Determine degrees of freedom
• Number of categories – 1 =
5. Compare Chi-square values
Chi-square test of independence

Is one factor associated with the


other?
Chi-square test of independence
• Inferential method used for assessing
relationships between categorical variables.
Response Categories
A B Total
Group 1 a b a+b
Group 2 c d c+d

Total a+c b+d N

Total number of subjects, N = a+b+c+d


Chi-square test of independence
• Example: of 2*2 table
Ate breakfast

Yes No Total

Males 10 20 30
GENDER

females 15 30 45

Total 25 50 7y
Conducting Chi-Square Analysis
Test of independence
1) Make a hypothesis based on your basic biological question
1) Ho :Column and row classifications are independent of each other
2) Ha: Column and row classifications are not independent of each other.
2) Determine the expected frequencies
3) Create a table with observed frequencies, expected frequencies,
and chi-square values using the formula:
2 = ∑ [(O-E)2 / E]

4) Find the degrees of freedom: (r-1)(c-1)


• r: number of rows, c: number of column classifications
5) Find the chi-square statistic in the Chi-Square Distribution table
6) Apply Rejection Rule
4) REJECT Ho if 2 (calculated) is > 2 (table)
Example 1
• The table below shows classification of cows
according to parity number and incidence of
mastitis. Test if history of mastitis is
dependent of parity number.
MASTITIS HISTORY
Mastitis No Mastitis
Parity

Less than 3 20 80
3 or more 25 225
Example 1: Solution
• State Hypotheses:
• Ho: History of mastitis is independent of parity
number

• Ha: History of mastitis is dependent of parity


number.

• α = 0.05
Example 1: Solution
• Step 2.
– Calculate Row and Column Totals
MASTITIS HISTORY
Mastitis No Mastitis Total
Less than 3 20 80 100
Parity

3 or more 25 225 250

Total 45 305 350


Example 1: Solution
• Step 2.
– Calculate expected frequencies.
MASTITIS HISTORY
Mastitis No Mastitis Total
Less (row total)*(column total) / N (row total)*(column total) / N 100
(100)*(45) / 350 = 12.9 (100)*(305) / 350 = 87.1
than 3
Parity

3 or (row total)*(column total) / N (row total)*(column total) / N 250


(45)*(250)/350 = 32.1 (250)*(305)/350 = 217.9
more
Total 45 305 350
Example 1 : Solution
Step 3. calculate Chi square value:
Observed Expected O–E (O-E)2 (O-E)2 / E

a 20 12.9 7.1 50.41 50.41/12.9


=3.908
b 80 87.1 -7.1 50.41 50.41/87.1
=0.579
c 25 32.1 -7.1 50.41 50.41/32.1
=1.570
d 225 217.9 -7.1 50.41 50.41/217.9
=0.231
TOTAL 350 350

3) 2 = ∑ [(O-E)2 / E] 4) Degrees of Freedom = (r-1)(c-1)


=3.908+0.579+1.570+0.231 = (2 – 1)(2-1)
=1
= 6.288
Example 1: Solution
• Rejection Rule: REJECT Ho if 2 (calculated) is > 2 (table)
– Since 2 (calculated) is > 2 (table) ( 6.288> 3.84), Then
WE MUST REJECT Ho.

• Conclusion:
– The history of mastitis is dependent on parity
number.
Example 2
• The table below shows classification of Sows
according to breed and weight gain. Test if
weight gain is dependent on breed.
WEIGHT Gain (g)
0 1-150 151-300 300+
Duroc 220 327 110 71
Hampshire 36 45 38 21
Landrace 650 1535 600 240
Example 2: Solution
• State Hypotheses:
• Ho: Weight gain is independent of breed

• Ha: Weight gain is dependent on breed.

• α = 0.05
Example 2: Solution
• Step 2.
– Calculate Row and Column Totals

WEIGHT Gain (g)


0 1-150 151-300 300+ TOTAL
Duroc 220 327 110 71 728
Hampshire 36 45 38 21 140
Landrace 650 1535 600 240 3025
TOTAL 906 1907 748 332 3893
Example 2: Solution
• Step 2.
– Calculate expected frequencies.
WEIGHT Gain (g)
0 1-150 151-300 300+ TOTAL
Duroc (RT*CT)/N (RT*CT)/N RT*CT)/N RT*CT)/N 728
(728*906)/3893 (728*1907)/3893 (728*748)/3893 (728*332)/3893
= 169.42 =356.61 =139.88 =62.08
Hamp. RT*CT)/N (RT*CT)/N RT*CT)/N RT*CT)/N 140
(140*906)/3893
=32.58
Landr; RT*CT)/N RT*CT)/N RT*CT)/N RT*CT)/N 3025
(3025*906)/3893
=703.99
TOTAL 906 1907 748 332 3893
Example 2:
Step 3. calculate Chi square value:
Observed Expected O–E (O-E)2 (O-E)2 / E
220 169.42
327 356.61
110 139.88
73 62.08
36 ……..
45 ……..
38 ……..
21 ……
650 ……..
1535 …….
600 ……..
240 ……….
Example 2:
• Calculate 2 = ∑ [(O-E)2 / E]

• Degrees of freedom:
(r-1) * (c-1)
= (3-1)*(4-1)
=6
Example 2: Solution
• Rejection Rule: REJECT Ho if 2 (calculated) is > 2 (table)
– Since 2 (calculated) is > 2 (table), Then WE MUST
REJECT Ho.

• Conclusion:
– The weight gain is dependent on breed.
Example 3
• The table below shows classification of
students according to gender and hair colour.
Test if hair color is dependent of gender.

Black Brown Blond Red


MALE 32 43 16 9
FEMALE 55 65 64 16
Conducting Chi-Square Analysis
Test of independence
1) Make a hypothesis based on your basic biological question
1) Ho :Column and row classifications are independent of each other
2) Ha: Column and row classifications are not independent of each other.
2) Determine the column and Row totals
3) Calculate expected frequencies
4) Create a table with observed frequencies, expected frequencies, and
chi-square values using the formula:
2 = ∑ [(O-E)2 / E]

4) Find the degrees of freedom: (r-1)(c-1)


• r: number of rows, c: number of column classifications
5) Find the chi-square statistic in the Chi-Square Distribution table
6) Apply Rejection Rule
4) REJECT Ho if 2 (calculated) is > 2 (table)
Example 4
• A survey of 200 cows was done in three areas.
The cows were examined to determine the
number of functional teats. The data is shown
below. Is there an association between the
number of functional teats and the region?

Functional teats
1 2 3 4
North 29 16 42 23
Central 6 11 26 7
South 15 5 10 10
Conducting Chi-Square Analysis
Test of independence
1) Make a hypothesis based on your basic biological question
1) Ho :Column and row classifications are independent of each other
2) Ha: Column and row classifications are not independent of each other.
2) Determine the column and Row totals
3) Calculate expected frequencies
4) Create a table with observed frequencies, expected frequencies, and
chi-square values using the formula:
2 = ∑ [(O-E)2 / E]

4) Find the degrees of freedom: (r-1)(c-1)


• r: number of rows, c: number of column classifications
5) Find the chi-square statistic in the Chi-Square Distribution table
6) Apply Rejection Rule
4) REJECT Ho if 2 (calculated) is > 2 (table)

You might also like