I have 36 categorical variables, 11 binary and other with more than 2 levels. I wanted to check if they are independent or not, so I want to do Chi-square test of independence. Problem is I believe Chi-Square is a pairwise test and that means lot of tests for 36 pairs. Is there any way we can have matrix similar to correlation matrix that we get for continuous variables.

Also, please advise on second question: even if variable is dependent as per chi-square test, should I still carry on with other feature selection methods like what is suggested in below paper before I decide to drop any variable? http://jmlr.csail.mit.edu/papers/volume3/guyon03a/guyon03a.pdf

P.S. I am doing this in R

  • The chi-squared test for independence is not pairwise: it works exactly the same for higher-dimensional tables as it does for lower-dimensional ones. However, a table with 36 dimensions will have too many cells to permit testing of full independence. This suggestions limiting your ambitions, such as testing for pairwise independence. But what does this have to do with "feature selection"? Are you sure you're asking a question that is even relevant to your analysis? – whuber Aug 10 at 12:40
  • 1
    Do you mean you want to analyze multi-way frequency tables? If so, you may consider log-linear analysis (look at the following link for a brief intro on log-linear analysis: statisticssolutions.com/…). – Ayalew A. Aug 10 at 13:48
  • @whuber can you elaborate why cou cannot test for full independence in this case? – 0rangetree Aug 10 at 14:08
  • Thanks for your reply. I did not frame it correctly. I was also looking at chi-square between dependent and target variable as well, question is, would it make sense to try other variable selection tech like variable ranking or is it ok to drop the feature if it is not significant as per chi square. If dependent and target are independent as per chi-square can we directly drop. Or should carry out any strength statistics Also could you guide me on what to do if two dependent categorical variables fail null hypothesis of chi square. I am still learning so kindly ignore my ignorance. – Vipin Koul Aug 10 at 14:10
  • @0rangetree If I am trying to use all variables at a time I get an error in R which says dimensions are over 2^31 – Vipin Koul Aug 10 at 14:14

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.