Commit 7e221e5d authored by MichelJuillard's avatar MichelJuillard
Browse files

factoring setting of bayestop_.penalty = Inf in Metropolis

parent 7959102d
......@@ -59,8 +59,6 @@ if ~isempty(M_.bvar)
ModelName = [M_.fname '_bvar'];
end
bayestopt_.penalty = Inf;
MhDirectoryName = CheckPath('metropolis',M_.dname);
nblck = options_.mh_nblck;
......@@ -113,7 +111,8 @@ if ~options_.load_mh_file && ~options_.mh_recover
if all(candidate(:) > mh_bounds(:,1)) && all(candidate(:) < mh_bounds(:,2))
ix2(j,:) = candidate;
ilogpo2(j) = - feval(TargetFun,ix2(j,:)',dataset_,options_,M_,estim_params_,bayestopt_,oo_);
if ilogpo2(j) <= - bayestopt_.penalty+1e-6
if ~isfinite(ilogpo2(j)) % if returned log-density is
% Inf or Nan (penalized value)
validate = 0;
else
fprintf(fidlog,[' Blck ' int2str(j) ':\n']);
......
......@@ -56,6 +56,12 @@ function record=random_walk_metropolis_hastings(TargetFun,ProposalFun,xparam1,vv
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% In Metropolis, we set penalty to Inf to as to reject all parameter sets
% triggering error in target density computation
bayestopt_.penalty = Inf;
%%%%
%%%% Initialization of the random walk metropolis-hastings chains.
%%%%
......
......@@ -103,9 +103,6 @@ if whoiam
bayestopt_.p3,bayestopt_.p4,1);
end
% (re)Set the penalty
bayestopt_.penalty = Inf;
MhDirectoryName = CheckPath('metropolis',M_.dname);
options_.lik_algo = 1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment