> 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