# Confusion on Chi-Squared test results

Basically, I have the data where I am trying to assess whether there is any correlation between the gender of the manager and the gender of people within their team. I decided to do the chi-squared test on these categorical data by counting the number of males and females within the team and then doing the test against the data for the manager.

However, there are many more male managers and employees within the dataset rather than females, which is why I believe I got skewed results at first. The challenge lies in the imbalance of males and females and the potential impact on analysis results. The goal is to balance the sample sizes between males and females, ensuring a fair comparison, and then calculating p-values to assess the significance of the relationship. I did that by using random sampling but my results when I plot them look kind of weird now.

Before:

After:

My question is: did I do the right thing? I am kind of confused now on how to interpret these results :/

EDIT: Performing a chi-squared test using pd.crosstab to create a contingency table for manager_gender and the count of females or males (Count_Female or Count_Male) in a team. It calculates the chi-squared statistic and the p-value associated with the test. Then I am comparing the p-value to the significance level alpha to determine whether the correlation between manager_gender and the count of females or males is statistically significant.

data = {
'manager_gender': ['female', 'male', 'female', 'male'],
'Count_Female': [1, 3, 5, 1],
'Count_Male': [3, 5, 1, 2]
}


Contingency table for females:

Contingency table for males:

• Hi! It's a bit unclear what your data looks like, and on what you conducted the chi-squared test. Can you edit your question to provide a snippet of the data? An example of a table on which you conducted the chi-squared test would be useful. Aug 20, 2023 at 23:02
• @J-J-J this is a very rough example of what i am trying to do Aug 20, 2023 at 23:21
• It's very hard to say what you should do based on "very rough examples". Also, you have a year variable. What's its role? Aug 20, 2023 at 23:41
• Also, what is your plot? Year is on the x axis, but what is your p-value from? And what are the lines? Aug 20, 2023 at 23:43