# Hypothesis Testing: Chi-Square Tests

Hypothesis Testing uses statistics to choose between hypotheses regarding whether data is statistically significant or occurred by chance alone. One type of hypothesis tests are Chi-Square tests, which are tests that examine whether the frequency of certain categorical values, such as the number of individuals in a group, differs from the frequency distribution expected from random chance alone. The Chi-Square Goodness of Fit Test does this for one variable at a time, and the Test of Independence: Pearson's Chi-Square does this as well but can also test whether multiple categorical variables are significantly associated.

### Goodness of Fit Test

A Chi-Square Goodness of Fit Test examines whether the frequency of certain categorical values differs from the frequency distribution expected from random chance alone. The Chi-Square Goodness of Fit Test does this for one variable at a time and requires a categorical variable consisting of two or more groups as input.
In this example, the variable 'Respondents Astrological Sign, zodiac' will be serving as the categorical variable with 12 groups. The Chi-Square Goodness of Fit Test is specifically looking at whether the respondents' astrological signs differ significantly in distribution from one that is expected by random chance. (This example is operating under the assumption that the frequency distribution expected from random chance alone should have all of the categories equally represented with an equal number of people with each zodiac.)

To generate a Chi-Square Goodness of Fit Testclick 'Analyze' in the top toolbar of the Data Editor window. Click 'Nonparametric Tests' in the dropdown menu, and click 'Legacy Dialogs...' in the first side menu and 'Chi Square' in the second side menu.

In the Chi Square dialog box that pops up, select the variable of interest (Respondents Astrological Sign, zodiac) from the list of variables and bring it over to the 'Test Variable List:' field. Then, in the 'Expected Values' field, select 'All categories equal' if all groups would be expected to have equal frequencies, or enter an exact value if a specific frequency is expected. In this case, we selected 'All categories equal' because we are operating under the assumption that the frequency distribution expected from random chance alone should have all of the categories equally represented with an equal number of people with each zodiac. Then, click 'OK.'

The output is displayed in the SPSS Viewer window. The output consists of two tables. The first table, Respondents Astrological Sign, displays the Observed N, the Expected N, and the Residual (the difference between the Observed N and the Expected N) for each of the categories within the categorical variable (for each of the astrological signs). The second table, Test Statistics, displays information specific to the Chi-Square Goodness of Fit Test, including the Chi-Square Value, the df (degrees of freedom), and Asymp. Sig. (when the Sig. value is .05 or less, the probability that the difference between the Observed N and Expected N value was due to chance is 5% or less). In this case, the Sig. level is above .05, so the difference between the Observed and Expected N values is not significant and the sample is an accurate representation of the population.

### Test of Independence: Pearson's Chi-Square

Test of Independence: Pearson's Chi Square examines whether the frequency of certain categorical values differs from the frequency distribution expected from random chance alone. The Test of Independence: Pearson's Chi Square does this for one variable at a time but it also tests whether the multiple categorical variables are significantly associated. It requires two categorical variables consisting of two or more groups as input, .
In this example, the variable 'Subjective Class Identification, class' with 4 groups, and the variable 'R Has Given Money To A Charity, givchrty' with 6 groups will be serving as the categorical variables. The Test of Independence: Pearson's Chi Square is specifically looking at whether the two variables are significantly associated, with the distribution of the respondents' subjective class identification and frequency of giving money to a charity differing from the distribution expected by random chance.

To generate a Test of Independence: Pearson's Chi Square click 'Analyze' in the top toolbar of the Data Editor window. Click 'Descriptive Statistics' in the dropdown menu, and click Cross Tabs...' in the side menu.

In the Crosstabs dialog box that pops up, select one of the variables of interest (R Has Given Money To A Charity, givchrty) from the list of variables and bring it over to the 'Row(s):' field, and select the othe variable of interest (Subjective Class Identification, class) from the list of variables and bring it over to the 'Column(s):' field. (The placement of the individual variables into the Row and Column fields is arbitrary.) Then, click 'Statistics...'

In the Crosstabs: Statistics dialog box, click 'Chi Square' and click 'Continue.'

Then, back in the the Crosstabs dialog box, click 'Cells...' In the cells dialog box, in the 'Counts' field, click to select both Observed and Expected, and in the 'Percents' field, select the desired percent values you would like to be displayed in the output. Additionally, select the desired residuals output in the residuals field. Then, click 'Continue, and back in the Crosstabs dialog box, click 'OK.'

The output is displayed in the SPSS Viewer window. The output consists of three tables. The first table, Case Processing Summary, displays the number N and percent of valid cases, missing cases, and total cases in the Chi-Square analysis.

The second table, the Crosstabulation matrix, presents the counts, expected counts, and the adjusted residual (the standardized difference between the observed values and the expected values), as well as percents for each group.

The third table, Chi-Square Tests,  presents the df (degrees of freedom), Asymp. Sig. (2-sided) for the Pearson Chi-Square value as well as other statistics. If the level of significance for the Pearson Chi-Square statistic is above .05, the probability that the difference between the Observed N and Expected N value was due to chance is 5% or less. In this case, the  Sig. value is below .05. However, the output does not explicitly indicate how the relationship exhibited in the sample data differs from a random expected pattern. The adjusted residuals in the above chart are important in determining how the relationship exhibited in the sample data differs from that of a random pattern: When the adjusted residual is greater than or equal to 1.96 (or less than or equal to -1.96), then the observed frequency value is significantly different from the expected frequency. Furthermore, if the adjusted residual value is positive, then the group is over-represented, and if the value is negative, then the group is under-represented. For example, the lower class giving money to charity once a month, a group which has an adjusted residual of -2.6, is significantly under-represented.