Path: news.mathworks.com!not-for-mail
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$1@newscl01ah.mathworks.com>
References: <kadqg5$ehk$1@newscl01ah.mathworks.com> <kadrlf$i7v$1@newscl01ah.mathworks.com> <kadsoq$lg2$1@newscl01ah.mathworks.com> <kaffio$ja8$1@newscl01ah.mathworks.com> <kafhls$qip$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1355520188 4255 172.30.248.46 (14 Dec 2012 21:23:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 14 Dec 2012 21:23:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:784861

"Lizzy " <lookforaroommate@126.com> wrote in message <kafhls$qip$1@newscl01ah.mathworks.com>...
>
> 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.