Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

trouble with optimx() ("Cannot evaluate function at initial parameters")

$
0
0

I would like to maximize a function of x1, x2, and x3 as follows

f <- function(x) x[1]*14.1638 + x[2]*4.2062 + 
   x[3]*0.6700 - x[1]*x[2]*2.2175 + x[1]*x[3]*2.8800 + 
   x[2]*x[3]*2.0450 + x[1]*x[1]*9.9863 - 
   x[2]*x[2]*12.6738 - x[3]*x[3]*10.9062 + 36.4100

params <- c(1,1,1)

r <- optimx(params, f,gr=NULL, hess=NULL,  lower=-1, upper=1, 
    method=c("Nelder-Mead", "L-BFGS-B"), itnmax=c(50), 
    maximize=TRUE )

r$convergence == 0

r$par

But I am getting the warning message

Error in optimx.check(par, optcfg$ufn, optcfg$ugr, optcfg$uhess, lower, : Cannot evaluate function at initial parameters

I am pretty sure I am missing something basic in function parameters but I am not able to figure out what.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>