From 21d58eac91c0e56e9946426ae7ea8cdc795bc6c6 Mon Sep 17 00:00:00 2001 From: stepan Date: Thu, 22 Oct 2009 15:56:32 +0000 Subject: [PATCH] * Bug fix. * Changed the conditional forecast section in the manual. * Removed the calibration token from the preprocessor. git-svn-id: https://www.dynare.org/svn/dynare/trunk@3067 ac1d8469-bf42-47a9-8791-bf33cf982152 --- doc/manual.xml | 27 ++++++++++++++++----------- matlab/imcforecast.m | 8 ++++---- matlab/plot_icforecast.m | 28 ++++++++++++++++------------ preprocessor/DynareBison.yy | 4 +--- preprocessor/DynareFlex.ll | 1 - 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/doc/manual.xml b/doc/manual.xml index 2b804db42..e0d434341 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -2860,10 +2860,10 @@ forecast; conditional_forecast - + conditional_forecast - computes a simulation of a stochastic model conditionally to a specified future path for some endogenous + computes a simulation of a stochastic model conditionally to a specified future path for some endogenous variables. @@ -2878,30 +2878,34 @@ forecast; Options - = | | | | | - Specify the parameter set to use for the forecasting. Use if you calibrated your model instead of estimating it. No default value, mandatory option + = | | | + | + Specify the parameter set to use for the forecasting. No default value, mandatory option. = (VARIABLE_NAME [ [,] VARIABLE_NAME ... ] ) - Specify the exogenous variables to use as control variables. No default value, mandatory option + Specify the exogenous variables to use as control variables. No default value, mandatory option. = INTEGER - Number of periods of the forecast. Default: as many as the length of the constrained path + Number of periods of the forecast. Default: 40. + cannot be less than the number of constrained periods. = INTEGER - Number of simulations. Default: ???? + Number of simulations. Default: 5000. = DOUBLE - Level of significance for confidence interval. Default: 0.90 + Level of significance for confidence interval. Default: 0.80 Description -conditional_forecast computes forecasts on a calibrated or estimated model for a given constrained path of some future endogenous variables. This is done, from the reduced form representation of the DSGE model, by finding the structural shocks that are needed to match the restricted paths. +conditional_forecast computes forecasts on an estimated model for a given constrained path of some +future endogenous variables. This is done, from the reduced form representation of the DSGE model, by finding the structural shocks that +are needed to match the restricted paths. This command has to be called after estimation. Use to give the list of constrained endogenous, and their constrained future path. Option is used to specify the structural shocks which will be matched to generate the constrained path. @@ -2917,7 +2921,7 @@ varexo e u; ... -stoch_simul(irf=0); +estimation(...); conditional_forecast_paths; var y; @@ -2984,7 +2988,8 @@ plot_conditional_forecast(periods = 10) e u; = INTEGER - Number of periods to be plotted. Default: as many as the length of the forecast + Number of periods to be plotted. Default: equal to in conditional_forecast. The number of periods + declared in plot_conditional_forecast cannot be greater than the one declared in conditional_forecast. diff --git a/matlab/imcforecast.m b/matlab/imcforecast.m index fba682a51..99e9f0131 100644 --- a/matlab/imcforecast.m +++ b/matlab/imcforecast.m @@ -77,15 +77,15 @@ else end end -if isfield(options_cond_fcst,'replic') || isempty(options_cond_fcst.replic) +if ~isfield(options_cond_fcst,'replic') || isempty(options_cond_fcst.replic) options_cond_fcst.replic = 5000; end -if isfield(options_cond_fcst,'periods') || isempty(options_cond_fcst.periods) - options_cond_fcst.replic = 40; +if ~isfield(options_cond_fcst,'periods') || isempty(options_cond_fcst.periods) + options_cond_fcst.periods = 40; end -if isfield(options_cond_fcst,'conf_sig') || isempty(options_cond_fcst.conf_sig) +if ~isfield(options_cond_fcst,'conf_sig') || isempty(options_cond_fcst.conf_sig) options_cond_fcst.conf_sig = .8; end diff --git a/matlab/plot_icforecast.m b/matlab/plot_icforecast.m index 6dd76e4f4..88a1145b9 100644 --- a/matlab/plot_icforecast.m +++ b/matlab/plot_icforecast.m @@ -1,4 +1,4 @@ -function plot_icforecast(Variables) +function plot_icforecast(Variables,periods) % Build plots for the conditional forecasts. % % INPUTS @@ -29,27 +29,31 @@ function plot_icforecast(Variables) load conditional_forecasts; +if nargin==1% Set default number of periods. + eval(['periods = length(forecasts.cond.mean.' Variables(1,:) ');']); +end + for i=1:size(Variables,1) eval(['ci1 = forecasts.cond.ci.' Variables(i,:) ';']) eval(['m1 = forecasts.cond.mean.' Variables(i,:) ';']) eval(['ci2 = forecasts.uncond.ci.' Variables(i,:) ';']) eval(['m2 = forecasts.uncond.mean.' Variables(i,:) ';']) - build_figure(Variables(i,:),ci1,ci2,m1,m2); + build_figure(Variables(i,:),ci1(:,1:periods),ci2(:,1:periods),m1(1:periods),m2(1:periods)); end -function build_figure(name,ci1,ci2,m1,m2) +function build_figure(name,cci1,cci2,mm1,mm2) figure('Name',['Conditional forecast: ' name '.']); - H = length(m1); - h1 = area(1:H,ci1(2,1:H)); - set(h1,'BaseValue',min([min(ci1(1,:)),min(ci2(1,:))])) + H = length(mm1); + h1 = area(1:H,cci1(2,1:H)); + set(h1,'BaseValue',min([min(cci1(1,:)),min(cci2(1,:))])) set(h1,'FaceColor',[.9 .9 .9]) hold on - h2 = area(1:H,ci1(1,1:H)); - set(h2,'BaseValue',min([min(ci1(1,:)),min(ci2(1,:))])) + h2 = area(1:H,cci1(1,1:H)); + set(h2,'BaseValue',min([min(cci1(1,:)),min(cci2(1,:))])) set(h2,'FaceColor',[1 1 1]) - plot(1:H,m1,'-k','linewidth',3) - plot(1:H,m2,'--k','linewidth',3) - plot(1:H,ci2(1,:),'--k','linewidth',1) - plot(1:H,ci2(2,:),'--k','linewidth',1) + plot(1:H,mm1,'-k','linewidth',3) + plot(1:H,mm2,'--k','linewidth',3) + plot(1:H,cci2(1,:),'--k','linewidth',1) + plot(1:H,cci2(2,:),'--k','linewidth',1) axis tight hold off \ No newline at end of file diff --git a/preprocessor/DynareBison.yy b/preprocessor/DynareBison.yy index 34edf6ead..026124fa5 100644 --- a/preprocessor/DynareBison.yy +++ b/preprocessor/DynareBison.yy @@ -92,7 +92,7 @@ class ParsingDriver; %token BVAR_PRIOR_DECAY BVAR_PRIOR_FLAT BVAR_PRIOR_LAMBDA %token BVAR_PRIOR_MU BVAR_PRIOR_OMEGA BVAR_PRIOR_TAU BVAR_PRIOR_TRAIN %token BVAR_REPLIC BYTECODE -%token CALIB CALIB_VAR CALIBRATION CHANGE_TYPE CHECK CONDITIONAL_FORECAST CONDITIONAL_FORECAST_PATHS CONF_SIG CONSTANT CONTROLLED_VAREXO CORR COVAR CUTOFF +%token CALIB CALIB_VAR CHANGE_TYPE CHECK CONDITIONAL_FORECAST CONDITIONAL_FORECAST_PATHS CONF_SIG CONSTANT CONTROLLED_VAREXO CORR COVAR CUTOFF %token DATAFILE DR_ALGO DROP DSAMPLE DYNASAVE DYNATYPE %token END ENDVAL EQUAL ESTIMATION ESTIMATED_PARAMS ESTIMATED_PARAMS_BOUNDS ESTIMATED_PARAMS_INIT %token FILENAME FILTER_STEP_AHEAD FILTERED_VARS FIRST_OBS @@ -1693,8 +1693,6 @@ o_parameter_set : PARAMETER_SET EQUAL PRIOR_MODE { driver.option_str("parameter_set", "posterior_mode"); } | PARAMETER_SET EQUAL POSTERIOR_MEDIAN { driver.option_str("parameter_set", "posterior_median"); } - | PARAMETER_SET EQUAL CALIBRATION - { driver.option_str("parameter_set", "calibration"); } ; o_parameters : PARAMETERS EQUAL symbol {driver.option_str("parameters",$3);}; diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll index ccd473766..c871c7987 100644 --- a/preprocessor/DynareFlex.ll +++ b/preprocessor/DynareFlex.ll @@ -336,7 +336,6 @@ int sigma_e = 0; posterior_mode {return token::POSTERIOR_MODE; } posterior_mean {return token::POSTERIOR_MEAN; } posterior_median {return token::POSTERIOR_MEDIAN; } -calibration {return token::CALIBRATION; } [\$][^$]*[\$] {