# Categorical Variable and Target Variable

Though a similar question is answered here , but I wanted to take a different approach. Assuming that I have a binary target variable 1/0 and a categorical variable Gender M/F. From this, I can have a proportion p1 for M with target 1 and p2 for F with target 1. N1 and N2 would be total number of M and F respectively. Is it prudent to run a test for H0: p1=p2 ? If H0 cannot be rejected, doesn't it indicate that Gender doesn't have any correlation with Target

• Is Gender the only explanatory variable you have? Or can it be used together with others? – Leevo Jun 3 '19 at 7:24
• Actually, I have a large number of binary Categorical Predictors. So for each Predictor, I want to try out this method with the target variable. Is there any gap in this theory ? – Arindam Jun 3 '19 at 9:34
• Yes, I think there is a gap. The point is, that not beeing able to identify a correlation between one of your features and the target doesn't mean there is no such relationship between a combination of your features and the target. Let's say your target states 1=obese 0=not obese and you have a second flag 0=weighs less then 70kg and 1=more than 70kg. Given this data it could be that (depending on the composition of your data) you would never reject H0 and thus reason, that your data doesn't allow you to decide on the target attribute. – jottbe Jul 3 '19 at 19:39
• But if you consider combinations of your attributes and look at your data with weight more than 70kg and gender=Female, clearly you still have a lot of data points which are normal, but you surely will have a higher ratio of data points which would have to be classified as obese. Btw I hope I don't upset somebody by that example, I think obesity starts much higher, but I wanted a border which is low enough so it would not be sufficient as a single attribute and still high enough so it splits of some of the non-obese people. – jottbe Jul 3 '19 at 19:45

If you want to understand whether Gender (M/F) has a significant association, you should run a logistic regression using it together with other predictors. This would let you control for the impact of Gender all things equal, i.e. after you controlled for the effects of other variables. Logistic regression will return significant scores and standard errors for each variables. Alternatively, you could look at relative importance scores from tree-based models such as Random Forest or XGBoost. (However, Logistic regression is better for hypothesis testing.)