# How to get correlation between the categories of two categorical variable?

I have a categorical variable with 2 categories ("Health") ('healthy', 'not_healthy') and another categorical variable ("country") with 5 categories ("english", "eua", "Australia", "spain", "Germany"). I want to check if there is any relation between health and country. I can perform chi-squared and, having a p-value < 0.05, I can reject the null hypothesis and states that under a confidence interval of 95%, country is related to health.

However, what now I want to know is which country is more related to being healthy or not? That is, which country increases the likelihood that a person will be a healthy person if they are from that country? Is there any statistical test that I can perform or is it determined only by data visualization (healthy graph x country)?

Since you already implemented the significant relationship between health and country, you can now perform a so-called Post-Hoc Analysis to find out which categories of country are more likely to indicate a healthy society.

Post-Hoc Analysis Options: Depending on the structure of your data and the specific question you want to answer, you can use various techniques for post-hoc analysis:

1. Crosstabulations: Create a cross-tabulation or contingency table to compare the frequencies of "Healthy" and "Not Healthy" individuals within each country. This will help you visually inspect which countries have a higher proportion of healthy individuals.

2. Chi-Squared Residuals: Calculate the chi-squared residuals for each cell in the contingency table. Large positive residuals indicate that a category has more "Healthy" individuals than expected, while large negative residuals suggest fewer "Healthy" individuals.

3. Post-Hoc Pairwise Tests: If you have more than two categories in your "Country" variable, you can perform pairwise comparisons using methods like Bonferroni-adjusted chi-squared tests to identify significant differences between individual countries and health. This will help you pinpoint which specific countries contribute to the overall relationship between health and country.

4. Logistic Regression: If you want to quantify the effect of each country on health while controlling for potential confounding variables, you can perform logistic regression. In this case, the outcome variable would be "Health," and the predictor variables would include binary variables for each country (with one country serving as the reference category). The regression coefficients will indicate how each country affects the likelihood of being healthy or not.

5. Data Visualization: While statistical tests are valuable, data visualization, such as bar charts or stacked bar charts, can also help you intuitively identify which countries have a higher proportion of healthy individuals.