# Stata Help

## Some Theory Behind Chi-square Tests

Chi-square tests are perhaps the most common nonparametric analysis. A chi-square test looks at frequencies and addresses the question of whether or not those frequencies are what you would expect to find in a population. To illustrate this concept, we'll look at a simple (single-variable) example, then an example with two variables.

For a single-variable chi-square, also known as a chi-square for goodness of fit, you can evaluate one of two types of hypotheses:

1. Questions of differences across groups.

Example: Red-green colorblindness and gender. You could use a chi-square to conclude that color-blindness in our population, by gender, is not what one would expect due to chance. (Chance suggests an equal number of color-blind males and females.) This could be the initial observation that ultimately leads to discovering sex-linked color-blindness.

2. Questions of categorical changes and population differences.

Example: I have a percentage makeup of what political parties people identified with twenty years ago, as well as data on current party identification. I could compare past makeup to a current makeup and hypothesize about whether or not people identify with different political parties than they once did.

To determine if these differences are significant, a chi-square value is calculated. This is done by looking at the difference between the observed (O) and expected values (E) (literally subtracting O-E), squaring it, dividing by E and summing the resulting values. This value is then compared to a chi-square distribution which is mostly influenced by sample size (sample size determines the degrees of freedom for the test).

The multiple variable chi-square, also known as a chi-square for independence, looks at whether variables are independent of one another. The simplest example would be a two-by-two grid with frequencies for each cell. Perhaps I have a theory that men, with their higher metabolism, wear t-shirts more often in all seasons than women. I pick a nice location, like a downtown street and in each season, make a count of men and women in t-shirts versus not. Since the count is not continuous (no one can be counted as wearing 1.5 t-shirts) this chi-square analysis is looking in each season category, if more men or more women wore t-shirts. A nonsignificant chi-square for independence would imply that gender and season did not influence sleeve length.

Unlike the chi-square for goodness of fit, which takes theoretical distribution from a comparison population or from the idea that things ought to be equally distributed, a chi-square test for independence uses the observed values to calculate what is expected.

For a more in-depth explanation of a chi-square analysis, you can follow up with the online Handbook of Biological Statistics.

Back to Nonparametric Tests

Forward to Chi-Square