Hello,
I am trying to optimize a function with the function nls.lm from the
package minpack.lm. But I can't get it right:
```
A = 3261
B = 10
K = c(8, 24, 39, 63, 89, 115, 153, 196, 242, 287, 344, 408, 473,
546, 619, 705, 794, 891, 999, 1096, 1242, 1363, 1506, 1648, 1753,
1851, 1987, 2101, 2219, 2328, 2425, 2575, 2646, 2698, 2727, 2771, 2818,
2853, 2895, 2926, 2964, 2995, 3025, 3053, 3080, 3102, 3119, 3141, 3152,
3159, 3172, 3182, 3196, 3209, 3220, 3231, 3239, 3246, 3252, 3261)
O = nls.lm(list(a=A, b=B, x=X), holling,
lower=NULL, upper=NULL, jac = NULL)> Error in fn(par, ...) : argument "x" is missing, with no default
```
What am I missing?
Is nls.lm the right function for functions that are not linear?
Thank you
--
Best regards,
Luigi
You create objects A, B, and K, but then use A, B, and X in the call to nls.lm(). I have no idea if nls.lm is the right tool for your job, but I do know that you need to use the same names. Sarah On Tue, Jun 30, 2020 at 6:01 AM Luigi Marongiu <marongiu.luigi at gmail.com> wrote:> Hello, > I am trying to optimize a function with the function nls.lm from the > package minpack.lm. But I can't get it right: > ``` > A = 3261 > B = 10 > K = c(8, 24, 39, 63, 89, 115, 153, 196, 242, 287, 344, > 408, 473, > 546, 619, 705, 794, 891, 999, 1096, 1242, 1363, 1506, 1648, > 1753, > 1851, 1987, 2101, 2219, 2328, 2425, 2575, 2646, 2698, 2727, 2771, > 2818, > 2853, 2895, 2926, 2964, 2995, 3025, 3053, 3080, 3102, 3119, 3141, > 3152, > 3159, 3172, 3182, 3196, 3209, 3220, 3231, 3239, 3246, 3252, 3261) > O = nls.lm(list(a=A, b=B, x=X), holling, > lower=NULL, upper=NULL, jac = NULL) > > Error in fn(par, ...) : argument "x" is missing, with no default > ``` > What am I missing? > Is nls.lm the right function for functions that are not linear? > Thank you > -- > Best regards, > Luigi > > ______________________________________________ > R-help at 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. >-- Sarah Goslee (she/her) http://www.sarahgoslee.com [[alternative HTML version deleted]]
But I get the same error even if I run:
```
parms = list(a=3261, b=10, x=CH$Cum_Dead[1:60])
O = nls.lm(parms, holling,
lower=NULL, upper=NULL, jac = NULL)> Error in fn(par, ...) : argument "x" is missing, with no default
```
the function to be optimized is:
```
function(a, b, x) {
y = (a * x^2) / (b^2 + x^2)
return(y)
}
```
so the parameters a, b, x are the same I called within nls.lm
On Tue, Jun 30, 2020 at 1:32 PM Sarah Goslee <sarah.goslee at gmail.com>
wrote:>
> You create objects A, B, and K, but then use A, B, and X in the call to
nls.lm().
>
> I have no idea if nls.lm is the right tool for your job, but I do know that
you need to use the same names.
>
> Sarah
>
> On Tue, Jun 30, 2020 at 6:01 AM Luigi Marongiu <marongiu.luigi at
gmail.com> wrote:
>>
>> Hello,
>> I am trying to optimize a function with the function nls.lm from the
>> package minpack.lm. But I can't get it right:
>> ```
>> A = 3261
>> B = 10
>> K = c(8, 24, 39, 63, 89, 115, 153, 196, 242, 287, 344,
408, 473,
>> 546, 619, 705, 794, 891, 999, 1096, 1242, 1363, 1506, 1648,
1753,
>> 1851, 1987, 2101, 2219, 2328, 2425, 2575, 2646, 2698, 2727, 2771,
2818,
>> 2853, 2895, 2926, 2964, 2995, 3025, 3053, 3080, 3102, 3119, 3141,
3152,
>> 3159, 3172, 3182, 3196, 3209, 3220, 3231, 3239, 3246, 3252, 3261)
>> O = nls.lm(list(a=A, b=B, x=X), holling,
>> lower=NULL, upper=NULL, jac = NULL)
>> > Error in fn(par, ...) : argument "x" is missing, with no
default
>> ```
>> What am I missing?
>> Is nls.lm the right function for functions that are not linear?
>> Thank you
>> --
>> Best regards,
>> Luigi
>>
>> ______________________________________________
>> R-help at 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.
>
> --
> Sarah Goslee (she/her)
> http://www.sarahgoslee.com
--
Best regards,
Luigi