Displaying 1 result from an estimated 1 matches for "optfunc".
Did you mean:
opfunc
2012 Apr 24
1
Use of optim to fit two curves at the same time ?
...ons (like those two for example) at the
same time using optim ... or another function in R ?
Thanks
Arnaud
######################################################################
## function 1
x1 <- 1:100
y1 <- 5.468 * x + 3 # + rnorm(100,0, 10)
dfxy <- cbind(x1,y1)
# Objective function
optfunc <- function(x, dfxy){
a <- x[1]
b <- x[2]
xtest <- dfxy[,1]
yobs <- 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....