Descriptive STATISTICS: Chi Square
Introduction: chi square: There are two different chi-square tests: one in which we have different levels of a single categorical variable and one in which we have different levels of two categorical variables. A chi-square test on a single categorical variable is called a chi-square goodness-of-fit test.
 Formula    
       Chi Square  
Restrictions:
1. Chi square can only be used with frequency data.
2. the individual events or observations that constitute the data must be independent of each other.
3. we must have in the data both the frequency of occurrence and the frequency of nonoccurrence if we are recording whether or not an event occurs.
4. no expected frequencies should be less than 5.
Note: an alternative to chi square is the Fisher exact probability test.
 
prgmX2GOF
Line  Command or Statement  Comments
   1.  ClrHome  Clear Screen
   2.  Disp "OBS LIST"  Observed
   3.  Input "L1=",Str1  
   4.  expr("{"+Str1->L1  
   5.  0->A  
   6.  For(I,1,dim(L1  
   7.  A+L1(I)->A  
   8.  End  
   9.  L1->ιθO  
 10.  Disp "EXP LIST  Expected
 11.  Input "L2=",Str2  
 12.  expr("{"+Str2->L2  
 13.  0->B  
 14.  For(J,1,dim(L2  
 15.  B+L2(J)->B  
 16.  End  
 17.  L2->ιθE  
 18.  ClrHome  
 19.  dim(ιθO)-1->K  df
 20.  Fix 4  
 21.  Disp "X2 ="  
 22.  (ιθO-ιθE)²/ιθE->ιCOMP  X2GOF formula
 23.  sum(ιCOMP)->T  
 24.  Output(1,4,T)  
 25.  Disp"P ="  
 26.  Output(2.3.1-X²cdf(0,T,K))  
 27.  Float  
 28.  Disp "df ="  
 29.  Output(3,4,K)  
 30.  Pause  
 31.  ClrHome  
 
Example:
List: Observed: 39, 15, 28, 18
List: Expected: 25, 25, 25, 25
Answers: X ² = 14.16