search for: ivtransf

Displaying 1 result from an estimated 1 matches for "ivtransf".

Did you mean: iv_transf
2011 Nov 10
3
optim seems to be finding a local minimum
...gle predictor: mysum<- function(myIV,myDV){ 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...