From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: use fminsearch and fmincon to find MLE
Date: Fri, 14 Dec 2012 21:23:08 +0000 (UTC)
Organization: Xoran Technologies
Lines: 12
Message-ID: <kag5bs$44v$>
References: <kadqg5$ehk$> <kadrlf$i7v$> <kadsoq$lg2$> <kaffio$ja8$> <kafhls$qip$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1355520188 4255 (14 Dec 2012 21:23:08 GMT)
NNTP-Posting-Date: Fri, 14 Dec 2012 21:23:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: comp.soft-sys.matlab:784861

"Lizzy " <> wrote in message <kafhls$qip$>...
> And can anyone please tell me if this code is correct?
> coefInit = [1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;9];
> options_fminsearch = optimset('Display','iter','TolFun',1e-4,'TolX',1e-4,'MaxIt',10000000,'MaxFunEvals',10000000000000);
> [coefEst,fval,exitflag,output] = fmincon(@(coef) llk(coef,q,p,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12),coefInit,A,b,[],[],[],[],[],options_fminsearch);

Since you only have upper and lower bound constraints, like sigma>=eps, you should be using the lb and ub input arguments, rather than A and b.

Also, as Alan and I mentioned, you should use optimset to set the 'Algorithm' option to something like  'interior-point' or 'sqp' that know how to deal with the NaN regions of your objective function.