Problem with fminunc, why does the parameters not change?
Afficher commentaires plus anciens
Hi,
may be is a very simple mistake but I cant see it. I have a simple model to try how fminunc works and the thing is I dont get different parameters from the initial ones.
this is my code:
function main2()
pars0=[0.2 0.3 0.4]';
objective=@(x)li2(x);
[x,fval,exitflag,output,grad,hessian]= fminunc(objective,pars0);
disp(x);
disp(fval);
disp(exitflag);
end
function [ilik]=li2(x);
mData=randn(50,1);
iT=size(mData,1);
lik=zeros(iT,1);
hxt=zeros(iT,1);
Yt=0;
xt=0;
for i = 1 : iT
Yt=mData(i,1);
F=x(3,1)*Yt^2+x(1,1)*Yt+x(2,1);
hxt(i,1)=F;
lik(i,1) = -(0.5)*iT*log(2*pi)-0.5*F;
end
ilik = -sum(lik);
end
Thanks a lot in advance.
Réponse acceptée
Plus de réponses (1)
Barbara
le 14 Mai 2014
0 votes
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!