Problem with fminunc, why does the parameters not change?
Show older comments
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.
Accepted Answer
More Answers (1)
Barbara
on 14 May 2014
0 votes
Categories
Find more on Write Constraints in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!