correlation of nonlinear variables
51 visualizaciones (últimos 30 días)
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 ?
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 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 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.