Borrar filtros
Borrar filtros

correlation of nonlinear variables

48 visualizaciones (últimos 30 días)
Ameen Bassam
Ameen Bassam el 27 de Jul. de 2021
Respondida: John D'Errico el 31 de Jul. de 2021
I have variables with nonlinear relationships and I want to calculate the correlation between them to find which variable affect more than the others.
I have used corr function but it returns the linear correlation coefficient. I can't find a function to calculate correlation coefficients for nonlinear variables. Any hlep please? Or should I use R instead of MATLAB ?

Respuestas (3)

John D'Errico
John D'Errico el 31 de Jul. de 2021
Correlation does not really make sense in respect to nonlinear variables. Depending on the values of the variables, they will be more or less correlated. So that is meaningless. At best you can talk about a local correlation, where a linear approximation is made, and then correlation could be defined.
So in that context, correlation is simple. You start with the inverse of the local Hessian matrix. Scale that to have unit diagonals, by pre-and post multiplying by the correct diagonal matrix. The off-diagonal terms will be the desired local correlation, as a simple approximation, and valid ONLY locally.

Image Analyst
Image Analyst el 27 de Jul. de 2021
If you want, you can try to fit some model through your data, like an exponential growth or decay if you suspect that is the relationship. Then you can compute the MSE of the residuals. Demos are attached.

Jeff Miller
Jeff Miller el 28 de Jul. de 2021
It isn't really clear what you mean by "correlation coefficients for nonlinear variables", because an infinite number of nonlinear relationships are possible, and each one would give a different correlation value. As indicated by Image Analyst, you can try fitting different nonlinear relationships and see which one fits best.
Alternatively, maybe you are looking for the nonparametric Spearman rank order correlation which checks only for monotonic relationships rather than strictly linear ones. If that is what you are after, you can use
[RHO,PVAL] = corr(x,y,'Type','Spearman'); % May require statistics toolbox?
to get the Spearman correlation.
  3 comentarios
Jeff Miller
Jeff Miller el 31 de Jul. de 2021
To compute such a correlation you must be able to specify the nonlinear function precisely, e.g.
Y = a+b*X+c*X^2 or
Y = a+b*X+c*X^2 + d* X^3 or
Y = a + b*e^X + c*log(X)
etc
There is no such thing as a general "correlation coefficient for nonlinear variables" that can be computed even if the form of the nonlinear function is unknown.
Ameen Bassam
Ameen Bassam el 31 de Jul. de 2021
Editada: Ameen Bassam el 31 de Jul. de 2021
Thank you for your reply. I think distance correlation can be helpful in my case

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by