Given a variable which is categorical that depends on continuous variables, I would like to know how to check wether these continous variable explain the categorical one.


Y = cagetorical 
X1 = continous 
X2 = continous
X3 = continous

I'd start with a correlation but which? I've seen How to get correlation between two categorical variable and a categorical variable and continuous variable? but there it is explained wether there is a difference in categorical variables explaining a continous variable, so I think it's another topic?

I'm fine with tool advices in R and python as well.

edit: I'm not sure wether cateogrical is correct here. The values of $ Y $ are $ 0, 1, 2, 3 $ but I could also use $ A, B, C, D $. They represent a classification of the measure of cleanliness of a room.

  • 1
    $\begingroup$ Can you give a better example of the Y variable? Is it nominal or ordinal which makes a huge difference. Also what is your end goal? Is it just identifying and explaining a dependency/relationship, do you want to predict or model something? $\endgroup$ – Fnguyen Jul 23 '20 at 14:20
  • $\begingroup$ You're right, that wasn't very precise and I'm not sure wether the term categorical is correct here. I added some more information to clearify. $\endgroup$ – Ben Jul 24 '20 at 4:59
  • 1
    $\begingroup$ Ordinal means there is a clear order/hierarchy whereas nominal does not (e.g gender,etc) I assume cleanliness here is ordinal then because it is clear which value is better even if we cannot quantify better. $\endgroup$ – Fnguyen Jul 24 '20 at 5:37
  • $\begingroup$ Alright, thank you! Then it should be ordinal. $\endgroup$ – Ben Jul 24 '20 at 5:42

By saying you want to "explain Y by X" it sounds that you try to build a classifier F that can map X values into expected Y: F(X) --> Y. If so, you don't have to search for "correlation" necessarily. There are various methods to build such a classifier. You can use logistic regression \ SVM \ Neural network \ etc.

Besides, if it make more sense for you, you can always first discretize the continuous variables into categorical vars and than use also other methods such as decision trees \ Naive Bayes and more.

  • $\begingroup$ Thanks for the information but I think it doesn't match to my needs but I'll think about it. Basically, I only wanna' know wether $ X_i $ are able to explain $ Y $ in which way ever. That's why I'm not thinking about a specific model but about a correlation? $\endgroup$ – Ben Jul 24 '20 at 5:04
  • $\begingroup$ Ok, so you have the following options: 1. If the categorical Y var is actually an ordinal one, you can transform it to a reasonable numeric scale (e.g. 0,1,2,3 but it doesn't have to be a linear scale necessarily) and then you can calculate Spearman correlation 2. You can discretize the X var into a categorical var and then use information measures (such as: Info gain \ Gain ratio and others) 3. You can encode the categorical Y var somehow (for example one hot encoder) and see the correlation between X and each of the existing categories of Y $\endgroup$ – Oren Razon Jul 30 '20 at 15:38

So you want to explain the influence of 1-n ordinal variables X on one interval/continuous variable Y. What is the best way to do it?


Spearman rank-order correlation is the right approach for correlations involving ordinal variables even if one of the variables is continuous. Some sources do however recommend that you could try to code the continuous variable into an ordinal itself (via binning --> e.g. a 0-100 variable coded as 0-25,26-50,51-75,76-100) and include that into the correlation which is a valid approach as well.


In most regression models we can treat ordinal variables as continuous and probably be okay. Regression models have several key advantages over correlations for your question. They can deal with multiple predictors and also identify the magnitude of influence.

What you always have to do

To deal with ordinal variables in a correlation or a regression you always have to label encode them which means A,B,C,D becomes 0,1,2,3.

  • $\begingroup$ Thanks a lot! Just to conclude: I can perform a regression model like I would have done anyway? $\endgroup$ – Ben Jul 24 '20 at 7:15
  • $\begingroup$ Yes you can but if you have the time also try out transforming the continuous into an ordinal variable for the regression (would be a logistical regression then). $\endgroup$ – Fnguyen Jul 24 '20 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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