Displaying 1 result from an estimated 1 matches for "optfunc2".
Did you mean:
optfunc
2012 Apr 24
1
Use of optim to fit two curves at the same time ?
...obs <- dfxy[,2]
ysim <- a*xtest + b
sum((ysim - yobs)^2)
}
out<- optim(par=c(0.2,5), fn=function(x){optfunc(x, dfxy)}, method =
"Nelder-Mead", hessian = F)
## function 2
x2 <- seq(0.01, 0.1, length=100)
y2 <- exp(30*x2)
dfxy2 <- cbind(x2,y2)
# objective function
optfunc2 <- function(x, dfxy){
a <- x[1]
xtest <- dfxy[,1]
yobs <- dfxy[,2]
ysim <- exp(a*xtest)
sum((ysim - yobs)^2)
}
out<- optimize(f=function(x){optfunc2(x, dfxy2)}, interval=c(0,500))
######################################################################
[[alternative HT...