s-news
[Top] [All Lists]

Re: optimization issue

To: stephane.g.zebouni@jpmorgan.com
Subject: Re: optimization issue
From: Tony Plate <tplate@blackmesacapital.com>
Date: Thu, 13 Oct 2005 09:32:20 -0600
Cc: S-news <s-news@lists.biostat.wustl.edu>
In-reply-to: <OFA4E14B74.B0D5E1CF-ON85257099.0052BA72-85257099.00531015@jpmchase.com>
References: <OFA4E14B74.B0D5E1CF-ON85257099.0052BA72-85257099.00531015@jpmchase.com>
User-agent: Mozilla Thunderbird 1.0.5 (Windows/20050711)
Just pass the additional arguments as extra arguments to nlminb:

> f <- function(x, aa=0, bb=0, cc=0) aa*x^2 + bb*x + cc
> nlminb(0, f, aa=1, bb=2, cc=1)[1:2]
$parameters:
[1] -1

$objective:
[1] 0

> nlminb(0, f, aa=1, bb=4, cc=1)[1:2]
$parameters:
[1] -2.000001

$objective:
[1] -3

>

Unfortunately, this is not documented correctly in the nlminb help page: the arguments "..." are not listed in the USAGE section. However, the "..." arguments are described in the ARGUMENTS section, and you can also see them by doing args(nlminb).

Something you have to be very careful of with this feature is that your actual arguments names do not partially (or fully) match other arguments of nlminb.

E.g., if your function definition was function(x, s=1), and you called nlminb(0, f, s=1), then the "s" argument would get matched to the "scale" argument of nlminb, and would NOT get passed to your function f().

hope this helps,

Tony Plate

stephane.g.zebouni@jpmorgan.com wrote:

Hello,

I am using S-plus 6.1 and the function nlminb to optimize a function of one parameter (a target function ofr an ewma model). I want to be able to pass an argument to the function that is not supposed to be optimized (i.e. i am minimizing on a given set of data,and i want to be able to change this set of data as i want to call the optimization several times on different sets of data) Is there a simple way to do that?

Thanks a lot

Stephane


This communication is for informational purposes only. It is not intended
as an offer or solicitation for the purchase or sale of any financial
instrument or as an official confirmation of any transaction. All market prices,
data and other information are not warranted as to completeness or accuracy and
are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates.



<Prev in Thread] Current Thread [Next in Thread>