R-Squared in Curve-fitting Tool

47 views (last 30 days)
Mohamed Amine Ben El Mechri
Edited: mg1987 on 1 Jul 2023
Hello,
to evaluate my modell i am using the Curve fitting Tool. I loaded my data. And i want to calculate the R-Squared .So i set a Polynom first degree (y = x) as a reference.
The problem is, for every Robust mode ( Off , bisquare , LAR) i get a different R-squared value even though data and the reference ( line y= x) didn#t change.
Do you have an explanation ?
Thanks.

Answers (1)

Prabhan Purwar
Prabhan Purwar on 16 Oct 2019
Hello,
Different methods weight the residuals differently while Fitting the curve, leading to a different curve, which is responsible for the change in the R^2 value.
  • The LAR scheme finds a curve that minimizes the absolute difference of the residuals, rather than the squared differences. Therefore, extreme values have a lesser influence on the fit.
  • The Bisquare method minimizes a weighted sum of squares, where the weight given to each data point depends on how far the point is from the fitted line. Points near the line get full weight. Points farther the line get reduced weight. Points that are farther from the line than would be expected by random chance get zero weight.
Thus a dataset with large number of outliers leads to more variation in R^2.
Refer to the following link for further information:
  1 Comment
mg1987
mg1987 on 1 Jul 2023
Edited: mg1987 on 1 Jul 2023
I find the Rsquare issue quite frustrating, to be honest. Numerous questions have been raised regarding the same matter (I have searched the MATLAB Answers thoroughly), yet none, especially from the Matlab official administration, have provided a satisfactory answer regarding how Rsquare is calculated within the curve fitting toolbox when the LAR option is enabled. Multiple users have reported obtaining significantly different Rsquare values using different methods, or even when comparing curve fitting and manual calculation of Rsquare (the usual 1-SSE/SST). Why can't we see the equation used for the calculation? Alternatively, if the function provided by MathWorks at the following link:
is used, how can we test it when we are unable to obtain the weights shown on the link without any explanation or method of obtaining them (especially for LAR)? The LAR option has greatly improved R2 in my data fitting, but now I feel disheartened because I can't explain it. Please refrain from repeating the statement "LAR is searching for least absolute instead of least square..." as it is already understood. However, what does that mean for Rsquare and its significantly higher values?

Sign in to comment.

Categories

Find more on Fit Postprocessing in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!