I have troubles providing supplementary arguments to optim
function. Parameters to be optimized over are sent as a first arguments, and extra arguments are to be provided as named arguments. But this doe not seem to work in my code
I have four arguments to be used for optimization (a,b,c,d)
and 4 more to be used as supplementary arguments, with no optimization (e
, f
, g
, h
, where e
and f
are scalars, and g
and h
are vectors). The function to be optimized is fct
.
I am trying:
parm<-c(a,b,c,d)
optim(par=parm,fn=fct,e=e,f=f,g=g,h=h)
Running this constantly returns that the g vector is missing, with no default value... I don't understand my mistake, even after reading on similar problems in discussion lists.