CSDELUXE Program for TI-83 or TI-83 PLUS
Covers all three chi-square tests and computes the contributions to c2
Written by Mr. Hansen for the Class of 2003
Rev.
Purpose: This “c2 Deluxe” program combines the functionality of CHISQGOF and the TI-83 STAT TESTS C into a single easy-to-use package. Additional features: · Contributions to the c2 statistic are saved for the user’s inspection. During a goodness-of-fit test, the contributions to c2 are saved in list L1. During a 2-way table test (for independence or homogeneity of proportions), the contributions to c2 are saved in matrix [C]. · The program performs some error checking to reduce the likelihood of erroneous results caused by input errors. · The program warns the user if any expected cell counts are <5. The user can then manually check to make sure that the typical rule of thumb (all expected counts ³1, no more than 20% of them <5) is still satisfied. · Note: You can learn a lot about how the c2 tests work by reading the program. Do you understand what each step is doing? |
This is the text (HTML) version of the program listing. If you have TI-GRAPH LINK or TI CONNECT software and wish to download the program directly, please click here instead.
Program Listing:
ClrHome
Disp " c2 DELUXE"
Disp "E.M.HANSEN, 4/03"
Disp "---------------"
Disp "FINDS CONTRIBS."
Disp "TO c2 STATISTIC"
Output(7,1,"PRESS 1 FOR GOF,")
Output(8,1,"2 FOR 2-WAY c2:")
Lbl 5
getKey
If Ans=92
Goto 1
If Ans=93
Goto 2
Goto 5
Lbl 1
ClrHome
Disp "INPUTS:"
Disp "L2=EXP., L3=OBS."
Disp ""
Disp "OUTPUT:"
Disp "CONTRIBS. IN L1"
Disp ""
Output(7,1,"PRESS 'ENTER' IF")
Output(8,1,"OK,'ON' TO QUIT:")
Pause
(L3–L2)2/L2®L1
ClrHome
If sum(L2)¹sum(L3)
Then
Disp "ERROR: sum(L2)"
Disp " and sum(L3)"
Disp " MUST BOTH = n."
Stop
End
For(I,1,dim(L2),1)
If L3(I)<0 or L3(I)¹int(L3(I))
Then
Disp "ERROR: OBSERVED"
Disp " COUNTS IN L3"
Disp " MUST ALL BE"
Disp " WHOLE NUMBERS."
Stop
End
End
If min(L2)<5
Then
Disp "WARNING: SOME"
Disp "EXPECTED COUNTS"
Disp "ARE <5. CHECK L2"
Disp "TO BE SURE ALL"
Disp "ASSUMPTIONS FOR"
Disp "c2 GOODNESS-OF-"
Disp "FIT ARE MET."
Output(8,1,"'ENTER' TO CONT.")
Pause
End
sum(L1)®C
dim(L2)–1®D
c2cdf(C,99999,D)®P
ClrHome
Disp "CHECK L1 TO SEE"
Disp "CONTRIBS. TO c2."
Lbl 4
Disp "c2="
Output(3,4,C)
Disp "df="
Output(4,4,D)
Disp "p="
Disp P
Stop
Lbl 2
ClrHome
Disp "INPUT:"
Disp "MATRIX [A]=OBS."
Disp ""
Disp "OUTPUTS:"
Disp "[B]=EXP.,
[C]="
Disp "CONTRIBS. TO c2."
Output(7,1,"PRESS 'ENTER'
IF")
Output(8,1,"OK,'ON' TO QUIT:")
Pause
ClrHome
dim([A])®∟DIM
[A]–[A]®[B]
[B]®[C]
∟DIM(1)®R
∟DIM(2)®C
c2-Test([A],[B])
0®F
For(I,1,R,1)
For(J,1,C,1)
[A](I,J)®O
[B](I,J)®E
(O–E)2/E®[C](I,J)
If E<5
Then
1®F
End
End
End
If F>0
Then
Disp "WARNING: SOME"
Disp "EXPECTED COUNTS"
Disp "ARE <5. INSPECT"
Disp "MATRIX [B] TO"
Disp "BE SURE THE
Disp "SUMPTIONS FOR 2-"
Disp "WAY c2 ARE MET."
Output(8,1,"'ENTER' TO CONT.")
Pause
End
c2®C
df®D
p®P
ClrHome
Disp "CHECK [C] TO SEE"
Disp "CONTRIBS. TO c2."
Goto 4
When the program ends, variable C holds the value of the c2 statistic, variable D holds the degrees of freedom, and variable P holds the P-value of the test. You can then use these in other computations if you wish.
As you are entering the program above, you may find the following hints to be helpful: