Displaying 1 result from an estimated 1 matches for "sumofdevs".
2011 Nov 10
3
optim seems to be finding a local minimum
...){
regr<-lm(myDV[[1]] ~ 0 + myIV[[1]])
mysum<-sum(abs(regr$resid))
return(mysum)
}
### Function to be optimized;
### param is a vector of 2 values (.alpha and .beta)
myfunc <- function(param){
myalpha<-param[1]
mybeta<-param[2]
IVtransf<-transformIV(myalpha, mybeta)
sumofdevs<-mysum(myIV=IVtransf,myDV=DV)
return(sumofdevs)
}
# Optimizing using optim:
myopt <- optim(fn=myfunc, par=c(0.1,max(IV)), method="L-BFGS-B", lower=0)
(myopt)
myfunc(myopt$par)
## Comparing this solution to Excel Solver solution:
myfunc(c(0.888452533990788,94812732.0897449))
--...