[Rd] Optimization in R

Andrew Clausen clausen at econ.upenn.edu
Sat Aug 4 16:02:20 CEST 2007


Hi Pat,

On Sat, Aug 04, 2007 at 09:59:57AM +0100, Patrick Burns wrote:
> Sounds like a good project.

Thanks :)

> How much extra overhead are you getting from the
> algorithm being in R?

On the Rosenbrock function (which is very quick to evaluate), here are the
system.time() results:

> system.time(bfgs(x0, f, g))
[1] 0.148 0.000 0.149 0.000 0.000
> system.time(optim(x0, f, g, method="BFGS"))
[1] 0.008 0.000 0.008 0.000 0.000

and the function evaluation counts:

> bfgs(x0, f, g)$counts
function gradient 
      95       58 
> optim(x0, f, g, method="BFGS")$counts
function gradient 
     318      100 

So the overhead is clearly much bigger, but still too small to matter for
most (?) applications.

Cheers,
Andrew

PS, my computer is a "Intel(R) Pentium(R) 4 CPU 2.80GHz" with a
1024 KB cache, according to /proc/cpuinfo.



More information about the R-devel mailing list