Computations for the First Chi

advertisement
252chisqx2 10/27/06
Computations for the First Chi-squared example.
————— 10/27/2006 5:10:10 PM ————————————————————
Welcome to Minitab, press F1 for help.
MTB > PRINT C11-C14
Data Display
Row
1
2
3
O1
10
5
15
O2
15
10
15
O3
15
15
10
O4
10
10
20
This is the original O table. Top line is labels.
This is the same data as you were given for
the first problem that I did in class.
MTB > chisq c11-c14
Chi-Square Test: O1, O2, O3, O4
Expected counts are printed below observed counts
Chi-Square contributions are printed below expected counts
O1
10
10.00
0.000
O2
15
13.33
0.208
O3
15
13.33
0.208
O4
10
13.33
0.833
Total
50
2
5
8.00
1.125
10
10.67
0.042
15
10.67
1.760
10
10.67
0.042
40
3
15
12.00
0.750
15
16.00
0.063
10
16.00
2.250
20
16.00
1.000
60
Total
30
40
40
40
150
1
These are the column labels.
This is the first line of the O
This is the first line of the E
This is (E – O) squared, divided by E.
Chi-Sq = 8.281, DF = 6, P-Value = 0.218
All that you have here is the value of chisquared that we computed in class, the
degrees of freedom that we computed in
class and a p-value which is too high for us
to reject the null hypothesis of independence
or homogeneity.
MTB
MTB
MTB
MTB
MTB
MTB
MTB
I am now setting up the problem as we did it
in class. The original data stays in columns
11-13. C14 is the sum of the rows. C15 is
the proportion in each row. By multiplying
the column totals by the row proportions
I got E.
>
>
>
>
>
>
>
let c15 = c11+c12+c13+c14
let c16 = c15/sum(c15)
let c17 = c16*sum(O1)
let c18 = c16*sum(O2)
let c19 = c16*sum(O3)
let c20 = c16*sum(O4)
print c11-c20
Data Display
Row
1
2
3
O1
10
5
15
O2
15
10
15
O3
15
15
10
O4
10
10
20
sumO
50
40
60
pr
0.333333
0.266667
0.400000
E1
10
8
12
E2
13.3333
10.6667
16.0000
E3
13.3333
10.6667
16.0000
E4
13.3333
10.6667
16.0000
252chisqx2 10/27/06
MTB
MTB
MTB
MTB
MTB
>
>
>
>
>
Stack c11-c14 c1.
stack c17-c20 c2
let ‘O-E’ = C1 – C2'
let chisq1 = 'O-E' * 'O-E'
let chisq1 = chisq1/E
To do the chi-squared computations I
stacked the O columns in C1 and the E
columns in C2. O – E was computed.
The last column was computed by squaring
(O – E) and then dividing by E.
MTB > sum chisq1
Sum of chisq1
This is the value of chi-squared we got.
Sum of chisq1 = 8.28125
MTB > print c1-c4
This is the table we had in class.
Data Display
Row
1
2
3
4
5
6
7
8
9
10
11
12
MTB
MTB
MTB
MTB
O
10
5
15
15
10
15
15
15
10
10
10
20
>
>
>
>
E
10.0000
8.0000
12.0000
13.3333
10.6667
16.0000
13.3333
10.6667
16.0000
13.3333
10.6667
16.0000
let
let
let
let
O-E
0.00000
-3.00000
3.00000
1.66667
-0.66667
-1.00000
1.66667
4.33333
-6.00000
-3.33333
-0.66667
4.00000
chisq1
0.00000
1.12500
0.75000
0.20833
0.04167
0.06250
0.20833
1.76042
2.25000
0.83333
0.04167
1.00000
c7 = c11/sum(c11)
c8 = c12/sum(c12)
c9 = c13/sum(c13)
c10 = c14/sum(c14)
To demonstrate the computations in
Chisqnote I made C7 – C11 into proportions
of their column sum. These were stacked in
C6. This is O in proportions.
MTB > stack c7 c8 c9 c10 c6
MTB > print c7 - c10
Data Display
Row
1
2
3
C7
0.333333
0.166667
0.500000
C8
0.375
0.250
0.375
C9
0.375
0.375
0.250
C10
0.25
0.25
0.50
MTB > stack c16 c16 c16 c16 c7
MTB > print c6 c7
Data Display
Row
1
2
3
4
5
6
7
8
9
10
11
12
C6
0.333333
0.166667
0.500000
0.375000
0.250000
0.375000
0.375000
0.375000
0.250000
0.250000
0.250000
0.500000
C7
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
To get E as proportions I stacked the row
proportions in C7.
252chisqx2 10/27/06
MTB > let c8 = c6
MTB > let c9 = c7
To protect my work, I copied it into C8 and C9.
MTB > print c8 c9 c10
Data Display
Row
1
2
3
4
5
6
7
8
9
10
11
12
pbars
0.333333
0.166667
0.500000
0.375000
0.250000
0.375000
0.375000
0.375000
0.250000
0.250000
0.250000
0.500000
p0s
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
csums
30
30
30
40
40
40
40
40
40
40
40
40
I am now computing  2 
MTB > let c5 = c8 - c9

ij
 pij  pi0 2
pi0
nj
. This
is the method described in chisquarednote.
MTB > print c5 c8 c9
Data Display
Row
1
2
3
4
5
6
7
8
9
10
11
12
C5
0.000000
-0.100000
0.100000
0.041667
-0.016667
-0.025000
0.041667
0.108333
-0.150000
-0.083333
-0.016667
0.100000
C5 is the difference between expected and observed.
pbars
0.333333
0.166667
0.500000
0.375000
0.250000
0.375000
0.375000
0.375000
0.250000
0.250000
0.250000
0.500000
MTB > let c5 = c5*c5
MTB > let c5 = c5*c10
MTB > let c5 = c5/c9
MTB > sum c4
Sum of chisq1
Sum of chisq1 = 8.28125
MTB > sum c5
Sum of chisq2
Sum of chisq2 = 8.53125
p0s
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
To get chi-squared, square C5. Multiply result by co
column sums.
252chisqx2 10/27/06
MTB > print c4 c5 c8 c9 c10
Data Display
Row
1
2
3
4
5
6
7
8
9
10
11
12
chisq1
0.00000
1.12500
0.75000
0.20833
0.04167
0.06250
0.20833
1.76042
2.25000
0.83333
0.04167
1.00000
chisq2
0.00000
1.12500
1.00000
0.20833
0.04167
0.06250
0.20833
1.76042
2.25000
0.83333
0.04167
1.00000
pbars
0.333333
0.166667
0.500000
0.375000
0.250000
0.375000
0.375000
0.375000
0.250000
0.250000
0.250000
0.500000
p0s
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
0.333333
0.266667
0.400000
csums
30
30
40
40
40
40
40
40
40
40
40
40
Results for: ChiEx1a.MTW
MTB > WSave "C:\Documents and Settings\RBOVE\My Documents\Minitab\ChiEx1a.MTW";
SUBC>
Replace.
Saving file as: 'C:\Documents and Settings\RBOVE\My
Documents\Minitab\ChiEx1a.MTW'
MTB >
Download