[R] Trouble with optim on a specific problem

Liviu Andronic landronimirc at gmail.com
Tue Jun 16 08:34:35 CEST 2009


Hello,

On 6/16/09, Stu @ AGS <stu at agstechnet.com> wrote:
>  Error in optim(c(0.66, 0.999, 0.064), pe, NULL, method = "L-BFGS-B") :
>
>   objective function in optim evaluates to length 6 not 1
>
<skip>
>
>  > pe <- function(c) c[1]*x1*x2^c[2]*x3^c[3]
>
I would suspect a matrix multiplication issue. In order to minimise
your function optim expects the result of your specific function to be
a scalar. Are you sure that after all the multiplications pe results
in a vector of dimension 1x1?
Liviu




More information about the R-help mailing list