Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculating R^2 using Robust fit with nlinfit

709 views
Skip to first unread message

Sumit

unread,
Mar 13, 2012, 5:57:19 PM3/13/12
to
Hello,

I am using nlinfit function to do Robust Regression. I want to calculate R^2.

C = corrcoef(yfit, y);
Rsq = C(1,2)^2;

I am also Calculating RSquare as follows.

Rsq1 = 1 - sum(r.^2)/sum((y - mean(y)).^2);

Rsq is equal to Rsq1 if the Robust regression is off. However, if I use the 'Robust' option, then Rsq is not equal to Rsq1.

Can somebody explain the reason for this.

Sums80

Bruno Luong

unread,
Mar 14, 2012, 2:52:10 AM3/14/12
to
Just a guess, but Robust could remove some outliner data, thus R^2 changes.

Bruno

Phil Goddard

unread,
Mar 14, 2012, 10:48:12 AM3/14/12
to
A description of what the robust fit does is given (near the end) of the documentation,

http://www.mathworks.com/help/toolbox/stats/nlinfit.html

Phil.

Tom Lane

unread,
Mar 14, 2012, 11:15:24 AM3/14/12
to
> C = corrcoef(yfit, y);
> Rsq = C(1,2)^2;
>
> Rsq1 = 1 - sum(r.^2)/sum((y - mean(y)).^2);
>
> Rsq is equal to Rsq1 if the Robust regression is off. However, if I use
> the 'Robust' option, then Rsq is not equal to Rsq1.

That's right, the two are the same for least squares.

It's not so clear about how to define R-square for robust fits. We know a
least squares fit maximizes R-square, so the usual definition will never
yield a better R-square for a robust fit. Other definitions might replace
the residuals in the formula you wrote with some sort of weighted values, or
might replace the sum of squared residuals by a multiple of a robust
estimate of the error variance.

If there's a standard definition in use, I haven't seen it (but would like
to).

-- Tom

eliasest...@gmail.com

unread,
Sep 6, 2013, 7:30:44 PM9/6/13
to
It's just you get the gradient matrix, and from it obtain a linear model, just so you can determine the R2.
0 new messages