[R] problem with nls....

Martin Maechler m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Fri Mar 22 10:19:13 CET 2019


>>>>> Ivan Krylov 
>>>>>     on Thu, 21 Mar 2019 18:36:20 +0300 writes:

    > One of the assumptions made by least squares method is that the
    > residuals are independent and normally distributed with same parameters
    > (or, in case of weighted regression, the standard deviation of the
    > residual is known for every point). If this is the case, the parameters
    > that minimize the sum of squared residuals are the maximum likelihood
    > estimation of the true parameter values.

    > The problem is, your data doesn't seem to adhere well to your formula.
    > Have you tried plotting your HF1 - ((m/HF6) + 1) against HF6 (i.e. the
    > residuals themselves)? With large residual values (outliers?), the loss
    > function (i.e. sum of squared residuals) is disturbed and doesn't
    > reflect the values you would expect to get otherwise. Try computing
    > sum((HF1 - ((m/HF6) + 1))^2) for different values of m and see if
    > changing m makes any difference.

    > Try looking up "robust regression" (e.g. minimize sum of absolute
    > residuals instead of squared residuals; a unique solution is not
    > guaranteed, but it's be less disturbed by outliers).

Very good point, Ivan (as your previous ones on this thread -
thank you! it's great to have a couple of smart and patient
R-helpers such as you !!).

CRAN package robustbase
     https://cran.r-project.org/package=robustbase

has function nlrob()  to do non-linear
regression *robustly*, even using several methods, the default
one using robustly re-weighted nls().  I'm the maintainer of the
package and have been the "moderator" of the current nlrob()
function, but as you can read on it's help page, I'm not the
author of that function and its submethods:
https://www.rdocumentation.org/packages/robustbase/versions/0.93-4/topics/nlrob

Martin Maechler
ETH Zurich

    > -- 
    > Best regards,
    > Ivan

    > ______________________________________________
    > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
    > https://stat.ethz.ch/mailman/listinfo/r-help
    > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    > and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list