How to enter the R-square fit formula in the m-file?

I need to calculate the R-square fit for the model output. I have the formula for calculating it, but how to give it in the code and what is the plot command to get the r-square fit?
Please do help me.

 Respuesta aceptada

Wayne King
Wayne King el 15 de Feb. de 2014
Editada: Wayne King el 15 de Feb. de 2014
Residual sum of squares
residsumsq = norm(y-yhat,2)^2;
Total sum of squares
tsumsq = norm(y-mean(y),2)^2;
R2 = 1-(tsumsq/residsumsq);

3 comentarios

Priya
Priya el 15 de Feb. de 2014
Editada: Priya el 15 de Feb. de 2014
Could anyone please tell how does this assigns the value for y, yhat from the plots and what should be the plot command to get the rsquared fit?
Wayne King
Wayne King el 15 de Feb. de 2014
The y vector is the vector of your original data. The yhat vector is your fitted data as predicted by your model.
Priya
Priya el 21 de Feb. de 2014
Editada: Priya el 21 de Feb. de 2014
Please tell me what does the 2(in bold) in the below expression mean?
residsumsq = norm(y-yhat, 2 )^2;
Also, Is the norm function referring to summation?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 15 de Feb. de 2014

Editada:

el 21 de Feb. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by