From: Tim on
I've done a nonlinear regression using lsqcurvfit and would like to find my most under-predicted value. The help page for lsqcurvefit shows residuals computed as predicted - observed.

In the residual analysis section of the Curve Fitting toolbox help page it has residuals being computed as observed - predicted.
http://www.mathworks.com/access/helpdesk/help/toolbox/curvefit/bq_5ka6-1_1.html

I realize for most applications it is the distance to the best fit line that matters, not necessarily the direction. It matters in my case and I can easily pick out the value I'm interested in. But I'm now curious as to why there is an inconsistency in the way Matlab computes residuals. Is there an inconsistency or am I misunderstanding something?

Thanks,

Tim
From: John D'Errico on
"Tim " <tcalappi(a)wayne.edu> wrote in message <hqkf89$d99$1(a)fred.mathworks.com>...
> I've done a nonlinear regression using lsqcurvfit and would like to find my most under-predicted value. The help page for lsqcurvefit shows residuals computed as predicted - observed.
>
> In the residual analysis section of the Curve Fitting toolbox help page it has residuals being computed as observed - predicted.
> http://www.mathworks.com/access/helpdesk/help/toolbox/curvefit/bq_5ka6-1_1.html
>
> I realize for most applications it is the distance to the best fit line that matters, not necessarily the direction. It matters in my case and I can easily pick out the value I'm interested in. But I'm now curious as to why there is an inconsistency in the way Matlab computes residuals. Is there an inconsistency or am I misunderstanding something?
>

But it is absolutely unimportant. So I doubt that they
worry about the sign here, nor should they, except that
the documentation should always be consistent.

Personally, I like my residuals to be always computed
as (yhat - y). (That is, yhat is the prediction.) This
means that when I see a positive residual, the prediction
is above my target value, whereas a negative residual
means that my function predicts below the target.

I recall that many others seem to go with (y - yhat)
though. It really is irrelevant in terms of the sum of
squares.

John