Correlation between two non-linear vectors

I got two vectors from mixed models with coefficients below.
I want to find out if there is any correlation between the both non linear vectors (poly 2).
Can I trust the function corrcoef?
Or is there any other test for the association e.g. t-test?
a1 = -1.357;
b1 = 0.1038;
c1 = -0.0015;
x1 = linspace(20,40,200) ;
y1 = 10.^(a1+ b1*x1+c1*x1.^2);
plot(x1,y1,'-','color','r');hold on;
a2 = -0.1953;
b2 = -0.0221;
c2 = 6.045e-04;
x2 = linspace(20,40,200) ;
y2 = 10.^(a2+ b2*x2+c2*x2.^2);
plot(x2,y2,'-','color','b');
[y1_y2,p_y1_y2]= corrcoef(y1,y2);
y1_y2:
1 0.471552593883940
0.471552593883940 1
p_y1_y2
1 1.59789801156464e-12
1.59789801156464e-12 1
Plot of the two vectors y1 and y2.
Scatter plot of y1 (y axis) and y2-(x axis)

Answers (1)

dpb
dpb on 13 Jul 2019
Can I trust the function corrcoef?"
Well, you can trust it to have computed what it says it computes which is the estimate of their linear dependence. Certainly the 0.45 doesn't look unreasonable as the two both have an overal positive linear slope while the curvatures are positive and negative, respectively, and certainly the difference plot shows a definite trend; it's not at all random in nature so there is a model that _could_ explain the difference almost exactly.
The question is what is the null hypothesis you would like to test? That determines the statistic if there is one to anwer the question.

5 Comments

[John33 Answer moved to comment -- dpb]
Thanks for your comments,
it is not a difference it is y1 on y axis and y2 on x axis.
The hypothesis is no assosiation with the two functions (I think correlatiom maybe wromg word)
Then I dont understand why I got R2=0.48 from cftool plot
Oh...ok. The title confused me as to what the plot actually was.
Still what's not to understand of R^2 =~ 0.5 from the given curves? 50% ain't but half the total variation and certainly the overall linear trend is there between the two. Remember, all R-square computes is the LINEAR correlation.
And moved again -- dpb
Ok Is there any other way to check association with these two functions Is no linear ?
Well, if they were perfectly linearly correlated, Rsq would have been 1 or near that...so, that it's only 50% says they're not particularly well correlated. But, they're far more than just random association as can clearly be seen by inspection.
It still isn't clear just what you're trying to say about them, specifically.
Can you trust corrcoef? Well, yes. It does what it says it does. But it is not designed to handle nonlinear problems. It assumes the relationship you pose to it is linear, with noise. When you have lack of fit, thus significant nonlinearity, you have failed the major assumption behind use of corrcoef.
So what do you have? There is essentially no noise at all. So any deviation from linear relationships is purely in terms of lack of fit, pure nonlinearity. corrcoef is not a good tool to measure whatever it is you are looking to measure. Is there a good tool? Hard to say, since we are not given sufficient information to know. But corrcoef is not really the right thing, because it is trying to view any deviation from linearity as noise, and that deviation is far from random noise in your case.

Sign in to comment.

Products

Release

R2019a

Asked:

on 13 Jul 2019

Commented:

on 15 Jul 2019

Community Treasure Hunt

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

Start Hunting!