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

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Wed Jul 1 15:15:10 CEST 2020

On Wed, 1 Jul 2020 14:31:19 +0200
Luigi Marongiu <marongiu.luigi using gmail.com> wrote:

>  the optimization actually got a worse outcome than the original
>eyeball estimation

Could you elaborate on the function you are trying to fit to your data?
nls.lm takes a function returning a vector of residuals, that is,

fn <- function(parameters, input, actual.output) {
 calculate.output(parameters, input) - actual.output

...which means that you need a vector of input values and a vector of
output values of the same length. In your example,

> y = (p$a * x^2) / (p$b^2 + x^2)

a and b are parameters. x seems to be the dependent variable (i.e.
output of the process) and not the independent variable (i.e. input of
the model function) like I had initially assumed. What is the input of
your model function?

Best regards,

More information about the R-help mailing list