Chi square test
Jagdish D. Powar
Statistician cum Tutor
Community Medicine
SMBT, IMSRC, Nashik
JDP-CM-SMBT 1
Competency & Learning objectives
2
Competency SLOs(Core)
CM6.3,
Describe, discuss and demonstrate
the application of elementary
statistical methods including test of
significance in various study
designs
The student should be able to
 Write a Null hypothesis and
alternative hypothesis for chi-
square test.
 Prepare contingency table.
 Perform chi-square test
association.
JDP-CM-SMBT
Chi-square test:-
 Chi-square used to test the association between two qualitative
variables.
 Null hypothesis Ho : There is no association i.e. attribute or
qualitative variables are independent.
 H1: There is association i.e. qualitative variables are dependent.
 Test statistics:-
χ2 =∑
𝑂−𝐸 2
𝐸
; E=
𝑅𝑜𝑤 𝑡𝑜𝑡𝑎𝑙 ∗𝑐𝑜𝑙𝑢𝑚𝑛 𝑡𝑜𝑡𝑎𝑙
𝐺𝑟𝑎𝑛𝑑 𝑡𝑜𝑡𝑎𝑙
d.f. = (r-1)*(c-1).
Find the table value from chi-square table value for (r-1)*(c-1) df
 Decision Rule:-
if chi-square cal > chi table then reject the NH.
JDP-CM-SMBT 3
1. The type of work and obesity distribution of 370
employees of SMBT, IMSRC, and Nashik is given below.
(χ2 df=2,5% =5.99)
a) Write the null and alternative hypothesis to test the
association.
b) Write the formula of Chi-square test statistic.
c) Test whether there is association between type of work
and obesity
Type of
Work
Central
Obesity
Moderate
Obesity
Normal TOTAL
Moderate 24 65 96 185
Sedentary 42 69 74 185
TOTAL 66 134 170 370
JDP-CM-SMBT 4
• Chi square test
• H0: There is no significant association between nature
of work and obesity.
• H1: There is significant association between nature of
work and obesity.
• Formula of Chi-square test statistic
• χ2 =∑
𝑶−𝑬 𝟐
𝑬
;
O = observed frequencies (values)
E= expected frequencies=
𝑅𝑜𝑤 𝑡𝑜𝑡𝑎𝑙 ∗ 𝑐𝑜𝑙𝑢𝑚𝑛 𝑡𝑜𝑡𝑎𝑙
𝐺𝑟𝑎𝑛𝑑 𝑡𝑜𝑡𝑎𝑙
• d.f. = (r-1)*(c-1),
r= no. of rows c= no. of columns
JDP-CM-SMBT 5
• Xcal
2 =∑
𝑶−𝑬 𝟐
𝑬
= 7.88 Xtab
2 =5.99
• X2
cal > X2
tab hence reject the null hypothesis.
• Conclusion
There is significant association between nature of work
and obesity.
Oi Ei (Oi-Ei)^2 (Oi-Ei)^2 /Ei
24 33 81 2.45
65 67 4 0.06
96 85 121 1.42
42 33 81 2.45
69 67 4 0.06
74 85 121 1.42
∑
𝑶−𝑬 𝟐
𝑬
=7.88
JDP-CM-SMBT 6
For 2x2 contingency table i.e. two row and two column.
The value of χ2 value can be calculated directly
χ2 =
𝑁 𝑎𝑑−𝑏𝑐 2
𝑎+𝑏 ∗ 𝑐+𝑑 ∗ 𝑎+𝑐 ∗(𝑏+𝑑)
with df=1,
 Decision Rule:-
if chi-square cal > chi table then reject it.
Qualitative
variables
Var 2
Total
Var 1
a b (a+b)
c d (c+d)
total a+c b+d N= a+b+c+d
JDP-CM-SMBT 7
1) Determine if there is any association between whooping cough and
tonsillectomy when in a random sample of 100 children of a school,
25 had a tonsillectomy done and 60 had whooping cough and 10 had
both while 25 had none. (χ2 df=1 ,5% =3.84)
Whooping
cough
No whooping
cough
Total
Tonsillectomy 10 15 25
Non
tonsillectomy
50 25 75
Total 60 40 100
JDP-CM-SMBT 8
• Chi square test
• H0: There is no significant association between
whooping cough and tonsillectomy
• H1: There is significant association whooping
cough and tonsillectomy
• Formula of Chi-square test statistic
• χ2 =
𝑁 𝑎𝑑−𝑏𝑐 2
𝑎+𝑏 ∗ 𝑐+𝑑 ∗ 𝑎+𝑐 ∗(𝑏+𝑑)
=
100 10∗25−15∗50 2
25∗75∗60∗40
χ2 cal = 5.55 > χ2 tab=3.84
Reject the null hypothesis.
Conclusion-There is significant association
whooping cough and tonsillectomy
JDP-CM-SMBT 9
JDP-CM-SMBT 10
11
Thank You

