Understanding Categorical Data Analysis: Commonly Used Tests and Their Applications
It is essential for every researcher or student to have a thorough understanding of inferential statistics and to know how and when to use different statistical tests. This is because statistical inference allows researchers to draw conclusions about a population based on a sample of data.
Moreover, by using the appropriate statistical test, researchers can ensure that their findings are valid and reliable. Choosing the wrong test or applying a test incorrectly can result in invalid or unreliable conclusions.
In addition, many scientific journals and funding agencies require statistical analysis to be performed and reported accurately, making it essential for researchers to have a good understanding of inferential statistics. Therefore, a solid grasp of statistical inference and the appropriate use of statistical tests is crucial for anyone conducting research or analyzing data.
In my previous article titled “Essential Statistical Concepts: Selecting the Appropriate Analysis for Your Data,” I focused on explaining the most widely used statistical tests for numerical data. In this article, I will shift my focus to clarify the tests commonly used for categorical data.
- The χ² test of independence:
The χ² test of independence is used to determine if there is a relationship between two categorical variables. It compares the observed frequency of categories in a sample with the expected frequency if the two variables were independent. If the difference between the observed frequency, and the expected frequency is large enough, it can be concluded that the two variables are related.
For example, consider a study to determine if gender and food preferences are related. Data is collected from a sample of people and organized in a contingency table as follows:
The χ² test can be used to determine if there is a relationship between gender and food preferences. The expected frequencies are calculated assuming that gender and food preferences are independent. If the χ² test yields a significant value, it means that there is a relationship between gender and food preferences.
2. The χ² goodness-of-fit test :
Is used to determine if a sample of data follows a theoretical distribution. It is often used to test the null hypothesis that the data are drawn from a population that follows a specific distribution, such as the normal distribution.
For example, consider a study to determine if the test scores of a group of students follow a normal distribution. The scores are collected and organized into classes, and then the observed frequencies are compared to the expected frequencies for a normal distribution. If the difference is large enough, the null hypothesis that the data follow a normal distribution can be rejected.
In summary, the χ² test of independence is used to determine if there is a relationship between two categorical variables, while the χ² goodness-of-fit test is used to determine if a sample of data follows a specific theoretical distribution.
3. Fisher’s exact test:
Is an inferential statistical method that can be used to test the independence of two categorical variables. Fisher’s exact test can be applied to any sample size, but it is typically used in analyzing small samples. Unlike the chi-squared test, which relies on an approximation, Fisher’s exact test is considered an exact test. It is particularly useful when dealing with situations where more than 20% of cells have expected frequencies less than 5, as the approximation method used in the chi-squared test may not be appropriate. Therefore, in such cases, Fisher’s exact test should be used instead of relying on approximation methods. Fisher’s exact test uses the hypergeometric distribution to assess the null hypothesis of independence between the two variables. However, while many statistical packages provide the results of Fisher’s exact test for 2x2 contingency tables, they may not provide it for larger tables with more rows or columns. In such cases, online resources or software may be used to perform the test .
Suppose you are a researcher studying the relationship between smoking status and lung cancer in a population of 500 people. You have collected data on whether each person in the sample smokes or not and whether they have been diagnosed with lung cancer or not. The data are summarized in the following contingency table:
To determine whether smoking status is associated with lung cancer, you can perform a Fisher test with a significance level of 0.05. The null hypothesis is that there is no association between smoking status and lung cancer, and the alternative hypothesis is that there is a significant association.
Using a statistical software package or an online Fisher test calculator, you can calculate the p-value of the Fisher test. The p-value is the probability of obtaining a result as extreme as the observed result, assuming that the null hypothesis is true.
In this example, the p-value of the Fisher test is 0.001, which is less than the significance level of 0.05. Therefore, you can reject the null hypothesis and conclude that there is a significant association between smoking status and lung cancer in the population.
This means that smokers are more likely to develop lung cancer than non-smokers. However, it is important to note that the Fisher test only measures association, and it does not prove causality. There may be other factors that contribute to the development of lung cancer besides smoking.
4. The McNemar test :
The McNemar test is a statistical method that is specifically designed for 2x2 tables where the data is matched or paired. This non-parametric test is useful for determining the significance of the difference between two proportions in paired dichotomous observations. It is often employed in “before and after” studies where the goal is to test the significance of any changes that have occurred. For instance, researchers might use this test to evaluate the effectiveness of a new treatment by comparing the proportions of patients who showed improvement before and after the continuous data treatment.
Originally introduced by Quinn McNemar in 1947, the McNemar test remains widely used in contemporary research, particularly in medical research. It can be applied in a variety of contexts where paired data are available and researchers seek to compare proportions between two groups. For example, suppose researchers wish to assess the effectiveness of a new weight loss program. They could select 100 participants at random and measure their weight both before and after the program.
Participants could be classified as having either “lost weight” or “did not lose weight” depending on whether their weight decreased or stayed the same/increased after the program.
Reference:Kim, H.-Y. (2017). Statistical notes for clinical researchers : Chi-squared test and Fisher’s exact test. Restorative Dentistry & Endodontics, 42(2), 152‑155. https://doi.org/10.5395/rde.2017.42.2.152
If you enjoy the article and wish to show your support, please do the following:
- Give the article 50 claps to increase its visibility
- Follow me on Medium
- Check out more of my content on my Medium profile
- Follow me on LinkedIn