Within the same population, the Chi-square test for independence looks for a connection between two categorical variables. Unlike the goodness of fit test, the test for independence compares two variables within a sample set to one another, rather than a single observed variable to a theoretical population.
Chi-square can also be regarded of as a test of independence, as it determines if two variables are independent or not. An independent question might be about whether gender (male vs. female) has any bearing on survey replies to yes/no questions.
The Chi-square test of independence is a statistical hypothesis test that is used to see if two categorical or nominal variables are likely to be connected.
In order to calculate the Chi-Square Test, you need to know the following:
The number of observations in each group
The expected frequency in each group
The observed frequency in each group
The number of degrees of freedom for this Chi-square test
The chi-square test can be helpful to a researcher if they are trying to find out whether there is a significant difference in the distribution of two categorical variables. It helps them use their data more effectively and make sure that they are not missing any important information.