I am trying to calculate if there is a dependence between two categorical columns, or a significant cooccurence of two categorical variables. Let's say I have columns A and B, and and out of 200K rows A is '1' 13683 and B is '1' 35171 times. Out of this, 2871 rows have both A and B '1' at the same time.
How do I calculate if there is a dependence between two columns? I tried to calculate expected ratios for both A and B, 0.068 0.175, and if assuming both were binomial, randomly both A an B being 1 is 0.068 * 0.175 = 0.01203. So any observed ratio significantly higher than this could signify the coocurence is not due to random chance? For that, I had the idea of using 0.01203 as "population parameter" and check with binomial test if observed ratio is significantly higher. Is a chi square test better for this? How would it be used here?
Thanks,