Commit ffd9b2d4 authored by sebastien's avatar sebastien
Browse files

preprocessor: clean-up workaround for acosh(), asinh(), atanh() on Win 64 platforms


git-svn-id: https://www.dynare.org/svn/dynare/trunk@3101 ac1d8469-bf42-47a9-8791-bf33cf982152
parent ee74f38b
...@@ -867,12 +867,13 @@ end; ...@@ -867,12 +867,13 @@ end;
<para>For most simulation exercises, it is necessary to provide initial (and possibly terminal) conditions. It is also necessary to provide initial guess values for non-linear solvers. The following statements are used for those purposes:</para> <para>For most simulation exercises, it is necessary to provide initial (and possibly terminal) conditions. It is also necessary to provide initial guess values for non-linear solvers. The following statements are used for those purposes:</para>
<itemizedlist> <itemizedlist>
<listitem><para><xref linkend='initval'/></para></listitem> <listitem><para><xref linkend='initval'/></para></listitem>
<listitem><para><xref linkend='initval_file'/></para></listitem>
<listitem><para><xref linkend='endval'/></para></listitem> <listitem><para><xref linkend='endval'/></para></listitem>
<listitem><para><xref linkend='histval'/></para></listitem> <listitem><para><xref linkend='histval'/></para></listitem>
<listitem><para><xref linkend='resid'/></para></listitem>
<listitem><para><xref linkend='initval_file'/></para></listitem>
</itemizedlist> </itemizedlist>
<para>In many contexts (determistic or stochastic), it is necessary to compute the steady state of a non-linear model: <xref linkend='initval'/> then specifies numerical initial values for the non-linear solver. <para>In many contexts (determistic or stochastic), it is necessary to compute the steady state of a non-linear model: <xref linkend='initval'/> then specifies numerical initial values for the non-linear solver. The command <xref linkend='resid'/> can be used to compute the equation residuals for the given initial values.
</para> </para>
<para> <para>
Used in perfect foresight mode, the types of forward-loking models for which Dynare was designed require both initial and terminal conditions. Most often these initial and terminal conditions are static equilibria, but not necessarily. Used in perfect foresight mode, the types of forward-loking models for which Dynare was designed require both initial and terminal conditions. Most often these initial and terminal conditions are static equilibria, but not necessarily.
...@@ -954,28 +955,6 @@ steady; ...@@ -954,28 +955,6 @@ steady;
</refsect1> </refsect1>
</refentry> </refentry>
<refentry id="initval_file">
<refmeta>
<refentrytitle>initval_file</refentrytitle>
</refmeta>
<refnamediv>
<refname>initval_file</refname>
<refpurpose>use an external file for specifying initial values (for steady-state computation or for simulations)</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>initval_file</command><arg choice="plain">(<option>filename</option> = <replaceable>FILENAME</replaceable>)</arg><arg choice="plain">;</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Description</title>
<para>...</para>
</refsect1>
</refentry>
<refentry id="endval"> <refentry id="endval">
<refmeta> <refmeta>
<refentrytitle>endval</refentrytitle> <refentrytitle>endval</refentrytitle>
...@@ -1101,6 +1080,65 @@ end; ...@@ -1101,6 +1080,65 @@ end;
</refsect1> </refsect1>
</refentry> </refentry>
<refentry id="resid">
<refmeta>
<refentrytitle>resid</refentrytitle>
</refmeta>
<refnamediv>
<refname>resid</refname>
<refpurpose>display the residual of the static equations</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>resid</command><arg choice="plain">;</arg><sbr/>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Description</title>
<para>This command will display the residuals of the static equations of the model, using the values given for the endogenous in the last <xref linkend="initval"/> or <xref linkend="endval"/> block (or the steady state file if you provided one).</para>
</refsect1>
</refentry>
<refentry id="initval_file">
<refmeta>
<refentrytitle>initval_file</refentrytitle>
</refmeta>
<refnamediv>
<refname>initval_file</refname>
<refpurpose>use an external to specify a path for exogenous and endogenous variables in a deterministic simulation</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>initval_file</command><arg choice="plain">(<option>filename</option> = <replaceable>FILENAME</replaceable>)</arg><arg choice="plain">;</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1><title>Description</title>
<para>In a deterministic setup, this command is used to specify a path for all endogenous and exogenous variables. The length of these paths must be equal to the number of simulation periods, plus the number of leads and the number of lags of the model (for example, with 50 simulation periods, in a model with 2 lags and 1 lead, the paths must have a length of 53). Note that these paths cover two different things:
<itemizedlist>
<listitem><para>the constraints of the problem, which are given by the path for exogenous and the initial and terminal values for endogenous</para></listitem>
<listitem><para>the initial guess for the non-linear solver, which is given by the path for endogenous variables for the simulation periods (excluding initial and terminal conditions)</para></listitem>
</itemizedlist>
</para>
<para>The command accepts three file formats:
<itemizedlist>
<listitem><para>M-file (extension <filename class="extension">.m</filename>): for each endogenous and exogenous variable, the file must contain a row vector of the same name</para></listitem>
<listitem><para>MAT-file (extension <filename class="extension">.mat</filename>): same as for M-files</para></listitem>
<listitem><para>Excel file (extension <filename class="extension">.xls</filename>): for each endogenous and exogenous, the file must contain a column of the same name</para></listitem>
</itemizedlist>
</para>
<warning><para>The extension must be omitted in the command argument. Dynare will automatically figure out the extension and select the appropriate file type.</para></warning>
</refsect1>
</refentry>
</sect1> </sect1>
<sect1 id="sec_shocks"><title>Shocks on exogenous variables</title> <sect1 id="sec_shocks"><title>Shocks on exogenous variables</title>
...@@ -1254,44 +1292,31 @@ forecast; ...@@ -1254,44 +1292,31 @@ forecast;
<refnamediv> <refnamediv>
<refname>mshocks</refname> <refname>mshocks</refname>
<refpurpose>specifies multiplicative shocks on deterministic or stochastic exogenous variables</refpurpose> <refpurpose>specifies multiplicative deterministic shocks on exogenous variables</refpurpose>
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<cmdsynopsis> <cmdsynopsis>
<command>mshocks</command><arg choice="plain">;</arg><sbr/> <command>mshocks</command><arg choice="plain">;</arg><sbr/>
<arg rep="repeat"> <arg rep="repeat">
<group>
<arg choice="plain">
<synopfragmentref linkend="det_mshock">DETERMINISTIC SHOCK STATEMENT</synopfragmentref>
</arg>
<arg choice="plain">
<synopfragmentref linkend="sto_mshock">STOCHASTIC SHOCK STATEMENT</synopfragmentref>
</arg>
</group>
</arg><sbr/>
<command>end</command><arg choice="plain">;</arg>
<synopfragment id="det_mshock">
<arg choice="plain">var <replaceable>VARIABLE_NAME</replaceable>;</arg> <arg choice="plain">var <replaceable>VARIABLE_NAME</replaceable>;</arg>
<arg choice="plain">periods <replaceable>INTEGER</replaceable><arg>:<replaceable>INTEGER</replaceable></arg> <arg choice="plain">periods <replaceable>INTEGER</replaceable><arg>:<replaceable>INTEGER</replaceable></arg>
<arg rep="repeat"><arg>,</arg> <replaceable>INTEGER</replaceable><arg>:<replaceable>INTEGER</replaceable></arg></arg>;</arg> <arg rep="repeat"><arg>,</arg> <replaceable>INTEGER</replaceable><arg>:<replaceable>INTEGER</replaceable></arg></arg>;</arg>
<arg choice="plain">values <replaceable>EXPRESSION</replaceable> <arg rep="repeat"><arg>,</arg> <replaceable>EXPRESSION</replaceable></arg>;</arg> <arg choice="plain">values <replaceable>EXPRESSION</replaceable> <arg rep="repeat"><arg>,</arg> <replaceable>EXPRESSION</replaceable></arg>;</arg>
</synopfragment> </arg><sbr/>
<command>end</command><arg choice="plain">;</arg>
<synopfragment id="sto_mshock">
<group choice="plain">
<arg choice="plain">var <replaceable>VARIABLE_NAME</replaceable>; stderr <replaceable>EXPRESSION</replaceable>;</arg>
<arg choice="plain">var <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;</arg>
<arg choice="plain">var <replaceable>VARIABLE_NAME</replaceable>, <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;</arg>
<arg choice="plain">corr <replaceable>VARIABLE_NAME</replaceable>, <replaceable>VARIABLE_NAME</replaceable> = <replaceable>EXPRESSION</replaceable>;</arg>
</group>
</synopfragment>
</cmdsynopsis> </cmdsynopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1><title>Description</title> <refsect1><title>Description</title>
<para>...</para> <para>The purpose of this command is similar to that of the <xref linkend="shocks"/> for deterministic shocks, except that the numeric values given will be interpreted in a multiplicative way. For example, if a value of <literal>1.05</literal> is given as shock value for some exogenous at some date, it means 5% above its steady state value (as given by the last <xref linkend="initval"/> or <xref linkend="endval"/> block).</para>
<para>This command is only meaningful in two situations:
<itemizedlist>
<listitem><para>on exogenous variables with a non-zero steady state, in a deterministic setup,</para></listitem>
<listitem><para>on deterministic exogenous variables with a non-zero steady state, in a stochastic setup.</para></listitem>
</itemizedlist>
</para>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1453,11 +1478,17 @@ Dynare has special commands for the computation of the static equilibrium of the ...@@ -1453,11 +1478,17 @@ Dynare has special commands for the computation of the static equilibrium of the
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>homotopy_mode</option> = <replaceable>INTEGER</replaceable></term> <term><option>homotopy_mode</option> = <replaceable>INTEGER</replaceable></term>
<listitem><para>...</para></listitem> <listitem><para>Use a homotopy (or divide-and-conquer) technique to solve for the steady state (see <xref linkend="homotopy_setup"/> for a short description of the technique). This option can take three possible values:
<itemizedlist>
<listitem><para><literal>1</literal>: in this mode, all the parameters are changed simultaneously, and the distance between the boudaries for each parameter is divided in as many intervals as there are steps (as defined by <option>homotopy_steps</option> option); the problem is solves as many times as there are steps</para></listitem>
<listitem><para><literal>2</literal>: same as mode <literal>1</literal>, except that only one parameter is changed at a time; the problem is solved as many times as steps times number of parameters</para></listitem>
<listitem><para><literal>3</literal>: Dynare tries first the most extreme values. If it fails to compute the steady state, the interval between initial and desired values is divided by two for all parameters. Every time that it is impossible to find a steady state, the previous interval is divided by two. When it succeeds to find a steady state, the previous interval is multiplied by two. In that last case <option>homotopy_steps</option> contains the maximum number of computations attempted before giving up.</para></listitem>
</itemizedlist>
</para></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>homotopy_steps</option> = <replaceable>INTEGER</replaceable></term> <term><option>homotopy_steps</option> = <replaceable>INTEGER</replaceable></term>
<listitem><para>...</para></listitem> <listitem><para>Defines the number of steps when performing a homotopy. See <option>homotopy_mode</option> option for more details.</para></listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</refsect1> </refsect1>
...@@ -1499,7 +1530,7 @@ See <xref linkend='initval'/> and <xref linkend='endval'/>. ...@@ -1499,7 +1530,7 @@ See <xref linkend='initval'/> and <xref linkend='endval'/>.
<refnamediv> <refnamediv>
<refname>homotopy_setup</refname> <refname>homotopy_setup</refname>
<refpurpose>instructs <xref linkend="steady"/> to use homotopy methods</refpurpose> <refpurpose>declare initial and final values when using homotopy method</refpurpose>
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
...@@ -1511,8 +1542,49 @@ See <xref linkend='initval'/> and <xref linkend='endval'/>. ...@@ -1511,8 +1542,49 @@ See <xref linkend='initval'/> and <xref linkend='endval'/>.
</refsynopsisdiv> </refsynopsisdiv>
<refsect1><title>Description</title> <refsect1><title>Description</title>
<para>...</para> <para>The idea of homotopy (also called divide-and-conquer by some authors) is to subdivide the problem of finding the steady state into smaller problems. It assumes that you know how to compute the steady state for a given set of parameters, and it helps you finding the steady state for another set of parameters, by incrementally moving from one to another set of parameters.</para>
<para>The purpose of the <command>homotopy_setup</command> block is to declare the final (and possibly also the initial) values for the parameters or exogenous that will be changed during the homotopy. In the first syntax where only one value is specified for a given parameter/exogenous, then this value is interpreted as the final value, and the initial value is taken from the preceeding <xref linkend="initval"/> block. In the second syntax where two values are specified for a given parameter/exogenous, the first is the initial one, the second is the final one.</para>
<para>A necessary condition for a successful homotopy is that Dynare must be able to solve the steady state for the initial parameters/exogenous without additional help (using the guess values given in the <xref linkend="initval"/> block).</para>
<para> If the homotopy fails, a possible solution is to increase the number of steps (given in <option>homotopy_steps</option> option of <xref linkend="steady"/>).</para>
</refsect1>
<refsect1><title>Example</title>
<informalexample>
<para>In the following example, Dynare will first compute the steady state for the initial values (<literal>gam=0.5</literal> and <literal>x=1</literal>), and then subdivide the problem into 50 smaller problems to find the steady state for the final values (<literal>gam=2</literal> and <literal>x=2</literal>).</para>
<programlisting>
var c k;
varexo x;
parameters alph gam delt bet aa;
alph=0.5;
delt=0.02;
aa=0.5;
bet=0.05;
model;
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
end;
initval;
x = 1;
k = ((delt+bet)/(aa*x*alph))^(1/(alph-1));
c = aa*x*k^alph-delt*k;
end;
homotopy_setup;
gam, 0.5, 2;
x, 2;
end;
steady(homotopy_mode = 1, homotopy_steps = 50);
</programlisting>
</informalexample>
</refsect1> </refsect1>
</refentry> </refentry>
<refentry id="check"> <refentry id="check">
......
...@@ -32,14 +32,14 @@ function ys1 = add_auxiliary_variables_to_steadystate(ys,aux_vars,fname, ... ...@@ -32,14 +32,14 @@ function ys1 = add_auxiliary_variables_to_steadystate(ys,aux_vars,fname, ...
k = k+1; k = k+1;
end end
for i=1:aux_lead_nbr + 1; for i=1:aux_lead_nbr+1;
res = feval([fname '_static'],ys1,... res = feval([fname '_static'],ys1,...
[exo_steady_state; ... [exo_steady_state; ...
exo_det_steady_state],params); exo_det_steady_state],params);
for j=1:n for j=1:n
if aux_vars(j).type == 0 if aux_vars(j).type == 0
el = aux_vars(j).endo_index; el = aux_vars(j).endo_index;
ys1(el) == res(el); ys1(el) = ys1(el)-res(el);
end end
end end
end end
...@@ -55,7 +55,7 @@ function oo_ = compute_moments_varendo(type,options_,M_,oo_,var_list_) ...@@ -55,7 +55,7 @@ function oo_ = compute_moments_varendo(type,options_,M_,oo_,var_list_)
NumberOfExogenousVariables = M_.exo_nbr; NumberOfExogenousVariables = M_.exo_nbr;
list_of_exogenous_variables = M_.exo_names; list_of_exogenous_variables = M_.exo_names;
NumberOfLags = options_.ar; NumberOfLags = options_.ar;
Steps = options_.conditional_variance_decomposition_dates; Steps = options_.conditional_variance_decomposition;
% COVARIANCE MATRIX. % COVARIANCE MATRIX.
if posterior if posterior
......
function PackedConditionalVarianceDecomposition = conditional_variance_decomposition(StateSpaceModel, Steps, SubsetOfVariables) function PackedConditionalVarianceDecomposition = conditional_variance_decomposition(StateSpaceModel, Steps, SubsetOfVariables,sigma_e_is_diagonal)
% This function computes the conditional variance decomposition of a given state space model % This function computes the conditional variance decomposition of a given state space model
% for a subset of endogenous variables. % for a subset of endogenous variables.
% %
...@@ -13,8 +13,7 @@ function PackedConditionalVarianceDecomposition = conditional_variance_decomposi ...@@ -13,8 +13,7 @@ function PackedConditionalVarianceDecomposition = conditional_variance_decomposi
% %
% SPECIAL REQUIREMENTS % SPECIAL REQUIREMENTS
% %
% [1] The covariance matrix of the state innovations needs to be diagonal. % [1] In this version, absence of measurement errors is assumed...
% [2] In this version, absence of measurement errors is assumed...
% Copyright (C) 2009 Dynare Team % Copyright (C) 2009 Dynare Team
% %
...@@ -32,24 +31,42 @@ function PackedConditionalVarianceDecomposition = conditional_variance_decomposi ...@@ -32,24 +31,42 @@ function PackedConditionalVarianceDecomposition = conditional_variance_decomposi
% %
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
ConditionalVariance = zeros(StateSpaceModel.number_of_state_equations,StateSpaceModel.number_of_state_equations); number_of_state_innovations = ...
ConditionalVariance = repmat(ConditionalVariance,[1 1 length(Steps) StateSpaceModel.number_of_state_innovations]); StateSpaceModel.number_of_state_innovations;
BB = StateSpaceModel.impulse_matrix*transpose(StateSpaceModel.impulse_matrix); transition_matrix = StateSpaceModel.transition_matrix;
number_of_state_equations = ...
StateSpaceModel.number_of_state_equations;
nSteps = length(Steps);
for h = 1:length(Steps) ConditionalVariance = zeros(number_of_state_equations,number_of_state_equations);
for t = 0:Steps(h) ConditionalVariance = repmat(ConditionalVariance,[1 1 nSteps ...
for i=1:StateSpaceModel.number_of_state_innovations number_of_state_innovations]);
ConditionalVariance(:,:,h,i) = ...
StateSpaceModel.transition_matrix*ConditionalVariance(:,:,h,i)*transpose(StateSpaceModel.transition_matrix) ... if StateSpaceModel.sigma_e_is_diagonal
+BB*StateSpaceModel.state_innovations_covariance_matrix(i,i); B = StateSpaceModel.impulse_matrix.* ...
repmat(sqrt(diag(StateSpaceModel.state_innovations_covariance_matrix)'),...
number_of_state_equations,1);
else
B = StateSpaceModel.impulse_matrix*chol(StateSpaceModel.state_innovations_covariance_matrix)';
end
for i=1:number_of_state_innovations
BB = B(:,i)*B(:,i)';
V = zeros(number_of_state_equations,number_of_state_equations);
m = 1;
for h = 1:max(Steps)
V = transition_matrix*V*transition_matrix'+BB;
if h == Steps(m)
ConditionalVariance(:,:,m,i) = V;
m = m+1;
end end
end end
end end
ConditionalVariance = ConditionalVariance(SubsetOfVariables,SubsetOfVariables,:,:); ConditionalVariance = ConditionalVariance(SubsetOfVariables,SubsetOfVariables,:,:);
NumberOfVariables = length(SubsetOfVariables); NumberOfVariables = length(SubsetOfVariables);
PackedConditionalVarianceDecomposition = zeros(NumberOfVariables*(NumberOfVariables+1)/2,length(Steps),StateSpaceModel.number_of_state_innovations); PackedConditionalVarianceDecomposition = zeros(NumberOfVariables*(NumberOfVariables+1)/2,length(Steps),StateSpaceModel.number_of_state_innovations);
for i=1:StateSpaceModel.number_of_state_innovations for i=1:number_of_state_innovations
for h = 1:length(Steps) for h = 1:length(Steps)
PackedConditionalVarianceDecomposition(:,h,i) = vech(ConditionalVariance(:,:,h,i)); PackedConditionalVarianceDecomposition(:,h,i) = vech(ConditionalVariance(:,:,h,i));
end end
......
function d = diag_vech(Vector)
% This function returns the diagonal elements of a symmetric matrix
% stored in vech form
%
% INPUTS
% Vector [double] a m*1 vector.
%
% OUTPUTS
% d [double] a n*1 vector, where n solves n*(n+1)/2=m.
% Copyright (C) 2009 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
m = length(Vector);
n = (sqrt(1+8*m)-1)/2;
k = cumsum(1:n);
d = Vector(k);
...@@ -76,6 +76,13 @@ function disp_th_moments(dr,var_list) ...@@ -76,6 +76,13 @@ function disp_th_moments(dr,var_list)
dyntable(title,headers,deblank(M_.endo_names(ivar(stationary_vars), ... dyntable(title,headers,deblank(M_.endo_names(ivar(stationary_vars), ...
:)),100*oo_.gamma_y{options_.ar+2}(stationary_vars,:),lh,8,2); :)),100*oo_.gamma_y{options_.ar+2}(stationary_vars,:),lh,8,2);
end end
conditional_variance_steps = options_.conditional_variance_decomposition;
if length(conditional_variance_steps)
oo_ = display_conditional_variance_decomposition(conditional_variance_steps,...
ivar,dr,M_, ...
options_,oo_);
end
end end
if options_.nocorr == 0 if options_.nocorr == 0
......
function oo_ = display_conditional_variance_decomposition(Steps, SubsetOfVariables, dr,M_,options_,oo_)
% This function computes the conditional variance decomposition of a given state space model
% for a subset of endogenous variables.
%
% INPUTS
% StateSpaceModel [structure] Specification of the state space model.
% Steps [integer] 1*h vector of dates.
% SubsetOfVariables [integer] 1*q vector of indices.
%
% OUTPUTS
% PackedConditionalVarianceDecomposition [double] n(n+1)/2*p matrix, where p is the number of state innovations and
% n is equal to length(SubsetOfVariables).
%
% SPECIAL REQUIREMENTS
%
% [1] The covariance matrix of the state innovations needs to be diagonal.
% [2] In this version, absence of measurement errors is assumed...
% Copyright (C) 2009 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
endo_nbr = M_.endo_nbr;
exo_nbr = M_.exo_nbr;
StateSpaceModel.number_of_state_equations = M_.endo_nbr;
StateSpaceModel.number_of_state_innovations = exo_nbr;
StateSpaceModel.sigma_e_is_diagonal = M_.sigma_e_is_diagonal;
iv = (1:endo_nbr)';
ic = dr.nstatic+(1:dr.npred)';
[StateSpaceModel.transition_matrix,StateSpaceModel.impulse_matrix] = kalman_transition_matrix(dr,iv,ic,[],exo_nbr);
StateSpaceModel.state_innovations_covariance_matrix = M_.Sigma_e;
conditional_decomposition_array = conditional_variance_decomposition(StateSpaceModel,Steps,dr.inv_order_var(SubsetOfVariables ));
if options_.noprint == 0
disp(' ')
disp('CONDITIONAL VARIANCE DECOMPOSITION (in percent)')
end
vardec_i = zeros(length(SubsetOfVariables),exo_nbr);
for i=1:length(Steps)
disp(['Period ' int2str(Steps(i)) ':'])
for j=1:exo_nbr
vardec_i(:,j) = diag_vech(conditional_decomposition_array(:, ...
i,j));
end
vardec_i = 100*vardec_i./repmat(sum(vardec_i,2),1,exo_nbr);
if options_.noprint == 0
headers = M_.exo_names;
headers(M_.exo_names_orig_ord,:) = headers;
headers = strvcat(' ',headers);
lh = size(deblank(M_.endo_names(SubsetOfVariables,:)),2)+2;
dyntable('',headers,...
deblank(M_.endo_names(SubsetOfVariables,:)),...
vardec_i,lh,8,2);
end
end
oo_.conditional_variance_decomposition = conditional_decomposition_array;
\ No newline at end of file
...@@ -117,6 +117,7 @@ for file = 1:NumberOfDrawsFiles ...@@ -117,6 +117,7 @@ for file = 1:NumberOfDrawsFiles
aux(k,2) = aux(k,2) + dr.nfwrd; aux(k,2) = aux(k,2) + dr.nfwrd;
StateSpaceModel.number_of_state_equations = M_.endo_nbr+rows(aux); StateSpaceModel.number_of_state_equations = M_.endo_nbr+rows(aux);
StateSpaceModel.number_of_state_innovations = M_.exo_nbr; StateSpaceModel.number_of_state_innovations = M_.exo_nbr;
StateSpaceModel.sigma_e_is_diagonal = M_.sigma_e_is_diagonal;
first_call = 0; first_call = 0;
clear('endo_nbr','nstatic','npred','k'); clear('endo_nbr','nstatic','npred','k');
end end
......
...@@ -106,14 +106,13 @@ function info = forecast(var_list,task) ...@@ -106,14 +106,13 @@ function info = forecast(var_list,task)
if M_.exo_det_nbr == 0 if M_.exo_det_nbr == 0
[yf,int_width] = forcst(oo_.dr,y0,horizon,var_list); [yf,int_width] = forcst(oo_.dr,y0,horizon,var_list);
else else
exo_det_length = size(oo_.exo_det_simul,1); exo_det_length = size(oo_.exo_det_simul,1)-M_.maximum_lag;
if horizon > exo_det_length if horizon > exo_det_length
ex = zeros(horizon,M_.exo_nbr); ex = zeros(horizon,M_.exo_nbr);
oo_.exo_det_simul = [ oo_.exo_det_simul;... oo_.exo_det_simul = [ oo_.exo_det_simul;...
repmat(oo_.exo_det_steady_state',... repmat(oo_.exo_det_steady_state',...
horizon- ... horizon- ...
exo_det_length,1)]; exo_det_length,1)];
%ex_det_length,1),1)];
elseif horizon < exo_det_length elseif horizon < exo_det_length
ex = zeros(exo_det_length,M_.exo_nbr); ex = zeros(exo_det_length,M_.exo_nbr);
end end
......
...@@ -118,7 +118,6 @@ function global_initialization() ...@@ -118,7 +118,6 @@ function global_initialization()
options_.linear = 0; options_.linear = 0;
options_.replic = 50; options_.replic = 50;
options_.drop = 100; options_.drop = 100;
options_.simul_algo = 0;
% if mjdgges.dll (or .mexw32 or ....) doesn't exist, matlab/qz is added to the path. % if mjdgges.dll (or .mexw32 or ....) doesn't exist, matlab/qz is added to the path.
% There exists now qz/mjdgges.m that contains the calls to the old Sims code % There exists now qz/mjdgges.m that contains the calls to the old Sims code
% Hence, if mjdgges.m is visible exist(...)==2, % Hence, if mjdgges.m is visible exist(...)==2,
...@@ -131,6 +130,7 @@ function global_initialization() ...@@ -131,6 +130,7 @@ function global_initialization()
options_.aim_solver = 0; % i.e. by default do not use G.Anderson's AIM solver, use mjdgges instead options_.aim_solver = 0; % i.e. by default do not use G.Anderson's AIM solver, use mjdgges instead
options_.use_k_order=0; % by default do not use k_order_perturbation but mjdgges options_.use_k_order=0; % by default do not use k_order_perturbation but mjdgges
options