[R] Advice wanted on using optim with both continuous and discrete par arguments...
Uwe Ligges
ligges at statistik.tu-dortmund.de
Mon Mar 1 18:28:52 CET 2010
On 01.03.2010 16:34, Jeffrey Racine wrote:
> Dear R users,
>
> I have a problem for which my objective function depends on both discrete and continuous arguments.
>
> The problem is that the number of combinations for the (multivariate) discrete arguments can become overwhelming (when it is univariate this is not an issue) hence search over the continuous arguments for each possible combination of the discrete arguments may not be feasible. Guided search over the discrete and continuous arguments would be infinitely preferable. That is, exhaustive search over all possible combinations works perfectly, but for large problems exhaustive search simply is not in the feasible set.
>
> Both the discrete and continuous arguments are bounded (the discrete lie in [0,K] and the continuous in [0,1]) and I am using L-BFGS-B with lower and upper vectors defining these bounds.
>
> The issue is that when I feed optim my objective function and par (whose first `k' elements must necessarily be rounded by my objective function while the remaining `l' arguments are continuous), the default settings naturally do not perform well at all. Typically if the initial values for the discrete variables are, say, par[1:3]= c(2,3,4) while those for the continuous are, say, par[4:6] = c(.17, .35, .85), then optim finds the minimum for only the continuous variables and dumps back the initial values for the discrete variables. I presume that the numerical approximation to the gradients/hessian is thrown off by the `flat spots' or step-like-nature of the objective function with respect to the discrete variables.
>
> I have played with ndeps, parscale etc. but nothing really works. I realize this is a mixed combinatorial optimization/continuous optimization problem and ideally would love pointers to any related literature or ideally an R package that implements such a beast.
>
> However, if anyone has attempted to use optimization routines native to R with any success in similar settings, I would love to get your feedback.
If your 3 first discrete variables have a rather limited number of
possible values (sounds like that is the case), you may want to apply
optim() on the other variables on a complete grid of the first 3
variables and select the best result. Even with this complete evaluation
of the whole grid with say 20 possible values in each dimension the
results should be there within minutes without a need for more
specialized optimization procedures. ...
Best wishes,
Uwe Ligges
> Many thanks in advance for your advice.
>
> -- Jeff
>
>
>
> Professor J. S. Racine Phone: (905) 525 9140 x 23825
> Department of Economics FAX: (905) 521-8232
> McMaster University e-mail: racinej at mcmaster.ca
> 1280 Main St. W.,Hamilton, URL: http://www.economics.mcmaster.ca/racine/
> Ontario, Canada. L8S 4M4
>
> `The generation of random numbers is too important to be left to chance'
>
> ______________________________________________
> 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.
More information about the R-help
mailing list