Chi square test

  • 1.
    Chi square test JagdishD. Powar Statistician cum Tutor Community Medicine SMBT, IMSRC, Nashik JDP-CM-SMBT 1
  • 2.
    Competency & Learningobjectives 2 Competency SLOs(Core) CM6.3, Describe, discuss and demonstrate the application of elementary statistical methods including test of significance in various study designs The student should be able to  Write a Null hypothesis and alternative hypothesis for chi- square test.  Prepare contingency table.  Perform chi-square test association. JDP-CM-SMBT
  • 3.
    Chi-square test:-  Chi-squareused to test the association between two qualitative variables.  Null hypothesis Ho : There is no association i.e. attribute or qualitative variables are independent.  H1: There is association i.e. qualitative variables are dependent.  Test statistics:- χ2 =∑ 𝑂−𝐸 2 𝐸 ; E= 𝑅𝑜𝑤 𝑡𝑜𝑡𝑎𝑙 ∗𝑐𝑜𝑙𝑢𝑚𝑛 𝑡𝑜𝑡𝑎𝑙 𝐺𝑟𝑎𝑛𝑑 𝑡𝑜𝑡𝑎𝑙 d.f. = (r-1)*(c-1). Find the table value from chi-square table value for (r-1)*(c-1) df  Decision Rule:- if chi-square cal > chi table then reject the NH. JDP-CM-SMBT 3
  • 4.
    1. The typeof work and obesity distribution of 370 employees of SMBT, IMSRC, and Nashik is given below. (χ2 df=2,5% =5.99) a) Write the null and alternative hypothesis to test the association. b) Write the formula of Chi-square test statistic. c) Test whether there is association between type of work and obesity Type of Work Central Obesity Moderate Obesity Normal TOTAL Moderate 24 65 96 185 Sedentary 42 69 74 185 TOTAL 66 134 170 370 JDP-CM-SMBT 4
  • 5.
    • Chi squaretest • H0: There is no significant association between nature of work and obesity. • H1: There is significant association between nature of work and obesity. • Formula of Chi-square test statistic • χ2 =∑ 𝑶−𝑬 𝟐 𝑬 ; O = observed frequencies (values) E= expected frequencies= 𝑅𝑜𝑤 𝑡𝑜𝑡𝑎𝑙 ∗ 𝑐𝑜𝑙𝑢𝑚𝑛 𝑡𝑜𝑡𝑎𝑙 𝐺𝑟𝑎𝑛𝑑 𝑡𝑜𝑡𝑎𝑙 • d.f. = (r-1)*(c-1), r= no. of rows c= no. of columns JDP-CM-SMBT 5
  • 6.
    • Xcal 2 =∑ 𝑶−𝑬𝟐 𝑬 = 7.88 Xtab 2 =5.99 • X2 cal > X2 tab hence reject the null hypothesis. • Conclusion There is significant association between nature of work and obesity. Oi Ei (Oi-Ei)^2 (Oi-Ei)^2 /Ei 24 33 81 2.45 65 67 4 0.06 96 85 121 1.42 42 33 81 2.45 69 67 4 0.06 74 85 121 1.42 ∑ 𝑶−𝑬 𝟐 𝑬 =7.88 JDP-CM-SMBT 6
  • 7.
    For 2x2 contingencytable i.e. two row and two column. The value of χ2 value can be calculated directly χ2 = 𝑁 𝑎𝑑−𝑏𝑐 2 𝑎+𝑏 ∗ 𝑐+𝑑 ∗ 𝑎+𝑐 ∗(𝑏+𝑑) with df=1,  Decision Rule:- if chi-square cal > chi table then reject it. Qualitative variables Var 2 Total Var 1 a b (a+b) c d (c+d) total a+c b+d N= a+b+c+d JDP-CM-SMBT 7
  • 8.
    1) Determine ifthere is any association between whooping cough and tonsillectomy when in a random sample of 100 children of a school, 25 had a tonsillectomy done and 60 had whooping cough and 10 had both while 25 had none. (χ2 df=1 ,5% =3.84) Whooping cough No whooping cough Total Tonsillectomy 10 15 25 Non tonsillectomy 50 25 75 Total 60 40 100 JDP-CM-SMBT 8
  • 9.
    • Chi squaretest • H0: There is no significant association between whooping cough and tonsillectomy • H1: There is significant association whooping cough and tonsillectomy • Formula of Chi-square test statistic • χ2 = 𝑁 𝑎𝑑−𝑏𝑐 2 𝑎+𝑏 ∗ 𝑐+𝑑 ∗ 𝑎+𝑐 ∗(𝑏+𝑑) = 100 10∗25−15∗50 2 25∗75∗60∗40 χ2 cal = 5.55 > χ2 tab=3.84 Reject the null hypothesis. Conclusion-There is significant association whooping cough and tonsillectomy JDP-CM-SMBT 9
  • 10.
  • 11.