[R] Optim Problem??

Duncan Murdoch murdoch at stats.uwo.ca
Sat Oct 3 23:32:18 CEST 2009

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

More information about the R-help mailing list