Different Rsquares for fitlm and fit when using robust option
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Martin Kaloudis
il 12 Lug 2021
I have exactly the same problem and have not yet found a solution, can anyone help?
Risposte (1)
Simon Chou
il 14 Ago 2019
When robutness option is used, the regression will consider the outliers. Check this out
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!