How does REGSTATS compute mse?

11 ビュー (過去 30 日間)
Jay Ghosh
Jay Ghosh 2014 年 5 月 8 日
編集済み: dpb 2014 年 5 月 8 日
I have a very simple and seemingly silly question, but I can't figure it out. I am trying to understand why MATLAB returns a mean square error (mse) value of Inf for a perfect regression fit. Shouldn't MSE for a perfect fit be zero?
For example if I have x = [1, 3, 5] and say y = exp(x) = [2.7183 20.0855 148.4312].
Now, just for the sake of it if I do a regression using regstat as: stats = regstat(y,x,'quadratic'), it gives a perfect fit to the function (as expected, since there are 3 points) and stats.yhat are the same values as y.
stats.rsquare = 1 , which makes sense... but stats.mse = Inf. Why so ? According to the traditional formula shouldn't mse be equal to zero, since it is a perfect fit?
Any clarifications will be appreciated. Thanks!

回答 (1 件)

dpb
dpb 2014 年 5 月 8 日
編集済み: dpb 2014 年 5 月 8 日
DOF = 0 so the denominator is zero--> inf for the mse.
Try with
x = [1:2:N];
y = x.^2;
instead, for example, for N=[5 7] to illustrate.

カテゴリ

Help Center および File ExchangeModel Building and Assessment についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by