Path: news.mathworks.com!not-for-mail From: "Lizzy " <lizzy1230@gmail.com> Newsgroups: comp.soft-sys.matlab Subject: Re: use fminsearch and fmincon to find MLE Date: Fri, 14 Dec 2012 01:20:09 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 39 Message-ID: <kadus9$rpo$1@newscl01ah.mathworks.com> References: <kadqg5$ehk$1@newscl01ah.mathworks.com> <kadrlf$i7v$1@newscl01ah.mathworks.com> <kadsoq$lg2$1@newscl01ah.mathworks.com> <kadtqg$ou4$1@newscl01ah.mathworks.com> Reply-To: "Lizzy " <lizzy1230@gmail.com> NNTP-Posting-Host: www-06-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1355448009 28472 172.30.248.38 (14 Dec 2012 01:20:09 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 14 Dec 2012 01:20:09 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 3922075 Xref: news.mathworks.com comp.soft-sys.matlab:784794 "Matt J" wrote in message <kadtqg$ou4$1@newscl01ah.mathworks.com>... > "Lizzy " <lizzy1230@gmail.com> wrote in message <kadsoq$lg2$1@newscl01ah.mathworks.com>... > > > > Well, when I use fminsearch, the results are better. > ============ > > It's not clear what you mean by "the results are better". How are you measuring "better"? > > > > Optimization terminated: > > the current x satisfies the termination criteria using OPTIONS.TolX of 1.000000e-020 > > and F(X) satisfies the convergence criteria using OPTIONS.TolFun of 1.000000e-010 > > So does it mean that it converges? > > > It means that it converged to something, but not necessarily to an optimal point. You could plug the solution given by fminsearch into fmincon and see if it progresses further downhill. > > > > I'm now trying to use fminsearch, but change wherever there is a sigma to abs(sigma)+eps. And the final result of sigma I want to estimated is calculated by abs(result of sigma)+eps. (and the result is the same if I don't use this abs(.)+eps. Is it a correct way? > ============ > > It sounds reasonable for FMINSEARCH. You couldn't use this objective in FMINCON because FMINCON only handles differentiable functions. Thanks Matt. But what if I have no idea if my function is differentiable or not? And if I use fminsearch, is it ok that I set sigma as abs(sigma)+eps to make it greater than 0? And my code is as follows: coefInit = [1,1,1,1,1....1]]; options_fminsearch = optimset('Display','iter','TolFun',1e-10,'TolX',1e-20,'MaxIt',10000000,'MaxFunEvals',10000000000000); coefEst = fminsearch(@(coef) llk(coef,x1....xn),coefInit,options_fminsearch); And aa = log(phi/(abs(sigma)+eps)); aa(isnan(aa))=-inf; bb = log(1-phi2); bb(isnan(bb))=-inf; llk = d.*aa+(1-d).*bb; res = -sum(llk); Is it correct? Thanks a lot.