필터 지우기
필터 지우기

Different Rsquares for fitlm and fit when using robust option

조회 수: 5 (최근 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
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 CenterFile Exchange에서 Resampling Techniques에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by