Professional Documents
Culture Documents
edu/statprogram)
Home>4.0ChiSquareTests
4.0ChiSquareTests
ChiSquareTestofIndependence
Doyourememberhowtotesttheindependenceoftwocategoricalvariables?ThistestisperformedbyusingaChisquare
testofindependence.
Recallthatwecansummarizetwocategoricalvariableswithinatwowaytable,alsocalledarccontingencytable,wherer
=numberofrows,c=numberofcolumns.OurquestionofinterestisArethetwovariablesindependent?Thisquestionis
setupusingthefollowinghypothesisstatements:
NullHypothesis:Thetwocategoricalvariablesareindependent.
AlternativeHypothesis:Thetwocategoricalvariablesaredependent.
Thechisquareteststatisticiscalculatedbyusingtheformula:
= (O E) /E
whereOrepresentstheobservedfrequency.Eistheexpectedfrequencyunderthenullhypothesisandcomputedby:
Wewillcomparethevalueoftheteststatistictothecriticalvalueof2 withdegreeoffreedom=(r1)(c1),andrejectthe
nullhypothesisif2 > 2 .
Example
Isgenderindependentofeducationlevel?Arandomsampleof395peopleweresurveyedandeachpersonwasaskedto
reportthehighesteducationleveltheyobtained.Thedatathatresultedfromthesurveyissummarizedinthefollowingtable:
HighSchool
Bachelors
Masters
Ph.d.
Total
Female
60
54
46
41
201
Male
40
44
53
57
194
100
98
99
98
395
Total
Question:Aregenderandeducationleveldependentat5%levelofsignificance?Inotherwords,giventhedatacollected
above,istherearelationshipbetweenthegenderofanindividualandthelevelofeducationthattheyhaveobtained?
Here'sthetableofexpectedcounts:
HighSchool
Bachelors
Masters
Ph.d.
Total
Female
50.886
49.868
50.377
49.868
201
Male
49.114
48.132
48.623
48.132
194
100
98
99
98
395
Total
So,workingthisout,2
Thecriticalvalueof2 with3degreeoffreedomis7.815.Since8.006>7.815,thereforewerejectthenullhypothesisand
concludethattheeducationleveldependsongenderata5%levelofsignificance.
UsingMinitab
WecanenterthedataintoMinitabandrequestthatthe'Chisquaretest'beconductedfortheabovehypotheses.The
Minitaboutputforthisexampleisshownbelow:
TheChisquaretestofindependencevaluethatMinitabcalculatedis8.006,whichisthesameaswecalculatedabove.
TheChisquaretestforindependenceisanimportantmethodfordeterminingifthereisarelationshipbetweenvariables
wherethechancethatsomethingfallsintoaparticularcategorydependsonwhetherthevariablefallsintoanothercategory
comesintoplay.Thisrelationshipofindependence/dependenceisimportanttobeabletounderstandanduse.
ChiSquareGoodnessofFitTests
Doyourememberhowtousethechisquaregoodnessoffittesttotestwhetherrandomcategoricalvariablesfollowa
particularprobabilitydistribution?Let'stakealookatanexample:
Example
SupposethePennStatestudentpopulationis20%PAresidentand80%nonPAresident.Then,ifasampleof100students
yields16PAresidentand84nonPAresident,how'good'dothedata'fit'theassumedprobabilitymodelof20%PAresident
and80%nonPAresident?
Wecanusethechisquaregoodnessoffitstatistictotestthe
hypothesesstatements:
NullHypothesis:Pr
= 0.2
AlternativeHypothesis:Pr
0.2
Workingthisoutweget,
2
(16 20)
=
(84 80)
+ +
20
= 1
80
Thecriticalvalueof2 with1degreeoffreedomis3.84.Since1<
3.84,wecannotrejectthenullhypothesis.Thereisnotenough
evidencetoconcludethatthedatadon'tfittheassumedprobability
modelat5%levelofsignificance.Inotherwords,thestudentsthatwere
randomlyselectedinthisexampledidresembletheprobabilitydistributionthatwasspecified.
SourceURL:https://onlinecourses.science.psu.edu/statprogram/node/158