Re: [R] Q. regarding optim()

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 21 Jul 2006 - 16:12:59 EST

On Fri, 21 Jul 2006, N. Goodacre wrote:

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

But it says `parameters'. Please look at the examples on that help page. optim is concerned with optimizing functions of more than one parameter. In a statistical setting 'x' may be the data, but e.g. for fitting a gamma distribution c(scale, shape) are the parameters.

> 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.
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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 16:21:51 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:47 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.