How to get correlation coefficient exponential decay?

조회 수: 3 (최근 30일)
Fabian Moreno
Fabian Moreno 2022년 4월 26일
댓글: Mathieu NOE 2022년 4월 28일
Hello, I would like to get the correlation coefficient from the exponential decay model. I used the following code:
ft = fittype( 'a*exp(-b*x)+c', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
and got from the R2 the correlation coefficient
Rsqr=sqrt(gof.rsquare)
but the (r) is positive, is there a form to get the correlation coefficient negative. Obviously my data shows a decreasing exponentail decay.
And I don't use the corrcoef because it suppose to be use with a linear data, but what about exponentail decay?
  댓글 수: 3
Fabian Moreno
Fabian Moreno 2022년 4월 27일
Hello, @Mathieu NOE! Thanks for your answer. I am going to share my figure to show you my result. Also, could you please explain me why I have to multiply the Rsqr value by sigh (b)? I didn't understand.
Mathieu NOE
Mathieu NOE 2022년 4월 28일
hello
you have decaying exponentials here so sign(b) is negative (obviously) which is how I create the negative R
If you had a positive b , then R shoud be positive too
That may sound like a "trick" but there is probably no other matlab way to do it as all fit function returns R squared , which , of course reamins positive in all circumstances.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by