On 03/10/2009 5:26 PM, Jim Silverton wrote:> I have having the following error message when trying to optimize a
function
> using optim:
>
>
>
>> optim(c(10,100),fn,method="BFGS")
> Error in optim(c(10, 100), fn, method = "BFGS") :
> cannot coerce type 'S4' to vector of type 'double'
>
> Can someone tell me what this means?
I'd guess your fn doesn't return a numeric vector, it returns an object
of type 'S4'. To be more specific, we'd need to see some code to
reproduce the error message.
Duncan Murdoch