How can I optimize a two variable function in R
问题 I have been trying to optimize the following function, but without success: parametros <- data.frame(ap=c(11.1,7.07,6.3,4.75,4,3.35), fx=c(41.2012,39.3732,25.2912,10.3455,1.2253,0.4017)) xm<-11.2 fxcalc <- function(s,t){(1-(1-(parametros$ap/xm)^(s))^t)*100} suma <- function(s,t){(parametros$fx-fxcalc(s,t))^2} func <- function(s,t){sum(suma(s,t))} Being "func()" the function I am trying to minimize for "s" and "t". Apparently the function "optim()" wouldn't work with more than one variable.