Skip to content
Snippets Groups Projects
Commit 755c5645 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Merge branch 'irf' into 'master'

Fix posterior IRF generation with loglinear option

See merge request Dynare/dynare!2083
parents 9ea8e17f ee8dfb76
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,7 @@ for i=1:nvar
end
% Get index of shocks for requested IRFs
irf_shocks_indx = getIrfShocksIndx();
irf_shocks_indx = getIrfShocksIndx(M_, options_);
% Set various parameters & Check or create directories
nvx = estim_params_.nvx;
......
......@@ -144,7 +144,7 @@ while fpar<B
deep = x(fpar,:);
end
stock_param(irun2,:) = deep;
set_parameters(deep);
M_ = set_parameters_locally(M_, deep);
[dr,info,M_,oo_] =compute_decision_rules(M_,options_,oo_);
oo_.dr = dr;
if info(1)
......@@ -174,7 +174,7 @@ while fpar<B
end
SS(M_.exo_names_orig_ord,M_.exo_names_orig_ord) = M_.Sigma_e+1e-14*eye(M_.exo_nbr);
SS = transpose(chol(SS));
irf_shocks_indx = getIrfShocksIndx();
irf_shocks_indx = getIrfShocksIndx(M_, options_);
for i=irf_shocks_indx
if SS(i,i) > 1e-13
if options_.order>1 && options_.relative_irf % normalize shock to 0.01 before IRF generation for GIRFs; multiply with 100 later
......
function irf_shocks_indx=getIrfShocksIndx()
% irf_shocks_indx=getIrfShocksIndx()
function irf_shocks_indx=getIrfShocksIndx(M_, options_)
% irf_shocks_indx=getIrfShocksIndx(M_, options_)
% returns the unique indices of the exogenous shocks specified for IRF
% generation using the irf_shocks-command
%
% Inputs:
% none
% - M_ [structure] Matlab's structure describing the model (M_).
% - options_ [structure] Matlab's structure describing the current options (options_).
% Outputs:
% irf_shocks_indx: [1 by n_irf_shocks] vector storing the indices
% - irf_shocks_indx: [1 by n_irf_shocks] vector storing the indices
%
% Copyright © 2011-2018 Dynare Team
% Copyright © 2011-2022 Dynare Team
%
% This file is part of Dynare.
%
......@@ -25,8 +26,6 @@ function irf_shocks_indx=getIrfShocksIndx()
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
global M_ options_
if (isfield(options_,'irf_shocks')==0)
irf_shocks_indx = M_.exo_names_orig_ord;
else
......
......@@ -35,6 +35,11 @@ function y = irf(M_, options_, dr, e1, long, drop, replic, iorder)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
if options_.loglinear && ~options_.logged_steady_state
dr.ys = log_variable(1:M_.endo_nbr,dr.ys,M_);
options_.logged_steady_state=1;
end
if M_.maximum_lag >= 1
temps = repmat(dr.ys,1,M_.maximum_lag);
else
......
......@@ -86,7 +86,7 @@ if options.loglinear
% Find variables with non positive steady state. Skip auxiliary
% variables for lagges/leaded exogenous variables
idx = find(dr.ys(get_all_variables_but_lagged_leaded_exogenous(M))<threshold);
if length(idx)
if ~isempty(idx)
if options.debug
variables_with_non_positive_steady_state = M.endo_names{idx};
skipline()
......
......@@ -237,7 +237,7 @@ if options_.irf
if TeX
titTeX(M_.exo_names_orig_ord) = M_.exo_names_tex;
end
irf_shocks_indx = getIrfShocksIndx();
irf_shocks_indx = getIrfShocksIndx(M_, options_);
for i=irf_shocks_indx
if SS(i,i) > 1e-13
if PI_PCL_solver
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment