[R] argument "x" is missing in minpack.lm

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Tue Jun 30 14:04:41 CEST 2020


On Tue, 30 Jun 2020 13:53:10 +0200
Luigi Marongiu <marongiu.luigi using gmail.com> wrote:

> function(a, b, x) {
>   y = (a * x^2) / (b^2 + x^2)
>   return(y)
> }

Take a look at the examples in ?nls.lm. The first argument of the
function must be the parameter list/vector; the rest of the arguments
are passed from ... in nls.lm call. This is _unlike_ do.call, which can
be used to "unpack" a list of arguments into function arguments.

To make it more concrete, change your function to:

function(par) (par$a * par$x^2) / (par$b^2 + par$x^2)

Then it should work.

-- 
Best regards,
Ivan



More information about the R-help mailing list