Effacer les filtres
Effacer les filtres

How to calculate r-squared in exponential fitting?

5 vues (au cours des 30 derniers jours)
Inês Rodrigues
Inês Rodrigues le 17 Juil 2017
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?

Réponses (0)

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by