[R] optim function multi variables -newbie

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu Jan 27 16:03:08 CET 2011



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
>



More information about the R-help mailing list