From: "Lizzy " <>
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$>
References: <kadqg5$ehk$> <kadrlf$i7v$> <kadsoq$lg2$> <kadtqg$ou4$>
Reply-To: "Lizzy " <>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1355448009 28472 (14 Dec 2012 01:20:09 GMT)
NNTP-Posting-Date: Fri, 14 Dec 2012 01:20:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3922075
Xref: comp.soft-sys.matlab:784794

"Matt J" wrote in message <kadtqg$ou4$>...
> "Lizzy " <> wrote in message <kadsoq$lg2$>...
> >
> > 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);

aa     = log(phi/(abs(sigma)+eps));
bb     = log(1-phi2);
llk    = d.*aa+(1-d).*bb;

res = -sum(llk);

Is it correct? Thanks a lot.