Solved – How to detect nonlinear relationship

correlationhypothesis testingnonlinearity

I have two continuous variables that may have nonlinear relationship. Scatter plot of two variables showed an ellipse shape. Furthermore, both Pearson correlation coefficient and Spearman's rank correlation coefficient were calculated and they were 0.624 and 0.619 respectively.

Is this indicate a linear relationship? How can I verify whether it is a linear or nonlinear relationship, Is there a linearity test?

Best Answer

Furthermore, both Pearson correlation coefficient and Spearman's rank correlation coefficient were calculated and they were 0.624 and 0.619 respectively. Does this indicate a linear relationship?

No, not necessarily. You can build datasets which have 0.6, but dependence is strongly non-linear, or nearly linear/comonotonic but with anti-tail-dependence (high extreme values for ones correspond to low extreme values for the other, and conversely).

You can display an empirical copula: You sort the values for X (and divide by the number of values), you sort the values for Y (and divide by the number of values). You can then plot a 'normalized' scatterplot or an estimated density of this bivariate distribution of uniform marginals. The perfect positive dependence (comonotonic relationship) is depicted by the diagonal of $[0,1]^2$. For some python code and empirical copulas illustration, you can have a look there.