Hello! I?m doing this: A<-optim(vv,pen.wlsv,method="BFGS") B<-optim(vv,pen.wlsv,method="Nelder-Mead") the function is the same and the initial values too the estimate values are different, very different, at the first decimal is there an error? or maybe its because of my data, or funtion to minimize? i thought that the values must be almost equal, that the big difference between the two algoritms is in the time that they use to find a solution thank u! -- View this message in context: http://r.789695.n4.nabble.com/BFGS-and-Neldear-Mead-tp3388017p3388017.html Sent from the R help mailing list archive at Nabble.com.
On Fri, Mar 18, 2011 at 11:27:58AM -0700, LC-Bea wrote:> Hello! > > I?m doing this: > > A<-optim(vv,pen.wlsv,method="BFGS") > B<-optim(vv,pen.wlsv,method="Nelder-Mead") > > the function is the same > and the initial values too > > the estimate values are different, very different, at the first decimal > > is there an error?Not necessarily.> or maybe its because of my data, or funtion to minimize? > i thought that the values must be almost equal, that the big difference > between the two algoritms is in the time that they use to find a solutionIf the function has several local minima, then different methods may found different ones. Can you send more detail about the minimized function? Petr Savicky.
It is important to pay attention to the convergence message. For example, if the convergence is due to reaching maximum iteration limit (this is often the case with Nelder-Mead), then you should increase the maxit from 500 to 1500 or something like that. Users generally have trouble interpreting the convergence messages. This is one of the reasons that we have implemented explicit convergence diagnostics in "optimx" through first- and second-order KKT conditions. So, you might want to re-run your problem with "optimx" and check the KKT conditions. If there are multiple optima, you can get different answers from properly converged iterations. Ravi. ------------------------------------------------------- Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvaradhan at jhmi.edu -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Petr Savicky Sent: Friday, March 18, 2011 5:25 PM To: r-help at r-project.org Subject: Re: [R] BFGS and Neldear-Mead On Fri, Mar 18, 2011 at 11:27:58AM -0700, LC-Bea wrote:> Hello! > > I?m doing this: > > A<-optim(vv,pen.wlsv,method="BFGS") > B<-optim(vv,pen.wlsv,method="Nelder-Mead") > > the function is the same > and the initial values too > > the estimate values are different, very different, at the first decimal > > is there an error?Not necessarily.> or maybe its because of my data, or funtion to minimize? > i thought that the values must be almost equal, that the big difference > between the two algoritms is in the time that they use to find a solutionIf the function has several local minima, then different methods may found different ones. Can you send more detail about the minimized function? Petr Savicky. ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
hello! this is one of the two functions i use pen.mle<-function(x){ ax<-x[32:40] indice<-x[1:31] bx<-x[41:49] amlebind1<-matrix(rep(ax,31),nrow=9,ncol=31) mv<-(-(defunciones*log((exp(amlebind1+bx%*%t(indice)))*poblacion)-((exp(amlebind1+bx%*%t(indice)))*poblacion))) result<-sum(mv)+1000000000*sum(((t(u)%*%x)-c)^2) result } thankssss! -- View this message in context: http://r.789695.n4.nabble.com/BFGS-and-Neldear-Mead-tp3388017p3393167.html Sent from the R help mailing list archive at Nabble.com.
Thank you for your answer! the message that gives as result is 0, successful completion so that point wouldnt be the problem sorry if my english its not good (i speak spanish!) thanks! -- View this message in context: http://r.789695.n4.nabble.com/BFGS-and-Neldear-Mead-tp3388017p3393173.html Sent from the R help mailing list archive at Nabble.com.
i?ve tried with optimx these are the results pleae help me with this... i?m triying to understand what they mean...> lcmleQNpar 1 2.32805062, 1.94101989, 1.96853015, 1.12342948, 1.40725816, 1.30226031, 0.55687649, 0.67490698, 0.69883229, 0.72925173, 0.54030535, 0.54461379, 0.36190589, 0.31421293, 0.11386490, -0.28615571, -0.14935098, -0.30644983, -0.56747037, -0.38677021, -0.41294107, -1.00118828, -0.94659793, -0.76224978, -0.62148013, -1.18925770, -1.47986739, -1.72204331, -1.16313012, -1.74013570, -1.87021566, -5.29621049, -8.00726862, -7.02957636, -6.67849924, -6.04102731, -5.16783472, -4.34209917, -3.54995556, -2.34885117, 0.29181040, 0.15986090, 0.02910809, 0.07948031, 0.13340674, 0.11592655, 0.07209577, 0.07753882, 0.04075539 fvalues method fns grs itns conv KKT1 KKT2 xtimes 1 -81140057 BFGS 527 28 NULL 0 TRUE FALSE 0.67> lcmleSpar 1 2.17772594, 2.01672660, 2.08178576, 0.70717754, 1.36665299, 1.52691701, 0.61881301, 0.66814873, 0.91881338, 0.74934458, 0.43494487, 0.46521162, 0.22710505, 0.29096933, 0.13061327, -0.48398756, -0.14132034, -0.40960459, -0.66999565, -0.34176956, -0.21534550, -1.07791017, -0.89938104, -0.54921569, -0.51838385, -1.17441612, -1.46214041, -1.76872051, -0.92208257, -1.79888615, -1.95263053, -5.20704215, -7.90426743, -6.92991136, -6.57552982, -5.95087991, -5.08538490, -4.29595406, -3.52006025, -2.31470204, 0.28528187, 0.15976461, 0.03450613, 0.08503689, 0.14405771, 0.10326205, 0.07218856, 0.07254385, 0.04414397 fvalues method fns grs itns conv KKT1 KKT2 xtimes 1 -81101764 Nelder-Mead 502 NA NULL 1 FALSE FALSE 0.11 thanks again!!! Luc?a (je! that?s my name) -- View this message in context: http://r.789695.n4.nabble.com/BFGS-and-Neldear-Mead-tp3388017p3393510.html Sent from the R help mailing list archive at Nabble.com.
Sorry for posting too much! i found that in Nelder-Mead the result is "1" i run this algorith too many times with several data maybe the problem is that i have to give a bigger number of iterations Luc?a -- View this message in context: http://r.789695.n4.nabble.com/BFGS-and-Neldear-Mead-tp3388017p3393527.html Sent from the R help mailing list archive at Nabble.com.
I?m triying to give you more information -other function (the problem its the same with both) pen.wls<-function(x){ ax<-x[32:40] indice<-x[1:31] bx<-x[41:49] awlsbind1<-matrix(rep(ax,31),nrow=9,ncol=31) indice<-as.vector(indice-mean(indice)) bx<-as.vector(bx/sum(bx)) me<-(awlsbind1+bx%*%t(indice)) result<-sum(defunciones*(lts-me)^2)+1000000000*sum(((t(u)%*%x)-c)^2) result} -I run it with optimx and i reach convergence with nealder-mead but values are still different BFGS an NM, both reach the convergence, code=0, but still produces different results -KKT conditions ara 1=T and 2=F but, this conditions are usefull when whe have constraints? i included one condition 1000000000*sum(((t(u)%*%x)-c)^2), that makes that sum(kt)=0 and sum(bx)=1 i hope that this information helps to understand where the problem is... Luc?a -- View this message in context: http://r.789695.n4.nabble.com/BFGS-and-Neldear-Mead-tp3388017p3393731.html Sent from the R help mailing list archive at Nabble.com.