Chi-Squared Test is one of the ways in which we try to conduct hypothesis tests with categorical variables to see if there is an effect of one on another.
The Chi-Squared test of independence is used to determine whether or not there is a significant relationship between two nominal (categorical) variables.
For example, a researcher wants to examine the relationship between gender (male vs female) and the chances of developing Alzheimer’s disease. The chi-squared test of independence can be used to examine this relationship. The null hypothesis (H0) for this test is that there is no relationship between gender and life expectancy, and the alternative hypothesis is that there is a relationship between gender and life expectancy.
Here, there are two categorical variables (nominal variables): male and female.
Let’s draw a table for both these categorical variables.
Male | Female | |
Expected Value | ||
Sample Value |
The expected value is calculated by assuming that the null hypothesis is correct. So, if you select a sample of, say, 100 Alzheimer’s patients, 50 should be men and 50 should be women.
Putting the expected values in the table above, you get:
Male | Female | |
Expected Value | 50 | 50 |
Sample Value |
Let’s say the sample value comes out to be a bit different, and in a sample of 100 Alzheimer’s patients, 60 are men and 40 are women.
Male | Female | |
Expected Value | 50 | 50 |
Sample Value | 60 | 40 |
The test statistic for the chi-squared test is equal to
χ2=Σ(O−E)2E
where O is the observed sample value and E is the expected value.
So, our test statistic will be equal to:
χ2=102/50+102/50=4
Let’s select the level of significance as 5%, or 0.05.
Based on the degrees of freedom and the given test statistic we compare it with the given level of significance and check if the p-value is greater or not. And then, on that basis, take a decision to reject or not reject the null hypothesis.
You can take a look at this link to understand this concept in a much better way.
Now that you’re well versed with the concept of Chi-Squared Test, go ahead and practice the next interview question.