Hi all, Would be great if you could help me get my head around the "further arguemnts" in the optim function. Let's say we have f and g as shown:
f<-function(x,a,b){(x-a)^2+b} optim(100,fn=f,gr=NULL,2,5) #the NULL is annoying g<-function(x,a){2*(x-a)} optim(100,fn=f,gr=g,2,5) 1. How does optim know that 2,5 both go into f whereas g only accepts the first of those arguments. WHAT IF for some random reason I wanted there to be no common parameters, what then? so for example the input for g to be 3 s.t. f(x,2,5) and g(x,3) 2. Is there a way for me to skip writing gr=NULL the first time I implement this? Its quite important for me as I want to implement optimx where the "further arguments" are the last ones, and I do not want to go setting each parameter to some sort of default. basically I want to say: optim(100,fn=f,further_args=c(2,5)) Thanks in advance, Sachin [[alternative HTML version deleted]] ______________________________________________ R-help@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.