Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 16

Chi-square test of

independence
Chi-square test of independence

This test is used to analyze the frequencies of two characteristics of a society in order
to find out whether there is a relationship between these two characteristics.

For example, the test can be used to find out if there is a relationship between the
income and educational levels, or the student's assessment and number of hours of
study.

To answer such a question, we must choose a random sample from the community
under study, then classify the observations of this sample according to the levels of
each of the two characteristics and be placed in a table called the cross-tabulation.
Example
BEVERAGE COFFEE/TEA SOFT OTHERS TOTAL
DRINK
AGE
• A study is conducted to test CATEGORY
whether there is relation between
preferred beverage ordered at a 21-34 26 95 18 139
restaurant and the age of the
customer 35-55 41 40 20 101

55> 24 13 32 69

Total 91 148 70 309

Use the independence test to determine whether the preference for a specific type of
beverage is independent of the age or not. The hypothesis was tested at the level of
significance 0.01
• Step 1:
Type of beverage preferred is independent of age
Type of beverage preferred is not independent of age
• Step 2:
The test statistic used:
2
( 𝑂𝑖𝑗 − 𝐸𝑖𝑗 )
𝜒 =∑ ∑
2
Solution
𝑖 𝑗 𝐸𝑖𝑗
: The frequency of observed values at level of
variable A and level of the variable B
: The frequency of expected values at level of
variable A and level of the variable B

𝐸𝑖𝑗 =¿ ¿
Solution
Beverage Coffee/Tea Soft others Total
Age B Drink
category 𝐵1 𝐵3
A 𝐵2
21-34 26 𝑂 95 𝑂 18
𝐴1 𝑂1 1 12 1 3 𝑈 1 139
35-55 41 𝑂 40 𝑂 20
𝐴2 𝑂2 1 22 23 𝑈 2 101
55> 24 𝑂 13 𝑂 32 69
𝐴3 𝑂3 1 32 33
𝑈3
Total
𝑉 1 91 𝑉 2148 𝑉 3 70 𝑛 309
Beverage Coffee/Tea Soft others Total ==29.74
Age Drink
category
21-34 )40.94( )66.58( )31.49(
==48.38
139
26 95 18
35-55 )29.74( )48.38( )22.88( 101 ==22.88
41 40 20
55> )20.32( )33.05( )15.63( 69
24 13 32
Total 91 148 70 309

==40.94 ==20.32

==66.58 ==33.05

==31.49 ==15.63
Beverage Coffee/Tea Soft others Total
Age Drink
category
+ +
21-34 )40.94( )66.58( )31.49( 139
+ + + 26 95 18
+++ 35-55 )29.74( )48.38( )22.88( 101
=59.41 41 40 20
55> )20.32( )33.05( )15.63( 69
24 13 32
Total 91 148 70 309
Step 3: the critical Value

  [(r  1)(c  1)]


2

2
( 𝑂𝑖𝑗 − 𝐸𝑖𝑗 )
𝜒 =∑ ∑
2
Where
r: number of rows
c: number of columns

𝑖 𝑗 𝐸𝑖𝑗
Necessary Condition: All expected values are greater than or equal 5
Chi-Squared Distribution
Note that:
The chi-squared distribution is not symmetrical
The square, i.e. , forces non-negative values. The curve starts
at zero and stretches out to infinity.
We say that such a distribution is a positive distribution.

9
Solution
• Step 3: the critical Value:
  [(r  1)(c  1)]
( 𝑂𝑖𝑗 − 𝐸𝑖𝑗 ) 2 2
𝜒 =∑ ∑
2

𝑖 𝑗 𝐸𝑖𝑗

=
Solution
• Step 3: the critical Value:
  [(r  1)(c  1)]
2 2
( 𝑂𝑖𝑗 − 𝐸𝑖𝑗 )
𝜒 =∑ ∑
2

𝑖 𝑗 𝐸𝑖𝑗

The rejection region is on the right side only for the


distribution of χ2 at degrees of freedom 4 and the 2
𝜒 =59.41
level of significance 0.01 and therefore null
hypothesis is rejected if the calculated value is
13.2767
greater than 13.2767
Solution

• Step 4:
The test statistics fall in the rejection region
Therefore our decision is to reject
The two variables, the preferred beverage and age, are not independent.
Example 2
• A study was conducted on the extent to which the opinions of youth of one
of the political parties in each of the governorates of Cairo and Giza
regarding the new constitution draft are similar. A sample of 500 young
people was withdrawn from each of the two governorates to test the
similarity of the distribution of youth’s views in each of the two
governorates regarding the new draft constitution, and their views were
recorded, and their answers were as follows.
Test whether the opinion is independent of the governorate or not. The
hypothesis was tested at the level of significance 0.01
Example 2 (Cont’d)

Governorate
Cairo Giza Total
opinion

Agree 320 270 590


Disagree 50 100 150
neutral 130 130 260
Total 500 500 1000
Solution
The opinion is independent of governorate
The opinion is not independent of governorate
• Step 2:
The test statistic used:
2
( 𝑂𝑖𝑗 − 𝐸𝑖𝑗 )
𝜒 =∑ ∑
2

𝑖 𝑗 𝐸𝑖𝑗
Example 2 (Cont’d) The test statistics fall in the rejection region
Therefore our decision is to reject
The two variables, the opinion and
governorate, are not independent.
Governorate
Cairo Giza Total
opinion

320 270 600


Agree
(300) (300)

50 100 150
Disagree
(75) (75)

130 130 260


neutral
(130) (130)

Total 500 500 1000

( 𝑂𝑖𝑗 − 𝐸 𝑖𝑗 ) 2
=∑ ∑
2
𝜒 =2 1
𝑖 𝑗 𝐸 𝑖𝑗
21

=
9.2104

You might also like