Skip to content

Commit

Permalink
Born_Pfeifer_2014/Born_Pfeifer_RM_Comment.mod: compatibility fixes fo…
Browse files Browse the repository at this point in the history
…r recent Dynare versions
  • Loading branch information
JohannesPfeifer committed Apr 29, 2024
1 parent 0031309 commit 01907c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Born_Pfeifer_2014/Born_Pfeifer_RM_Comment.mod
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ burnin=4000; //periods for convergence
shocks_mat_with_zeros=zeros(burnin,M_.exo_nbr); //shocks set to 0 to simulate without uncertainty
%% Note that simult_FGRU.m uses the original non-standard pruning scheme
out_noshock = simult_FGRU(oo_.dr.ys,oo_.dr,shocks_mat_with_zeros,options_.order,zeros(size(oo_.dr.ys)),zeros(M_.exo_nbr,1)); //simulate series
%% To simulate serires with proper pruning scheme as in Andreasen et al. (2013), use the following code
% out_noshock = simult_(oo_.dr.ys,oo_.dr,shocks_mat_with_zeros,options_.order); //simulate series
%% To simulate series with proper pruning scheme as in Andreasen et al. (2013), use the following code
%out_noshock = simult_(M_,options_,oo_.dr.ys,oo_.dr,shocks_mat_with_zeros,options_.order); //simulate series
log_deviations_SS_noshock=out_noshock-oo_.dr.ys*ones(1,burnin+M_.maximum_lag); //subtract steady state to get deviations from steady state
ergodicmean_no_shocks=out_noshock(:,end); //EMAS is the final point
Expand Down Expand Up @@ -539,7 +539,7 @@ eval(['print -depsc2 Current_Account',country_string,end_save_string])
//options_.qz_criterium = 1+1e-6; //required because it is empty by default, leading to a crash in k_order_pert
[shock_mat]=generate_FGRU_shocks(estimation_replications,winsorizing_dummy);
[fhat,xhat] = csminwel(@smm_diff_function,x_start,H0,[],crit,nit,target,estimation_replications,shock_mat(:,:,1:estimation_replications));
[fhat,xhat] = csminwel(@smm_diff_function,x_start,H0,[],crit,nit,target,estimation_replications,shock_mat(:,:,1:estimation_replications),M_,oo_,options_);
@# endif
Expand Down
15 changes: 10 additions & 5 deletions Born_Pfeifer_2014/smm_diff_function.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function [fval, simulated_moments]=smm_diff_function(xopt,target,replications,shocks)
% function [fval, simulated_moments]=smm_diff_function(xopt,target,replications,shocks)
function [fval, simulated_moments]=smm_diff_function(xopt,target,replications,shocks,M_,oo_,options_)
% function [fval, simulated_moments]=smm_diff_function(xopt,target,replications,shocks,M_,oo_,options_)
% Computes the quadratic deviation of the simulated moments from the target
% moments in the data
% Inputs:
Expand Down Expand Up @@ -30,7 +30,6 @@
%
% For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.

global oo_ M_ options_ % get Dynare structures; used to pass them on to resol.m
tic

%% simulate data from monthly model
Expand All @@ -48,8 +47,14 @@
toc
return
end

[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_); %run model solution in Dynare
dyn_ver = dynare_version;
if str2double(dyn_ver(1))< 5
[oo_.dr, info, M_, options_, oo_] = resol(0, M_, options_, oo_); %get decision rules
elseif str2double(dyn_ver(1))< 6
[oo_.dr,info,M_,oo_] = resol(0,M_,options_,oo_); %get decision rules
else
[oo_.dr,info] = resol(0,M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_steady_state); %get decision rules
end

if info %solution was not successful
fval=10e6+sum([xopt(1),xopt(2),xopt(3),log(xopt(4)) ].^2); %return with penalty
Expand Down

0 comments on commit 01907c4

Please sign in to comment.