Fixes to mode_compute=5. (1) force univariate steps at every iteration: improve robustness at the expenses of a bit less efficiency; (2) fix gradient computation for special cases when the value of the parameters get stacked at the prior boundary.

time-shift
Marco Ratto 2013-12-07 10:52:27 +01:00
parent a26d32b7fa
commit e5854cb201
2 changed files with 3 additions and 2 deletions

View File

@ -101,6 +101,7 @@ while i<n
h1(i)=2.1*h1(i);
end
h1(i) = min(h1(i),0.5*hmax(i));
h1(i) = max(h1(i),1.e-10);
xh1(i)=x(i)+h1(i);
try
[fx, ffx]=feval(func,xh1,DynareDataset,DynareOptions,Model,EstimatedParameters,BayesInfo,DynareResults);

View File

@ -122,7 +122,7 @@ while norm(gg)>gtol && check==0 && jit<nit
fval=fval1;
x0=x01;
end
if icount==1 || (icount>1 && (fval0(icount-1)-fval0(icount))>1) || ((fval0(icount)-fval)<1.e-2*(gg'*(H*gg))/2 && igibbs),
% if icount==1 || (icount>1 && (fval0(icount-1)-fval0(icount))>1) || ((fval0(icount)-fval)<1.e-2*(gg'*(H*gg))/2 && igibbs),
if length(find(ig))<nx
ggx=ggx*0;
ggx(find(ig))=gg(find(ig));
@ -139,7 +139,7 @@ while norm(gg)>gtol && check==0 && jit<nit
nig=[nig ig];
disp('Sequence of univariate steps!!')
fval=fvala;
end
% end
if (fval0(icount)-fval)<ftol && flagit==0
disp('Try diagonal Hessian')
ihh=diag(1./(diag(hhg)));