필터 지우기
필터 지우기

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 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