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 O1 O2 O3 O4This is the original O table. Top line is labels.

1 10 15 15 10This is the same data as you were given for

2 5 10 15 10the first problem that I did in class.

3 15 15 10 20

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 O2 O3 O4 TotalThese are the column labels.

1 10 15 15 10 50This is the first line of the O

10.00 13.33 13.33 13.33This is the first line of the E

0.000 0.208 0.208 0.833This is (E – O) squared, divided by E.

2 5 10 15 10 40

8.00 10.67 10.67 10.67

1.125 0.042 1.760 0.042

3 15 15 10 20 60

12.00 16.00 16.00 16.00

0.750 0.063 2.250 1.000

Total 30 40 40 40 150

Chi-Sq = 8.281, DF = 6, P-Value = 0.218All that you have here is the value of chi- squared 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 > let c15 = c11+c12+c13+c14I am now setting up the problem as we did it

MTB > let c16 = c15/sum(c15)in class. The original data stays in columns

MTB > let c17 = c16*sum(O1)11-13. C14 is the sum of the rows. C15 is

MTB > let c18 = c16*sum(O2)the proportion in each row. By multiplying

MTB > let c19 = c16*sum(O3)the column totals by the row proportions

MTB > let c20 = c16*sum(O4)I got E.

MTB > print c11-c20

Data Display

Row O1 O2 O3 O4 sumO pr E1 E2 E3 E4

1 10 15 15 10 50 0.333333 10 13.3333 13.3333 13.3333

2 5 10 15 10 40 0.266667 8 10.6667 10.6667 10.6667

3 15 15 10 20 60 0.400000 12 16.0000 16.0000 16.0000

MTB > Stack c11-c14 c1.To do the chi-squared computations I

MTB > stack c17-c20 c2stacked the O columns in C1 and the E

MTB > let ‘O-E’ = C1 – C2'columns in C2. O – E was computed.

MTB > let chisq1 = 'O-E' * 'O-E'The last column was computed by squaring

MTB > let chisq1 = chisq1/E(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-c4This is the table we had in class.

Data Display

Row O E O-E chisq1

1 10 10.0000 0.00000 0.00000

2 5 8.0000 -3.00000 1.12500

3 15 12.0000 3.00000 0.75000

4 15 13.3333 1.66667 0.20833

5 10 10.6667 -0.66667 0.04167

6 15 16.0000 -1.00000 0.06250

7 15 13.3333 1.66667 0.20833

8 15 10.6667 4.33333 1.76042

9 10 16.0000 -6.00000 2.25000

10 10 13.3333 -3.33333 0.83333

11 10 10.6667 -0.66667 0.04167

12 20 16.0000 4.00000 1.00000

MTB > let c7 = c11/sum(c11)To demonstrate the computations in

MTB > let c8 = c12/sum(c12)Chisqnote I made C7 – C11 into proportions

MTB > let c9 = c13/sum(c13)of their column sum. These were stacked in MTB > let c10 = c14/sum(c14) C6. This is O in proportions.

MTB > stack c7 c8 c9 c10 c6

MTB > print c7 - c10

Data Display

Row C7 C8 C9 C10

1 0.333333 0.375 0.375 0.25

2 0.166667 0.250 0.375 0.25

3 0.500000 0.375 0.250 0.50

MTB > stack c16 c16 c16 c16 c7To get E as proportions I stacked the row

MTB > print c6 c7proportions in C7.

Data Display

Row C6 C7

1 0.333333 0.333333

2 0.166667 0.266667

3 0.500000 0.400000

4 0.375000 0.333333

5 0.250000 0.266667

6 0.375000 0.400000

7 0.375000 0.333333

8 0.375000 0.266667

9 0.250000 0.400000

10 0.250000 0.333333

11 0.250000 0.266667

12 0.500000 0.400000

MTB > let c8 = c6To protect my work, I copied it into C8 and C9.

MTB > let c9 = c7

MTB > print c8 c9 c10

Data Display

Row pbars p0s csums

1 0.333333 0.333333 30

2 0.166667 0.266667 30

3 0.500000 0.400000 30

4 0.375000 0.333333 40

5 0.250000 0.266667 40

6 0.375000 0.400000 40

7 0.375000 0.333333 40

8 0.375000 0.266667 40

9 0.250000 0.400000 40

10 0.250000 0.333333 40

11 0.250000 0.266667 40

12 0.500000 0.400000 40

MTB > let c5 = c8 - c9I am now computing. This is the method described in chisquarednote.

MTB > print c5 c8 c9

Data Display C5 is the difference between expected and observed.

Row C5 pbars p0s

1 0.000000 0.333333 0.333333

2 -0.100000 0.166667 0.266667

3 0.100000 0.500000 0.400000

4 0.041667 0.375000 0.333333

5 -0.016667 0.250000 0.266667

6 -0.025000 0.375000 0.400000

7 0.041667 0.375000 0.333333

8 0.108333 0.375000 0.266667

9 -0.150000 0.250000 0.400000

10 -0.083333 0.250000 0.333333

11 -0.016667 0.250000 0.266667

12 0.100000 0.500000 0.400000

MTB > let c5 = c5*c5To get chi-squared, square C5. Multiply result by co

MTB > let c5 = c5*c10column sums.

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

MTB > print c4 c5 c8 c9 c10

Data Display

Row chisq1 chisq2 pbars p0s csums

1 0.00000 0.00000 0.333333 0.333333 30

2 1.12500 1.12500 0.166667 0.266667 30

3 0.75000 1.00000 0.500000 0.400000 40

4 0.20833 0.20833 0.375000 0.333333 40

5 0.04167 0.04167 0.250000 0.266667 40

6 0.06250 0.06250 0.375000 0.400000 40

7 0.20833 0.20833 0.375000 0.333333 40

8 1.76042 1.76042 0.375000 0.266667 40

9 2.25000 2.25000 0.250000 0.400000 40

10 0.83333 0.83333 0.250000 0.333333 40

11 0.04167 0.04167 0.250000 0.266667 40

12 1.00000 1.00000 0.500000 0.400000 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 >