Different Rsquares for fitlm and fit when using robust option

7 ビュー (過去 30 日間)
Maximilian Rüppell
Maximilian Rüppell 2019 年 3 月 21 日
コメント済み: Martin Kaloudis 2021 年 7 月 12 日
Hi all,
when using fit (curve fitting tool or programmatic) or fitlm, the resulting coefficients and Rsquare/ adjusted Rsquare are the same. However, using the "Robust" option (both time using the bisquare method), values for both Rsquare/ adjusted Rsquare AND the resulting coefficients (slope and offset of linear) are different. Does anyone have an explanation for this? Since the values are completely different (R² ~0.7 in fit function and ~0.2 in fitlm) I cannot just ignore this as a "minor difference in calculation"
I have included my data, but compare my results here:
USING FITLM:
Model = fitlm(XDATA, YDATA, 'Robust', 'on')
Model =
Linear regression model (robust fit):
y ~ 1 + x1
Estimated Coefficients:
Estimate SE tStat pValue
_________ __________ ______ __________
(Intercept) 0.027124 0.015805 1.7162 0.086706
x1 0.0056166 0.00064793 8.6686 5.1589e-17
Number of observations: 540, Error degrees of freedom: 538
Root Mean Squared Error: 0.121
R-squared: 0.21, Adjusted R-Squared 0.209
F-statistic vs. constant model: 143, p-value = 1.87e-29
USING FIT
opts = fitoptions( 'Method', 'LinearLeastSquares', 'Robust', 'on');
[Fitresult, GoodnessOfFit] = fit(XDATA, YDATA, fittype('poly1'), opts)
Fitresult =
Linear model Poly1:
Fitresult(x) = p1*x + p2
Coefficients (with 95% confidence bounds):
p1 = 0.005617 (0.004344, 0.006889)
p2 = 0.02712 (-0.003923, 0.05817)
GoodnessOfFit =
struct with fields:
sse: 7.8536
rsquare: 0.7290
dfe: 538
adjrsquare: 0.7285
rmse: 0.1208
Although the original question was different, the same problem occurred here (see latest entry):
Thanks for your help!
  2 件のコメント
Maximilian Rüppell
Maximilian Rüppell 2019 年 3 月 26 日
Anyone?
Martin Kaloudis
Martin Kaloudis 2021 年 7 月 12 日
I have exactly the same problem and have not yet found a solution, can anyone help?

サインインしてコメントする。

回答 (1 件)

Simon Chou
Simon Chou 2019 年 8 月 14 日
When robutness option is used, the regression will consider the outliers. Check this out

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by