From 28d4ed19180aea81fc0ba422a602d9d803424f20 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Tue, 20 Dec 2016 13:57:27 +0100 Subject: [PATCH 1/5] Finish implementation and documentation of nograph option of shock_decomposition.m --- doc/dynare.texi | 5 +++++ matlab/global_initialization.m | 4 +--- matlab/shock_decomposition.m | 4 +++- preprocessor/DynareBison.yy | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index f47cd38eb..ce6ea6172 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -7030,6 +7030,11 @@ the decomposition. Groups of shocks are defined in @xref{shock_groups} block. @item colormap = @var{COLORMAP_NAME} @anchor{colormap}. Controls the colormap used for the shocks decomposition graphs. See @code{colormap} in Matlab/Octave manual. + +@item nograph +@xref{nograph}. Suppresses the display and creation only within the @code{shock_decomposition}-command +but does not affect other commands. + @end table @vindex oo_.shock_decomposition diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index 2f8eec361..d409232a6 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -134,6 +134,7 @@ options_.graphics.line_width = 1; options_.graph_format = 'eps'; options_.nodisplay = 0; options_.nograph = 0; +options_.no_graph.shock_decomposition = 0; options_.XTick = []; options_.XTickLabel = []; options_.console_mode = 0; @@ -790,9 +791,6 @@ options_.mcppath.mu0 = []; %Figure options options_.figures.textwidth=0.8; -% Shock decomposition options -options_.shock_decomp.nograph = 0; - % initialize persistent variables in priordens() priordens([],[],[],[],[],[],1); % initialize persistent variables in dyn_first_order_solver() diff --git a/matlab/shock_decomposition.m b/matlab/shock_decomposition.m index aa61c9b88..f3c264edc 100644 --- a/matlab/shock_decomposition.m +++ b/matlab/shock_decomposition.m @@ -139,4 +139,6 @@ else shock_names = M_.exo_names; end -graph_decomp(z,shock_names,M_.endo_names,i_var,options_.initial_date,M_,options_) +if ~options_.no_graph.shock_decomposition + graph_decomp(z,shock_names,M_.endo_names,i_var,options_.initial_date,M_,options_) +end \ No newline at end of file diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index b11895514..03e4b8446 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -2816,7 +2816,7 @@ o_nograph : NOGRAPH | GRAPH { driver.option_num("nograph", "0"); } ; -o_shock_decomposition_nograph : NOGRAPH { driver.option_num("shock_decomp.nograph", "1"); } +o_shock_decomposition_nograph : NOGRAPH { driver.option_num("no_graph.shock_decomposition", "1"); } o_nodisplay : NODISPLAY { driver.option_num("nodisplay","1"); }; o_graph_format : GRAPH_FORMAT EQUAL allowed_graph_formats { driver.process_graph_format_option(); } From 452d3cd98609a68d97017d5dc8ed6d498a221b77 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Mon, 26 Dec 2016 13:07:46 +0100 Subject: [PATCH 2/5] Implement preprocessor interface for posterior_nograph option --- doc/dynare.texi | 9 +++++++++ matlab/global_initialization.m | 1 + preprocessor/DynareBison.yy | 8 +++++++- preprocessor/DynareFlex.ll | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/dynare.texi b/doc/dynare.texi index ce6ea6172..4eab4ff7f 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -5186,6 +5186,15 @@ Default value is @code{1}. @item nograph @xref{nograph}. +@item posterior_nograph +@anchor{posterior_nograph} +Suppresses the generation of graphs associated with Bayesian IRFs (@ref{bayesian_irf}), +posterior smoothed objects (@ref{smoother}), and posterior forecasts (@ref{forecast}). + +@item posterior_graph +@anchor{posterior_graph} +Re-enables the generation of graphs previously shut off with @ref{posterior_nograph}. + @item nodisplay @xref{nodisplay}. diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m index d409232a6..e65ca4a62 100644 --- a/matlab/global_initialization.m +++ b/matlab/global_initialization.m @@ -134,6 +134,7 @@ options_.graphics.line_width = 1; options_.graph_format = 'eps'; options_.nodisplay = 0; options_.nograph = 0; +options_.no_graph.posterior = 0; options_.no_graph.shock_decomposition = 0; options_.XTick = []; options_.XTickLabel = []; diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 03e4b8446..d84d77907 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -114,7 +114,7 @@ class ParsingDriver; %token FILTER_ALGORITHM PROPOSAL_APPROXIMATION CUBATURE UNSCENTED MONTECARLO DISTRIBUTION_APPROXIMATION %token NAME %token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS NO_HOMOTOPY -%token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS +%token NOGRAPH POSTERIOR_NOGRAPH POSTERIOR_GRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS %token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS OVERWRITE %token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERIODS PERIOD PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE %token PERFECT_FORESIGHT_SETUP PERFECT_FORESIGHT_SOLVER NO_POSTERIOR_KERNEL_DENSITY FUNCTION @@ -1726,6 +1726,7 @@ estimation_options : o_datafile | o_lik_algo | o_lik_init | o_nograph + | o_posterior_nograph | o_nodisplay | o_graph_format | o_forecasts_conf_sig @@ -2816,6 +2817,11 @@ o_nograph : NOGRAPH | GRAPH { driver.option_num("nograph", "0"); } ; +o_posterior_nograph : POSTERIOR_NOGRAPH + { driver.option_num("no_graph.posterior","1"); } + | POSTERIOR_GRAPH + { driver.option_num("no_graph.posterior", "0"); } + ; o_shock_decomposition_nograph : NOGRAPH { driver.option_num("no_graph.shock_decomposition", "1"); } o_nodisplay : NODISPLAY { driver.option_num("nodisplay","1"); }; o_graph_format : GRAPH_FORMAT EQUAL allowed_graph_formats diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll index e461cb825..8d00b2874 100644 --- a/preprocessor/DynareFlex.ll +++ b/preprocessor/DynareFlex.ll @@ -276,6 +276,8 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2 raftery_lewis_diagnostics {return token::RAFTERY_LEWIS_DIAGNOSTICS;} graph {return token::GRAPH;} nograph {return token::NOGRAPH;} +posterior_graph {return token::POSTERIOR_GRAPH;} +posterior_nograph {return token::POSTERIOR_NOGRAPH;} nodisplay {return token::NODISPLAY;} graph_format {return token::GRAPH_FORMAT;} eps {yylval->string_val = new string(yytext); return token::EPS;} From 91abae9ce016f15db48f1ad7234af49a6aa7ac4c Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Mon, 26 Dec 2016 13:10:45 +0100 Subject: [PATCH 3/5] Document graph option --- doc/dynare.texi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/dynare.texi b/doc/dynare.texi index 4eab4ff7f..abcaa1cca 100644 --- a/doc/dynare.texi +++ b/doc/dynare.texi @@ -4034,6 +4034,10 @@ will be saved to disk (to the format specified by @code{graph_format} option, except if @code{graph_format=none}) and displayed to screen (unless @code{nodisplay} option is used). +@item graph +@anchor{graph} +Re-enables the generation of graphs previously shut off with @ref{nograph}. + @item nodisplay @anchor{nodisplay} Do not display the graphs, but still save them to disk (unless @code{nograph} is used). From d8b0495c77e6a96cbc32068dab996589e01fe5ca Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 21 Dec 2016 08:59:57 +0100 Subject: [PATCH 4/5] Make PosteriorIRF.m and pm3.m honor nograph and posterior_nograph option --- matlab/PosteriorIRF.m | 3 ++- matlab/pm3.m | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/matlab/PosteriorIRF.m b/matlab/PosteriorIRF.m index 9a89b4c0c..8b086c5b9 100644 --- a/matlab/PosteriorIRF.m +++ b/matlab/PosteriorIRF.m @@ -362,7 +362,7 @@ end % .tex generation always run in sequentially. This portion of code is execute in parallel by % PosteriorIRF_core2.m function. - +if ~options_.nograph && ~options_.no_graph.posterior % Save the local variables. localVars=[]; @@ -459,5 +459,6 @@ else end % END parallel code! +end fprintf('Estimation::mcmc: Posterior IRFs, done!\n'); diff --git a/matlab/pm3.m b/matlab/pm3.m index 21a486162..ae0f474d1 100644 --- a/matlab/pm3.m +++ b/matlab/pm3.m @@ -292,6 +292,7 @@ end %% Finally I build the plots. %% +if ~options_.nograph && ~options_.no_graph.posterior % Block of code executed in parallel, with the exception of file % .tex generation always run sequentially. This portion of code is execute in parallel by % pm3_core1.m function. @@ -394,5 +395,6 @@ if options_.TeX && any(strcmp('eps',cellstr(options_.graph_format))) fprintf(fidTeX,'%% End of TeX file.\n'); fclose(fidTeX); end +end -fprintf(['Estimation::mcmc: ' tit1 ', done!\n']); \ No newline at end of file +fprintf(['Estimation::mcmc: ' tit1 ', done!\n']); From 8900b99a742d301f0ddfa17f2835496d8743ca3e Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Wed, 21 Dec 2016 09:27:50 +0100 Subject: [PATCH 5/5] Add posterior_nograph option to fs2000.mod unit test --- tests/estimation/fs2000.mod | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/estimation/fs2000.mod b/tests/estimation/fs2000.mod index a70b76463..ddbe3fbbf 100644 --- a/tests/estimation/fs2000.mod +++ b/tests/estimation/fs2000.mod @@ -86,7 +86,8 @@ estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=3000,mh_nbl geweke_interval = [0.19 0.49], taper_steps = [4 7 15], raftery_lewis_diagnostics, - raftery_lewis_qrs=[0.025 0.01 0.95] + raftery_lewis_qrs=[0.025 0.01 0.95], + bayesian_irf,posterior_nograph ) y m; if ~isequal(options_.convergence.geweke.taper_steps,[4 7 15]') || ~isequal(options_.convergence.geweke.geweke_interval,[0.19 0.49]) @@ -98,6 +99,7 @@ if ~isequal(options_.convergence.rafterylewis.qrs,[0.025 0.01 0.95]) || ~isequal end %test load_mh_file option +options_.bayesian_irf=0; options_.smoother=0; options_.moments_varendo=0; options_.forecast=0;