# Interpretation of chi-squared test for contingency table

I am trying to solve an exercise where I applied the chi-squared test.

I have already calculated the test statistic, the degrees of freedom and the critical value.

At a question we have to determine whether the following sentence is true.

"That is, the bivariate relationship between these two features in the population is only with a probability of about x% (x is the critival value.) is different than that in her sample."

This means that we have to determine if the null hypothesis is accepted or rejected?

We have that when the chi-squared statistic exceeds the critical value then we reject the null hypothesis.

But at the sentence it is not clarified if it exceeds, is it? It says that it is about x%. Does this mean that it does not exceed the critical value?

• You probably need to compute the expected value and the stander-deviation in order to make the hypothesis test. – Pedro Gomes Feb 14 '17 at 21:03
• You mean the expected value of each element of the matrix, which (sum of row)*(sum of column)/(total sum), right? I have calculated these values. How can we use these values to make the hypothesis test? @PedroGomes – Mary Star Feb 14 '17 at 21:06
• Do you have the formula for the hypothesis test? – Pedro Gomes Feb 14 '17 at 21:09
• For the hypothesis testing do we not use the critical value? @PedroGomes – Mary Star Feb 14 '17 at 21:23
• Yes. If it surpasses the critical value you reject null hypothesis. You must look for it on the distribution table. Then compute the test according to the formula and check if it surpasses or not. I have been looking for that chi-squared formula on google. Go on google images and see if it is the one. – Pedro Gomes Feb 14 '17 at 21:28

This is a chi-squared test for the independence of two categorical variables, given data in a $$3 \times 3$$ contingency table.

Under the assumption that 'Religious Preference' and 'Party Affiliation' categories are independent, one estimates the expected cell counts by using the multiplication rule for independence, and the row and column totals. Here is how to find $$E_{11}$$ in the cell for 'Catholic and CDU-CSU'.

$$\hat P(\text{Catholic}) = 549/1739,\; \hat P(\text{CDU-CSU}) = 756/1739,\,\text{ thus }\\ \hat P(\text{Catholic}\cap\text{CDU-CSU}) = \frac{549}{1739}\times\frac{756}{1739}.$$

Then the expected count for this cell is the grand sample size $$1739$$ times the estimated probability, $$E_{11} = \hat E(\text{Cath.}\cap\text{CDU-CSU})= 1739\hat P(\text{Cath.}\cap\text{CDU-CSU})$$ $$= 549(756)/1739 = 238.6682.$$ While observed counts are integers, expected counts need not be integers; do not round expected counts.

The general rule for an expected cell count is "its row total times its column total divided by the grand total."

Then the contribution to chi-squared for cell $$(1,1)$$ is $$\frac{(X_{11} - E_{11})^2}{E_{11}} = \frac{(308 - 238.6682)^2}{238.6682} = 20.141.$$

The chi-squared statistic for this test is the sum of all $$3 \times 3 = 9$$ contributions to the chi-squared statistic:

$$Q = \sum_{i=1}^3 \sum_{j=1}^3 \frac{(X_{ij} - E_{ij})^2}{E_{ij}}.$$

Provided that all $$E_{ij} > 5,$$ the statistic $$Q \stackrel{aprx}{\sim} \mathsf{Chisq}(\nu = 4).$$ (Some authors would say it is OK for a few of the $$E_{ij}$$ to be as small as 3.)

In general $$\nu = (r-1)(c-1),$$ where the table has $$r$$ rows and $$c$$ columns. A rigorous argument for this computation of degrees of freedom $$\nu$$ is difficult to give at an elementary level.

It may help to notice, in the current example, that if only the four observed counts $$X_{11}, X_{12}, X_{21}, X_{22}$$ were given along with the row and column totals, then it would be possible to reconstruct all of 9 of the observed counts. That is to say, given the structure of row and column totals used to find the $$E_{ij},$$ only four of the $$X_{ij}$$ provide additional information.

The Minitab 17 printout for this problem is as follows:

Chi-Square Test for Association: Relig, Worksheet columns

Rows: Relig   Columns: Worksheet columns

CDU    SPD  NotVoted  All

Cath        308    162       79   549
238.7  206.8    103.5
20.141  9.699    5.820

Prot        284    273       80   637
276.9  239.9    120.1
0.181  4.559   13.415

None        164    220      169   553
240.4  208.3    104.3
24.284  0.658   40.129

All         756    655      328  1739

Cell Contents:      Count
Expected count
Contribution to Chi-square

Pearson Chi-Square = 118.885, DF = 4, P-Value = 0.000


First, notice that the expected count and contribution to chi-squared shown for cell $$(1,1)$$ in the Minitab table agree with our earlier computations. [In printouts, Minitab rounds numbers to make displays that fit nicely on a page; internally about 12-place accuracy is maintained throughout the computation.] Also notice that the smallest of the $$E_{ij} \approx 104,$$ very safely larger than 5.

Second notice that $$Q$$ is quite large. If the categories were independent we would expect this statistic to be about 4 (the mean of a chi-squared distribution is its degrees of freedom). The value that cuts 5% from the upper tail of $$\mathsf{Chisq}(4)$$ is 9.4877. This is the critical value for a test at the 5% level.

Sometimes, it is helpful to look at some of the larger contributions to chi-squared. For example, in cell $$(1,1),$$ 308 Catholics voted for CDU-CSU, whereas, under the null hypothesis of independence, one would have expected only about 239 such votes.

However, the P-value for $$Q = 118.885$$ is smaller than 0.0005 (printed as 0.000). So we could also reject at the 1% level and at the 0.1% level. (Maybe for "x%" in your question, you should say something such as: "Reject at any significance level down to 0.0005.") Whatever phrase you choose, the data are very strongly inconsistent with the hypothesis that voting behavior and religious preference are independent.

• Thank you for your answer!! :-) – Mary Star Feb 17 '17 at 22:36