Hi , can i ask if somebody know the syntax for optim function with multiple variables: I have function f (params,y,g,h,j) returnig z y<-C(0.2,0.5,0.6) where params<-c(x1,x2) I define g,h,j and then I define params, then use optim to structure it ..however if i use syntax optim(params , f,y=y,g=g,h=h,j=j) to optimize params , but i got result equalling to my params ..which is kind of wrong. I and if i use optim(params , f(params,y=y,g=g,h=h,j=j)) I get Error in function (par) : could not find function "fn" how ever none of them seems to be producing meaningful results Please I am newbie and could not find a proper answer to that.. Help me.!! Thanks -- View this message in context: http://r.789695.n4.nabble.com/optim-function-multi-variables-newbie-tp3242159p3242159.html Sent from the R help mailing list archive at Nabble.com.
On 27.01.2011 14:08, michalseneca wrote:> > Hi , > can i ask if somebody know the syntax for optim function with multiple > variables: > > I have function f (params,y,g,h,j) returnig z > y<-C(0.2,0.5,0.6) > where > params<-c(x1,x2) > I define g,h,j and then I define params, then use > optim to structure it ..however if i use syntax > > optim(params , f,y=y,g=g,h=h,j=j) to optimize params , but i got result > equalling to my params ..which is kind of wrong.The syntax above is correct, hence you need to describe the problem you try to solve, ideally including the full code for f and some example data. Uwe Ligges> I and if i use > optim(params , f(params,y=y,g=g,h=h,j=j)) I get>> > Error in function (par) : could not find function "fn" > > how ever none of them seems to be producing meaningful results > > Please I am newbie and could not find a proper answer to that.. > > Help me.!! > > Thanks >
Hi, Basically what I am trying is to rewrite matlab code into R ...This is code for famous SABR model Calibration. I did most of the code up to optimalization issue. In the attachment you can find matlab and my unfinished R code..This is very helpful code...Basically I am trying to achieve the same results. Thank you very much for your help..This might help me much with my thesis Best regards Michal Michal http://r.789695.n4.nabble.com/file/n3242469/optimtest optimtest http://r.789695.n4.nabble.com/file/n3242469/Hagan_Figure_33.zip Hagan_Figure_33.zip -- View this message in context: http://r.789695.n4.nabble.com/optim-function-multi-variables-newbie-tp3242159p3242469.html Sent from the R help mailing list archive at Nabble.com.