[R] Q. regarding optim()

From: N. Goodacre <ng296_at_cam.ac.uk>
Date: Fri 21 Jul 2006 - 12:22:59 EST


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?

 Sincerely,

Norman Goodacre



R-help@stat.math.ethz.ch 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 Jul 21 12:28:54 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 21 Jul 2006 - 18:15:41 EST.

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