About the efficiency of R optimization function
popo UBC wrote:
Hi all! The objective function I want to minimize contains about 10 to 20 variables, maybe more in the future. I never solved such problems in R, so I had no idea about the efficiency of R's optimization functions. I know doing loop in R is quite slow, so I am not sure whether this shortage influences the speed of R's optimization functions. I would be very appreciated if anyone could share some experiences with me. The speed, stability of the R's optimization functions. Is it helpful to call a C/Fortran code to do the job, if possible. Many thanks in advance. Popo
Many functions available in R are implemented using a compiled language such as C or Fortran- not the R language it's self. For example, the "Source" section of the help page for optim states that the code for the Nelder-Mead, BFGS and Conjugate Gradient methods were translated to C from Pascal and then further optimized. The L-BFGS-B method appears to be implemented as Fortran code. Looking at the source of the optim function reveals that results are computed by a call to .Internal(). Such calls usually indicate that R is handing computations off to a compiled, rather than interpreted, routine. If you have C or Fortran code you would prefer to use, take a look at the help pages for .C() and .Fortran() as well as the "Writing R Extensions" manual. The command line tool R CMD SHLIB will help you compile your code to shared libraries that can be loaded by R using dyn.load(). -Charlie ----- Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University
View this message in context: http://www.nabble.com/About-the-efficiency-of-R-optimization-function-tp23552061p23552668.html Sent from the R help mailing list archive at Nabble.com.