I'm using the optim function to optimize 5 coefficients. I use this function to do this :
min.RSS = function(data, par){
sum(
((data$CCI) -
10^(par[1]+par[2]*data$Landsat +
par[3]*data$Landsat^2 +
par[4]*data$Landsat^3 +
par[5]*data$Landsat^4))^2, na.rm=TRUE)
}
The following coefficients are used in this function later
OC3 <- function(coeff, landsat_values) {
chloa <- 10^(coeff[1] + coeff[2]*landsat_values +
coeff[3]*landsat_values^2 +
coeff[4]*landsat_values^3 +
coeff[5]*landsat_values^4)
return(chloa)
}
The data$CCI values are quite low so when I'm using the other optimisation method of optim the results of the OC3 function is always 0. I wanted to fix this by putting some upper and lower values to my optimization like this :
optimization_LBFGSB <- optim(par=c(0.30963,-2.40052,1.28932,0.52802,-1.33825), fn=min.RSS, data = data, method = "L-BFGS-B", lower = c(-3,-3,-3,-3,-3), upper = c(3,3,3,3,3))
I don't know how to by-pass this problem