How to enter the R-square fit formula in the m-file?
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Wayne King
2014-2-15
编辑:Wayne King
2014-2-15
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 个评论
Wayne King
2014-2-15
The y vector is the vector of your original data. The yhat vector is your fitted data as predicted by your model.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!