The Chi square statistic is the sum of the squared differences between the observed and expected frequencies divided by the expected frequencies. Chi square = Sum [(observed frequency - expected frequency)^2/expected frequency)]
The Chi square test applies to categorical data. This nonparametric test determines whether the observed counts for the categories differ from the expected counts. Look up the p-value for the Chi square statistic obtained in a statistical table in order to determine if the test reaches significance. Before using the table, calculate the degrees of freedom for the problem. For two independent variables, the degrees of freedom are the number of levels of the first variable minus one, times the number of levels of the second variable minus one. Hence, df = (r - 1) (s - 1), where r is the number of levels in the first variable and s is the number of levels in the second variable.