How to get correlation coefficient exponential decay?
古いコメントを表示
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 件のコメント
Mathieu NOE
2022 年 4 月 27 日
hello
I think most if not all matlab tools for curve fitting will give you R squared but not R
most of us simply need to know if R² is close to 1 so we know the fitted model is ok , but maybe not everyone is interested to know if R is close to 1 or to -1 depending of the slope of the curve

so if that really matters to you you can multiply your Rsqr value by sign(b) and here you have a negative R (assuming a is positive)
Fabian Moreno
2022 年 4 月 27 日
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 件)
カテゴリ
ヘルプ センター および File Exchange で Particle & Nuclear Physics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
