'How can I define a function in the form of f(a;b) in R?

This has been a recurring problem for me, so I'll have to address it here. I'm trying to build a non-linear optimization problem using optim or fsolve, and I need certain variables as fixed parameters.

So by f(a;b), I mean a function that defines b as given, and immovable for the optimization. Evidently matlab has a way to define b as just a parameter set & only allow a to be moved in the optimization; in R this doesn't seem to apply in the same way as matlab. Both optim & fsolve require that I specify the initial values of both a & b, and they calculate the results shifting b as well as a.

If anyone could let me know of a good way out of this that would be much appreciated. Thank you!



Solution 1:[1]

You can pass b via the ... argument of optim.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Enrico Schumann