The scientists who built the core R system have included a number of tools for optimization. In this chapter, we explore these and review their strengths and weaknesses. It is, however, important to note the following.
optim() is one of the most used tools in R. It incorporates five methods, three of which are derived from the author's own work (Nash, 1979). The five methods are largely independent but are all called through
optim(), using a call such as
ans<-optim(start, fn=myfn, gr=mygr, method="BFGS", X=myx, Y=myY, control=list(trace=1))
start is the vector of parameters that are used as the initial point of the optimization iteration,
myfn is the function to be minimized,
mygr is its gradient, and the control list specifies that we want to follow the iterations (
trace), while the elements given ...