# Two-Dimensional Tables with Chi-Square

A two-dimensional table can cross one categorical variable by another categorical variable. This may be useful, for example, if you which to know the breakdown of class for each sex. The following example produces a two-dimensional table of 'SEX' by 'CLASS', and requests a chi-square statistic on the table.

`MTB> TABLE 'SEX' 'CLASS';`

SUBC> CHISQ 3.

The "3" next to the Chi Square requests that the count, the expected count, and the standardized residual be put into each cell.

Here are the results:

ROWS: sex COLUMNS: class

1 2 3 4 ALL

1 7 2 1 1 11

4.95 2.20 1.65 2.20 11.00

0.92 -0.13 -0.51 -0.81 --

2 2 2 2 3 9

4.05 1.80 1.35 1.80 9.00

-1.02 0.15 0.56 0.89 --

ALL 9 4 3 4 20

9.00 4.00 3.00 4.00 20.00

-- -- -- -- --

CHI-SQUARE = 3.951 WITH D.F.= 3

CELL CONTENTS --

COUNT

EXP FREQ

STD RES

Here we see that 7 males are also freshman, where 2 males are sophomores, 1 is a junior, and 1 is a senior. 2 females are freshman, 2 are sophomores, 2 are juniors, and 3 are seniors. The chi-square statistic tests whether there is a significant difference between the two sexes as to how they are distributed among the classes. The chi-square statistic is used to determine this. The probability of chi-square is not given. If we looked up a chi-square with alpha of .05 and 3 degrees of freedom, we would find the value to be 7.81. Since 3.951 is less than 7.81, we cannot conclude that there is a difference between sexes.

The expected count and standardized residual are shown in each cell. This is helpful in determining which cells contributed greatest in the calculation of the chi-square.