# Correlations between continuous and categorical (nominal) variables

I would like to find the correlation between a continuous (dependent variable) and a categorical (nominal: gender, independent variable) variable. Continuous data is not normally distributed. Before, I had computed it using the Spearman's $\rho$. However, I have been told that it is not right.

While searching on the internet, I found that the boxplot can provide an idea about how much they are associated; however, I was looking for a quantified value such as Pearson's product moment coefficient or Spearman's $\rho$. Can you please help me on how to do this? Or, inform on which method would be appropriate?

Would Point Biserial Coefficient be the right option?

• Normally, one cannot advice only on the basis of the format of the data! What do the data represent, and what do you want to achieve with your analysis? – kjetil b halvorsen Jun 10 '14 at 8:29
• Thanks kjetil, I would like to compare the association between gender and other continuous variables. Simply to know, which continuous variables are moderately/strongly correlated and which variables are not. – Md. Ferdous Wahid Jun 10 '14 at 8:37
• Seems like a duplicate of stats.stackexchange.com/questions/25229/… Can you tell us if the answers to that one helps you? – kjetil b halvorsen Jun 10 '14 at 8:41
• Yes, my question is similar to that. However, I got a feedback where reviewer indicated that Spearman's $\rho$ is not appropriate. My sample size is 31. According to the answer (the link provided), non-normal wouldn't be an issue and any correlation method can be used (Spearman/Pearson/Point-Biserial) for the large dataset. Would it be true for the small dataset too? By the way, gender is not an artificially created dichotomous nominal scale. The above link should use biserial correlation coefficient. – Md. Ferdous Wahid Jun 10 '14 at 9:03
• Correlation between nominal and interval or ordinal variable stats.stackexchange.com/q/73065/3277 – ttnphns Dec 25 '15 at 20:59

The reviewer should have told you why the Spearman $\rho$ is not appropriate. Here is one version of that: Let the data be $(Z_i, I_i)$ where $Z$ is the measured variable and $I$ is the gender indicator, say it is 0 (man), 1 (woman). Then Spearman's $\rho$ is calculated based on the ranks of $Z, I$ respectively. Since there are only two possible values for the indicator $I$, there will be a lot of ties, so this formula is not appropriate. If you replace rank with mean rank, then you will get only two different values, one for men, another for women. Then $\rho$ will become basically some rescaled version of the mean ranks between the two groups. It would be simpler (more interpretable) to simply compare the means! Another approach is the following.

Let $X_1, \dots, X_n$ be the observations of the continuous variable among men, $Y_1, \dots, Y_m$ same among women. Now, if the distribution of $X$ and of $Y$ are the same, then $P(X>Y)$ will be 0.5 (let's assume the distribution is purely absolutely continuous, so there are no ties). In the general case, define $$\theta = P(X>Y)$$ where $X$ is a random draw among men, $Y$ among women. Can we estimate $\theta$ from our sample? Form all pairs $(X_i, Y_j)$ (assume no ties) and count for how many we have "man is larger" ($X_i > Y_j$)($M$) and for how many "woman is larger" ($X_i < Y_j$) ($W$). Then one sample estimate of $\theta$ is $$\frac{M}{M+W}$$ That is one reasonable measure of correlation! (If there are only a few ties, just ignore them). But I am not sure what that is called, if it has a name. This one may be close: https://en.wikipedia.org/wiki/Goodman_and_Kruskal%27s_gamma

• Spearman's rank correlation is just Pearson's correlation applied to the ranks of the numeric variable and the values of the original binary variable (ranking has no effect here). So Spearman's rho is the rank analogon of the Point-biserial correlation. I don't see any problem in using Spearman's rho descriptively in this situation. – Michael M Jun 10 '14 at 14:51
• Michael Mayer: Yes, it might work, maybe, but is there any point in it? It doesnt give information which is not contained in some difference of means! and that is more directly interpretable. – kjetil b halvorsen Jun 10 '14 at 14:57
• Is a difference in ranks much simpler to interprete as Spearman's rho? Even if so, would you call Spearman's rho wrong? Sad that we don't see the reviewers reasoning. – Michael M Jun 10 '14 at 15:12
• What you suggest is nice. It seems to be related to the test statistic of Wilcoxon's two-sample test, which is itself similar to Kendall's rank correlation between the numeric outcome and the binary group variable. – Michael M Jun 10 '14 at 15:29
• @tao.hong In which sense do you think it is asymetric? If you switch labels (men/women), then both $\theta$ and $\hat{\theta}$ switches in the same way, to $1-\theta$. – kjetil b halvorsen Sep 8 '16 at 19:48

I'm having the same issue now. I didn't see anyone reference this just yet, but I'm researching the Point-Biserial Correlation which is built off the Pearson correlation coefficient. It is mean for a continuous variable and a dichotomous variable.

I use R, but I find SPSS has great documentation.

• Great reference for finding a correlation between a continuous variable and a dichotomous variable! However, assumptions listed are bit strong. – SUNDONG Jan 31 '18 at 5:34

For the specified problem, measuring the Area Under the Curve of a Receiver Operator Characteristic curve might help.

I am not an expert in this so I try to keep it simple. Please comment on any error or wrong interpretation so I can change it.

$x$ is your continuous variable. $y$ is your categorical. See how many True Positives and False Positives do you get if you choose a value of $x$ as being the threshold between positives and negatives (or male and female) and you compare this to the real labels. For e.g. you choose 7, then above $x$=7 are all female (1) and below $x$=7 all male (0). Compare this to the real labels and get the number of true positives and false positives of your prediction.

Repeating the procedure explained above, from min($x$) to max($x$) you will generate the true positive and the false positive rates and then you can plot them like in the figure below and you can calculate the Area Under the Curve.

The idea is that if there is no correlation between the variables, you will get the same ratio of true positives and true negatives for all values of $x$, nevertheless, if there is good correlation (and the same stands for anti-correlation) the ratio of true positives to true negatives will strongly vary as $x$ varies.

The above statement is calulcated with the Area Under the Curve.

Example of good correlation (right) and fair anti-correlation (left).

• Welcome to CV! Your answer is a bit too short, and it does not seem to help find: "the correlation between a continuous (dependent variable) and a categorical (nominal: gender, independent variable) variable". Could you edit your answer to include how AUROC is supposed to achieve this? – Frans Rodenburg Aug 16 '18 at 3:45

It would seem that the most appropriate comparison would be to compare the medians (as it is non-normal) and distribution between the binary categories. I would suggest the non-parametric Mann-Whitney test...

• While the Mann-Whitney would be a way of identifying location shift in a variable (or indeed more general forms of stochastic dominance) across a binary categorical variable, the Mann-Whitney doesn't compare medians, at least not without additional assumptions. – Glen_b Jun 12 '15 at 0:01

you should use linear trend alternative to independence . if you don't know this way ,you can study an introduction to categorical data analysis page 41 .

• There is already an accepted answer. And it is not clear what your answer contributes. Could you explain more? I assume you make reference to Agresti's introduction to categorical data analysis. Please provide full citation. – T.E.G. Feb 8 '17 at 23:12