Re: [R] nlm and "missing argument

From: Charilaos Skiadas <cskiadas_at_gmail.com>
Date: Fri, 30 May 2008 00:11:47 -0400

On May 29, 2008, at 11:54 PM, Redding, Matthew wrote:

> Dear R Gurus,
>
> I am having a little difficulty with nlm. I've searched the
> archives and
> found nothing that tells me why this is occuring -- though there are
> some slightly similar issues.
>
> A simple example:
>
> lev2<-function(aaa,bbb,ccc,ddd,eee){
> res<-aaa+bbb+ccc+ddd+eee
> res
>
> }
>
> nlm(lev2,p=c(32,4,5),ddd=45,eee=23)
>
> Error in f(x, ...) : argument "bbb" is missing, with no default
>
> Why is this occurring? I am running 2.6.1.
>
> Is there something simple here that I am overlooking? I am trying to
> take advantage of the "..." method of inputing
> parameters that I do not want optimised.
>
> Kind regards,

Read the documentation for nlm more closely. The Arguments part says about f:

        This should be a function of a vector of the length of p followed by any other arguments specified by the ... argument.

All the examples in fact do exactly that, using only the first variable, x, of f for all the unknowns. So perhaps you want to do a simple wrapping like this:

lev3 <- function(x,ddd,eee) {

        lev2(x[1],x[2],x[3],ddd,eee)
}
nlm(lev3,p=c(32,4,5),ddd=45,eee=23)

> Matt Redding

Haris Skiadas
Department of Mathematics and Computer Science Hanover College



R-help_at_r-project.org mailing list
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. Received on Fri 30 May 2008 - 04:14:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 30 May 2008 - 05:30:41 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive