The chi-square test is used to determine if there is a significant difference between expected frequencies and observed frequencies in categorical data. It compares observed values to expected values that would occur according to a specific hypothesis. The chi-square test formula calculates the sum of the squares of the differences between observed and expected values divided by the expected value. A researcher would perform a chi-square test on survey data to understand the relationship between categorical variables like gender, age, and responses.