# Contingency tables: Risk, Odds and the χ2 test

#### Objectives

At the end of the lecture and having completed the exercises students should be able to:

1. Explain and calculate the probabilities of outcomes in simple situations
2. Explain what is meant by risk and odds
3. Explain what is meant by risk and odds ratio and calculate them
4. Interpret a χ2 test and know the conditions in which it can be used

### Bibliography

Altman, D.G., 1991. Practical statistics for medical research, pp. 49-50, 250-253, 259-271. Chapman and Hall, London.

Bowers, D., 1997. Statistics further from scratch : for health care professionals, pp. 156-157, 162-163. John Wiley & Sons, Chichester.

## Probability

The probability of an outcome is the number of times the outcome of interest occurs divided by the total number of possible outcomes.

For example: we are rolling a dice and we want to roll a 6. There are six possible outcomes (1 2 3 4 5 6) but only one of interest (6). The probability of rolling a 6 is:

1 ÷ 6 = 0·167 (to three decimal places).

In the paper Caries prevalence in northern Scotland before and 5 years after, water defluoridation (Stephen et al., 1987, BDJ 163: 324-326) the researchers studied two groups of children in Wick; one group whilst the water was fluoridated and one group after defluoridation. Of the 106 children studied before defluoridation 32 of them were from social classes IV and V. So if we were to randomly pick one of the subjects from this group the probability of getting a child from social classes IV or V would be:

Probability = 32 ÷ 106 = 0·30 (to two decimal places)

• Probabilities always lie between 0 and 1
• A probability of 1 means that the outcome is certain
• A probability of 0 means that the outcome is cannot happen

Sometimes people prefer to talk about percentage chances rather than probabilities. The percentage chance is simply 100 times the probability. So in the above case there was a 30% chance that a randomly picked subject was a from social classes IV or V. We prefer probabilities because they are easier to manipulate mathematically

## Risk

Risk means the same thing as probability to a mathematician. Clinicians and epidemiologists tend to use the word risk in a particular way but we still calculate risks in the same way as any other probability: the risk of an outcome is the number of times the outcome of interest occurs divided by the total number of possible outcomes.

For example: In the above study out of 106 children examined whilst the water was fluoridated 77 had caries. So we get the risk of caries whilst the water was fluridated by the following calculation:

Risk = 77 ÷ 106 = 0·73

### Risk ratio

#### (Also called the 'Relative risk')

The table below contains more data from the above study, it shows the number of children who were caries-free in both groups

 Caries Yes No Total Fluoridated 77 29 106 Non-fluoridated 95 31 126 Total 172 60 232

If we want to compare the effects of fluoridated and non-fluoridated water we could calculate the risk of having caries for each group:

Risk of having caries when water is fluoridated = 77 ÷ 106 = 0·73

Risk of having caries when water is not fluoridated = 95 ÷ 126 = 0·75

We can compare the risk for each of the groups using the risk ratio. The risk ratio for being caries free when water is fluoridated compared to when it is not fluoridated is:

(Risk when fluoridated) ÷ (Risk when not fluoridated) = 0·73 ÷ 0·75 = 0·96

So the risk of having caries when the water is fluoridated is only 0·96 that of when the water is not fluoridated. We ought to put a confidence interval on this risk ratio. (You do not need to know how to calculate this, it can be done on SPSS or a spreadsheet is available on this site.) The 95% CI for this risk ratio is from 0·83 to 1·12.

An risk ratio of 1 means there is no difference between the groups

The 95% CI includes 1 so we have a (statistically) non-significant result.

## Odds

The odds in favour of a particular outcome is the number of times the outcome occurs divided by the number of times it doesn't occur.

In the above example, there were 77 children who had caries and 29 who didn't:

Odds = 77 ÷ 29 = 2·66

• Odds of less than 1 mean the outcome occurs less than half the time
• Odds of 1 mean the outcome occurs half the time
• Odds of more than 1 mean the outcome occurs more than half the time

### Odds ratio

If we want to compare the effects of fluoridated and non-fluoridated water we could calculate the odds for each group:

Odds for having caries when water is fluoridated = 77 ÷ 29 = 2·66

Odds for having caries when water is not fluoridated = 95 ÷ 31 = 3·06

We can compare the odds using the odds ratio. The odds ratio for having caries when water is fluoridated compared to when it is not fluoridated is:

(Odds when fluoridated) ÷ (Odds when not fluoridated) = 2·66 ÷ 3·06 = 0·87

So the odds of having caries when the water is fluoridated are about 90% those of when the water is not fluoridated. We ought to put a confidence interval on this odds ratio. (You do not need to know how to calculate this, it can be done on SPSS or a spreadsheet is available on this site.) The 95% CI for this odds ratio is from 0·48 to 1·56.

An odds ratio of 1 means there is no difference between the groups

So we have a statistically non-significant result.

## Risk ratios and Odds ratios

### Case-control studies

The risk ratio cannot be used in case-control study, the odds ratio can be used. Risk ratios cannot be used in studies where selection of subjects is based on the outcome.

### Rare outcomes

When an outcome is rare the risk ratio and odds ratio will be approximately equal.

## The χ2 test

We can perform a hypothesis test on a contingency table. The test we will use most often is the χ2 test.

[χ is a Greek letter usually written chi in English. the pronunciation of the ch is similar to that in the Scottish loch.]

The null hypothesis of the χ2 test is that there is no association between the two variables. The test works by comparing the contingency table we observe from our results with the one we would expect if the null hypothesis were true.

Details of how to perform a χ2 test by hand are on another page. I do not expect you to be able to do this for your assessments. I do expect you to show your awareness of being able to use and interpret χ2tests. Learn how to get SPSS to calculate the results. If your results are already in the form of a contingency table you may find it easier to use the spreadsheet that is available on this site.

#### Observed:

 Caries Yes No Total Fluoridated 77 29 106 Non-fluoridated 95 31 126 Total 172 60 232

#### Expected (under null hypothesis):

 Caries Yes No Total Fluoridated 78·59 27·41 106 Non-fluoridated 93·41 32·59 126 Total 172 60 232

χ2 = 0·228, d.o.f = 1, P = 0·63

As P > 0·05 we cannot reject the null hypothesis of no association

### Conditions for the χ2 test

• All expected values must be greater than 1
• 80% of expected values must be greater than 5

### Continuity correction (Yates's correction)

For small sample sizes the χ2 test is too likely to reject the null hypothesis. A continuity correction can be made to allow for this. Although it is only strictly necessary on small sample sizes I would recommend always using it. The two conditions above still have to be met.

### Fisher's exact test

If a 2 x 2 contingency table fails to meet the conditions required for the χ2 test then Fisher's exact test can be used. This is based on different mathematics to the χ2 test which are more robust when sample sizes are small.

### What to do if larger tables fail to meet the requirements of the χ2 test

The best option is to combine categories.