[R] Q. regarding optim()

N. Goodacre ng296 at cam.ac.uk
Fri Jul 21 04:22:59 CEST 2006

Dear R mailing group,

  The second parameter for the function optim()is a function whose 
parameters are to be optimized. The description of this function given in 
the help file is the following:

      fn: A function to be minimized (or maximized), with first
          argument the vector of parameters over which minimization is
          to take place.  It should return a scalar result.

Let's say the second argument is x, a vector of x values

I would have thought that fn should return a vector full of y values for 
the x values entered as the second argument. If the function just takes one 
value at a time and outputs a scalar, how can I specify for fn which x 
value, of the vector x, to take?


Norman Goodacre

More information about the R-help mailing list