diff --git a/matlab/cli/prior.m b/matlab/cli/prior.m index 703297d73..1e1fb4985 100644 --- a/matlab/cli/prior.m +++ b/matlab/cli/prior.m @@ -62,6 +62,12 @@ end % Fill or update bayestopt_ structure [xparam1, EstimatedParams, BayesOptions, lb, ub, Model] = set_prior(estim_params_, M_, options_); +% Set restricted state space +options_plot_priors_old=options_.plot_priors; +options_.plot_priors=0; +[~,~,~,~, M_, options_, oo_, EstimatedParams, BayesOptions] = ... + dynare_estimation_init(M_.endo_names, M_.fname, 1, M_, options_, oo_, estim_params_, bayestopt_); +options_.plot_priors=options_plot_priors_old; % Temporarly change qz_criterium option value @@ -102,7 +108,8 @@ if ismember('simulate', varargin) % Prior simulations (BK). disp(['Complex jacobian share = ' num2str(results.jacobian.problem_share)]) disp(['mjdgges crash share = ' num2str(results.dll.problem_share)]) disp(['Steady state problem share = ' num2str(results.ss.problem_share)]) - disp(['Complex steady state share = ' num2str(results.ss.complex_share)]) + disp(['Complex steady state share = ' num2str(results.ss.complex_share)]) + disp(['Endogenous prior violation share = ' num2str(results.endogenous_prior_violation_share)]) if options_.loglinear disp(['Nonpositive steady state share = ' num2str(results.ss.nonpositive_share)]) end @@ -130,10 +137,13 @@ if ismember('moments', varargin) % Prior simulations (2nd order moments). oo__ = oo_; oo__.dr = set_state_space(oo__.dr, Model, options_); % Solve model - [dr, info, Model , options__ , oo__] = resol(0, Model , options_ ,oo__); + [T,R,~,info,Model , options__ , oo__] = dynare_resolve(Model , options_ ,oo__,'restrict'); + if ~info(1) + info=endogenous_prior_restrictions(T,R,Model , options__ , oo__); + end if info skipline() - disp(sprintf('Cannot solve the model on the prior mode (info = %s, %s)', num2str(info(1)), interpret_resol_info(info))); + fprintf('Cannot solve the model on the prior mode (info = %s, %s)\n', num2str(info(1)), interpret_resol_info(info)); skipline() return end diff --git a/matlab/prior_sampler.m b/matlab/prior_sampler.m index ccc0dc415..2506f91c3 100644 --- a/matlab/prior_sampler.m +++ b/matlab/prior_sampler.m @@ -50,6 +50,7 @@ count_nan_steadystate = 0; count_nan_params = 0; count_complex_params = 0; count_nonpositive_steadystate = 0; +count_endogenous_prior_violation = 0; count_unknown_problem = 0; NumberOfSimulations = options_.prior_mc; NumberOfParameters = length(bayestopt_.p1); @@ -95,7 +96,11 @@ while iteration < NumberOfSimulations loop_indx = loop_indx+1; params = prior_draw(); M_ = set_all_parameters(params,estim_params_,M_); - [dr,INFO,M_,options_,oo_] = resol(work,M_,options_,oo_); + [T,R,~,INFO,M_,options_,oo_] = dynare_resolve(M_,options_,oo_,'restrict'); + dr=oo_.dr; + if ~INFO(1) + INFO=endogenous_prior_restrictions(T,R,M_,options_,oo_); + end file_line_number = file_line_number + 1; iteration = iteration + 1; if drsave @@ -138,6 +143,8 @@ while iteration < NumberOfSimulations count_nan_params = count_nan_params + 1 ; case 26 count_nonpositive_steadystate = count_nonpositive_steadystate + 1; + case 49 + count_endogenous_prior_violation = count_endogenous_prior_violation + 1; otherwise count_unknown_problem = count_unknown_problem + 1 ; end @@ -167,6 +174,7 @@ results.ss.complex_share = count_complex_steadystate/loop_indx; results.ass.problem_share = count_steadystate_file_exit/loop_indx; results.ss.nonpositive_share = count_nonpositive_steadystate/loop_indx; results.jacobian.problem_share = count_complex_jacobian/loop_indx; +results.endogenous_prior_violation_share = count_endogenous_prior_violation/loop_indx; results.garbage_share = ... results.bk.indeterminacy_share + ... results.bk.unstability_share + ... @@ -177,6 +185,7 @@ results.garbage_share = ... results.ss.complex_share + ... results.ss.nonpositive_share + ... results.jacobian.problem_share + ... + results.endogenous_prior_violation_share + ... count_unknown_problem/loop_indx ; results.prior.mean = sampled_prior_expectation; results.prior.variance = sampled_prior_covariance; diff --git a/tests/gsa/ls2003a.mod b/tests/gsa/ls2003a.mod index 0bca629a7..ada43c747 100644 --- a/tests/gsa/ls2003a.mod +++ b/tests/gsa/ls2003a.mod @@ -97,6 +97,8 @@ y_obs,R_obs(@{ilag}), -; //[ccf] y_obs,pie_obs(@{ilag}), -; //[ccf] @#endfor end; +prior simulate; +prior moments(distribution); if isoctave() dynare_sensitivity(prior_range=0, nodisplay, graph_format=(eps));