Commit 21d58eac authored by stepan's avatar stepan
Browse files

* 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
parent e9ca5705
......@@ -2860,10 +2860,10 @@ forecast;
<refmeta>
<refentrytitle>conditional_forecast</refentrytitle>
</refmeta>
<refnamediv>
<refname>conditional_forecast</refname>
<refpurpose>computes a simulation of a stochastic model conditionally to a specified future path for some endogenous</refpurpose>
<refpurpose>computes a simulation of a stochastic model conditionally to a specified future path for some endogenous variables.</refpurpose>
</refnamediv>
<refsynopsisdiv>
......@@ -2878,30 +2878,34 @@ forecast;
<refsect1><title>Options</title>
<variablelist>
<varlistentry>
<term><option>parameter_set</option> = <option>calibration</option> | <option>prior_mode</option> | <option>prior_mean</option> | <option>posterior_mode</option> | <option>posterior_mean</option> | <option>posterior_median</option></term>
<listitem><para>Specify the parameter set to use for the forecasting. Use <option>calibration</option> if you calibrated your model instead of estimating it. No default value, mandatory option</para></listitem>
<term><option>parameter_set</option> = <option>prior_mode</option> | <option>prior_mean</option> | <option>posterior_mode</option> |
<option>posterior_mean</option> | <option>posterior_median</option></term>
<listitem><para>Specify the parameter set to use for the forecasting. No default value, mandatory option.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>controlled_varexo</option> = (<replaceable>VARIABLE_NAME</replaceable> [ [,] <replaceable>VARIABLE_NAME</replaceable> ... ] )</term>
<listitem><para>Specify the exogenous variables to use as control variables. No default value, mandatory option</para></listitem>
<listitem><para>Specify the exogenous variables to use as control variables. No default value, mandatory option.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>periods</option> = <replaceable>INTEGER</replaceable></term>
<listitem><para>Number of periods of the forecast. Default: as many as the length of the constrained path</para></listitem>
<listitem><para>Number of periods of the forecast. Default: <literal>40</literal>.
<option>periods</option> cannot be less than the number of constrained periods. </para></listitem>
</varlistentry>
<varlistentry>
<term><option>replic</option> = <replaceable>INTEGER</replaceable></term>
<listitem><para>Number of simulations. Default: ????</para></listitem>
<listitem><para>Number of simulations. Default: <literal>5000</literal>.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>conf_sig</option> = <replaceable>DOUBLE</replaceable></term>
<listitem><para>Level of significance for confidence interval. Default: <literal>0.90</literal></para></listitem>
<listitem><para>Level of significance for confidence interval. Default: <literal>0.80</literal></para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1><title>Description</title>
<para><command>conditional_forecast</command> 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.</para>
<para><command>conditional_forecast</command> 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.</para>
<para>Use <xref linkend="conditional_forecast_paths" /> to give the list of constrained endogenous, and their constrained future path. Option <option>controlled_varexo</option> is used to specify the structural shocks which will be matched to generate the constrained path.</para>
......@@ -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;
<variablelist>
<varlistentry>
<term><option>periods</option> = <replaceable>INTEGER</replaceable></term>
<listitem><para>Number of periods to be plotted. Default: as many as the length of the forecast</para></listitem>
<listitem><para>Number of periods to be plotted. Default: equal to <option>periods</option> in <command>conditional_forecast</command>. The number of periods
declared in <command>plot_conditional_forecast</command> cannot be greater than the one declared in <command>conditional_forecast</command>.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
......
......@@ -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
......
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
......@@ -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);};
......
......@@ -336,7 +336,6 @@ int sigma_e = 0;
<DYNARE_STATEMENT>posterior_mode {return token::POSTERIOR_MODE; }
<DYNARE_STATEMENT>posterior_mean {return token::POSTERIOR_MEAN; }
<DYNARE_STATEMENT>posterior_median {return token::POSTERIOR_MEDIAN; }
<DYNARE_STATEMENT>calibration {return token::CALIBRATION; }
<DYNARE_STATEMENT>[\$][^$]*[\$] {
......
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