AW: [R] Full enumeration, how can this be vectorized

Daniel Hoppe daniel.hoppe at em.uni-karlsruhe.de
Mon Nov 25 22:39:00 CET 2002


>
> Without looking closer, I think this is a very nice example
> for a piece
> of code that should be implemented in either C or Fortran (on the one
> hand it is easy to implement, on the other hand its "S interpreted"
> execution takes quite a long time). OK, quite a few possible
> improvements of the R code are obvious, but I don't think this is the
> best point to start ...
>

Probably you are right about C and Fortran. But coming from the combination
of Java and Windows it's hard to overcome one's inhibitions and get started
with C :-). Beside that I'm specifically trying to improve my R-skills a
little because I wrote quite a lot of code for my thesis with R and
therefore I'm curious for better "code patterns".  In my R-code I vectorized
the function fun (thanks Patrick), seems to run somehow faster already.

> Nevertheless, the code looks like you are searching on a grid. Are you
> really sure whether there is no method in optim() which
> performs better?
>

I tried them but was not successful yet. The search range is constrained,
and Nelder-Mead doesn't use constraints. L-BFGS-B handles the constraints,
but it isn't able to handle functions with poles. The other ones did not
qualify for the same reasons.

I wonder if a grid-search is a very unusual case or if there might be a need
for a fast and generic implementation of such an algorithm.

Daniel

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list