I have 43 categorical variables codified 0,1,2,3 etc and i want to measure correlation between each one of them with an output binary variable.

Do codification of categorical data in my case 0,1,2,3 etc convert data to numerical and then we can apply any correlation measurement???

Can i apply Pearson correlation? (i found in literature that Pearson is applied ony for numerical variables)

i found Spearman correlation can fit categorical variables better in this article https://machinelearningmastery.com/how-to-use-correlation-to-understand-the-relationship-between-variables/

Any help please


1 Answer 1


According to this answer, found via a quick Google search...


Pearson correlation is a means of quantifying how much the mean and expectation for two variables change simultaneously, if at all. In other words, pearson correlation measures if two variables are moving together, and to what degree.

You can’t apply this logic to categorical variables because there is typically no order in categorical variables. For example, a variable called “height” clearly places the observation of the human as “larger” than that of a cat, because 1.75 metres is definitely larger than 0.4 metres.

But the categories “human” and “feline” have no order, do they? Who determines which is better than the other? Where is the value that we use as the mean to calculate variance? Without order, it’s not possible to correlate two variables.

But never fear, there are ways to find out if categorical variables are related in some way; you need to simply move from correlation to association. These would be tests such as Chi square and ANOVAs.

The response also points in the direction of this nice StackOverflow thread, which has some examples you may find helpful. I would point you to this thread, which gives a concise overview of "correlation" or relatedness tests. The comments sections in the thread will also point you in the right direction.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.