From 5b2053c347c76f4a6543be6c0f79845263c58b86 Mon Sep 17 00:00:00 2001 From: adjemian Date: Tue, 21 Nov 2006 12:52:32 +0000 Subject: [PATCH] improvements to the stochastic posterior mode optimization routine (mode_compute = 6) git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1091 ac1d8469-bf42-47a9-8791-bf33cf982152 --- matlab/dynare_estimation.m | 25 ++++++++++++++++--------- matlab/gmhmaxlik.m | 4 +++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m index 233a27155..ba2eb716b 100644 --- a/matlab/dynare_estimation.m +++ b/matlab/dynare_estimation.m @@ -357,18 +357,25 @@ if options_.mode_compute > 0 & options_.posterior_mode_estimation if exist('hh') CovJump = inv(hh); else% The covariance matrix is initialized with the prior - % covariance (a diagonal matrix) % Except for infinite variances ;-) - stdev = bayestopt_.pstdev; - indx = find(isinf(stdev)); - stdev(indx) = ones(length(indx),1)*0.1; - indx = find(stdev>2); - stdev(indx) = ones(length(indx),1)*0.1; - CovJump = diag(stdev).^2; - CovJump = eye(length(stdev))*0.5; + % covariance (a diagonal matrix) %%Except for infinite variances ;-) + varinit = 'prior'; + if strcmpi(varinit,'prior') + stdev = bayestopt_.pstdev; + indx = find(isinf(stdev)); + stdev(indx) = ones(length(indx),1)*sqrt(10); + vars = stdev.^2; + CovJump = diag(vars); + elseif strcmpi(varinit,'eye') + vars = ones(length(bayestopt_.pstdev),1)*0.1; + CovJump = diag(vars); + else + disp('gmhmaxlik :: Error!') + return + end end OldPostVar = CovJump; Scale = options_.mh_jscale; - for i=1:options_.Opt6Iter + for i=1:options_.Opt6Iter if i == 1 if options_.Opt6Iter > 1 flag = ''; diff --git a/matlab/gmhmaxlik.m b/matlab/gmhmaxlik.m index a9724c166..d4ba341e7 100644 --- a/matlab/gmhmaxlik.m +++ b/matlab/gmhmaxlik.m @@ -107,7 +107,9 @@ while j<=MaxNumberOfTuningSimulations test1 = jsux/jj; cfactor = test1/AcceptanceTarget; if cfactor>0 - iScale = iScale*cfactor; + iScale = iScale*cfactor; + else + iScale = iScale/10; end jsux = 0; jj = 0; if cfactor>0.90 && cfactor<1.10