Parameters estimation using maximum likelihood with fmincon

Hi all,
I need to find the parameters by MLE. My code is as below. It seems to give me the values if without log(L) but incorrect from the original equation.
function LL = Loglikelihood(theta)
data = readtable('Test_data1.xlsx')
Gap = data.Var2
Vni = data.Var3
an = data.Var4
pn = data.Var5
hn = data.Var6
sn = data.Var7
n=length(Gap); %500 samples
b1 = theta(1); % parameter
b2 = theta(2); % parameter
b3 = theta(3); % parameter
b4 = theta(4); % parameter
b5 = theta(5); % parameter
b6 = theta(6); % parameter
sig = theta(7); % sigma
LL=0;
%%% try to find log likelihood
for ind = 1:n
L = (1./sig).*(normpdf(((Gap(ind)-(b1.*(Vni(ind).^b2).*((b3).^hn(ind)).*((b4).^pn(ind)).*((b5).^sn(ind))./((abs(an(ind)+exp(-50))).^(b6)))))./(sig)));
LL= LL+(log(L));
end
LL = -sum(LL)
end
%%% try to find optimization
A=[];
b=[];
Aeq=[];
beq=[];
lb=[-2 -2 0.5 0.5 0.5 -2 0.07];
ub=[4 4 2 2 2 2 2];
theta_0 =[ 2 1 1 1.5 1.5 1.5 4 ];
options=optimset('PlotFcns','optimplotfval','Display','off','MaxIter',10000,'TolX', 10e-6, 'MaxFunEvals', 10000, 'TolFun',10e-6);
[theta,fval,exitflag,output,grad,hessian] = fmincon(@Loglikelihood,theta_0,A,b,Aeq,beq,lb,ub,[],options)
The error shows " Error using barrier
Objective function is undefined at initial point". Fmincon cannot continue.
And there are somethings wrong with fmincon function.
Thanks in advance.

1 个评论

Since you're using normal-distributed samples the maximum-likelihood estimates should be the identical to the weighted least-squares solution.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Surrogate Optimization 的更多信息

产品

版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by