You are on page 1of 5

Reading material for private circulation only

CHI-SQUARE TEST

By

GAURANG RAMI
grami@rediffmail.com

Chisquare testTest:
( oi ei )2
c =
i = 1
ei
k

k - 1

where,
oi = observed (actual) frequency
ei = expected (theoretical ) frequency
k = number of categories
k-1 = degrees of freedom

Two uses:
(1) Testing Goodness of Fit
i.e. how well a theoretical distribution fits the observed data.
Here,
Ho: sample data are consistent with the theoretical distribution
H1: sample data are not consistent with the theoretical distribution
Example:
The data on demand of a commodity on various days of a week are as follows:
Test the hypothesis that demand does not depend upon the day of the week.
Day:

Demand:

124

125

110

120

126

115

Ho: Demand does not depend upon the day of the week.
H1: Demand does depend upon the day of the week.
If Ho is correct, demand on each day = Total demand / 6 = 120

k
( oi ei )2
c =
i = 1
ei
= (124 120)2 / 120 + ------- + (115-120)2 / 120
= 1.683
As the table values are 11.07 and 15.09 at 5 % and 1 % levels
respectively,
Ho is not rejected
Demand does not depend upon day of the week.
(2) Test of independence
Suppose we have a two way classification according to two different
attributes (Qualitative variables) as follows:
Attribute B
Present
Absent
Total

Attribute A
Present
Absent
a
b
c
d
a+c
b+d

Total
a+b
c+d
n = a+b+c+d

We want to test whether these two attributes are independent or not.


So, we set up Ho: they are independent (not related)
H1: they are not independent
3

If Ho is true, we can find out the expected (theoretical) frequency of


each cell as follows
Expected Frequency
(a+b)*(a+c) / n
(a+b)*(b+d) / n
(a+c)*(c+d) / n
(c+d)*(b+d) / n
Then.
k
( oi ei )2
c =
i = 1
ei

with d.f = (r-1) (c-1)

where r is number of rows and c is number of columns


If c > t, Ho is rejected
If not, Ho is not rejected
Example:
300 persons are classified on the basis of (i) their smoking habits and
(ii) whether they suffer from cancer or not. The relevant data are given
in the following table.

Smokers
Non-smokers
Total
Suppose

Suffer from
cancer
O1 = 30
O3 = 20
50

Do no suffer
from cancer
O2 = 70
O4 = 180
250

Total
100
200
300

Ho: Two attributes are independent


H1: They are related

Calculation of expected frequencies:


4

Expected frequency of (S,C) cell = 100 * 50 / 300 = 17 = e1


(S, NC) cell = 100 * 250 / 300

= 83 = e2--------

Then.
4
( oi ei )2
c =
i = 1
ei

= (30-17)2 / 17+.+(180-167)2 / 167


= 18.11
Now t for (2-1)(2-1) = 1*1=1 d.f. = 3.84 and 6.64 at 5 % and 1 %
levels respectively.
As c > t, Ho is rejected at 99 % level
Cancer and smoking are related.

You might also like