フィルターのクリア

How to calculate r-squared in exponential fitting?

5 ビュー (過去 30 日間)
Inês Rodrigues
Inês Rodrigues 2017 年 7 月 17 日
Hello. So I'm trying to find the r-squared in an exponencial fitting. Having x and y, I did first: Y = log(y); X = x; s_X = sum(X); s_Y = sum(Y); s_X_2 = sum(X.^2); s_XY = sum(X.*Y); N = length(X); B = (s_XY - (s_X_2 * (s_Y/s_X)))/(s_X-(s_X_2*N/s_X)); A = (s_Y - N*B)/s_X; C = exp(B);
My model is then y = C*exp(A*x). I checked in Excel and A and C are the same.
Then I did yfit = C*exp(A*X), and finally R2 = 1- (norm(yfit - Y)/norm(Y- mean(Y)))^2
However, it outputs me a negative value, of course not the same as excel
Could you help me?

回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by