I ran into a problem with the DEoptim package. I am trying to minimize the function minF by optimizing vector optVector (see code).
##construct function
minF <- function(x, y, z){
return(mean((z-rowSums(t(x*t(y))))^2))
}
#random matrix and vector
testmrx <- matrix(rnorm(6),38,9)
vctr <- runif(38, min=0, max=50)
#Vector to be optimized and its bounds
optVector = c(20,20,50,30,30,10,3,5,5)
lowr = c(0,0,0,0,0,0,0,0,0)
uppr = c(50,50,200,100,100,50,20,20,20)
#Call of DEoptim
DEoptim(fn = minF(optVector, testmrx, vctr), lower=lowr, upper=uppr)
When I try to do this I get following error:
Error in get(as.character(FUN), mode = "function", envir = envir) :
object 'fn' of mode 'function' was not found
I found a similar error posted (link), but the proposed solution of changing variable names did not work. I have no idea what might be causing the problem here. Any help would be greatly appreciated!