Azzera filtri
Azzera filtri

How to calculate r-squared in exponential fitting?

5 visualizzazioni (ultimi 30 giorni)
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?

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by