2020-02-24 14:14:41 +01:00
function [info, oo_, options_, M_] = stoch_simul ( M_, options_, oo_, var_list)
2023-09-08 11:59:37 +02:00
%[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list)
% Computes the stochastic simulations
%
% INPUTS
% - M_ [structure] Matlab's structure describing the model
% - options_ [structure] Matlab's structure describing the current options
% - oo_ [structure] Matlab's structure containing the results
% - var_list [character array] list of endogenous variables specified
%
% OUTPUTS
% - info [integer] scalar or vector, error code.
% - oo [structure] Matlab's structure containing the results (oo_).
% - options_ [structure] Matlab's structure describing the current options
% - M [structure] Matlab's structure describing the model (M_).
2008-08-01 20:53:30 +02:00
2023-09-08 11:59:37 +02:00
% Copyright © 2001-2023 Dynare Team
2008-08-01 20:53:30 +02:00
%
% 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
2021-06-09 17:33:48 +02:00
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
2008-08-01 20:53:30 +02:00
2013-11-28 10:57:54 +01:00
% Test if the order of approximation is nonzero (the preprocessor tests if order is non negative).
2013-11-28 10:51:20 +01:00
if isequal ( options_ . order , 0 )
error ( ' stoch_simul:: The order of the Taylor approximation cannot be 0!' )
end
2019-09-10 09:23:49 +02:00
if M_ . exo_nbr == 0
error ( ' stoch_simul:: does not support having no varexo in the model. As a workaround you could define a dummy exogenous variable.' )
end
2021-01-26 11:40:46 +01:00
if ismember ( options_ . solve_algo , [ 10 , 11 ] )
error ( ' stoch_simul:: perturbation solutions are not compatible with mixed complementarity problems and their solvers' )
end
2010-11-17 17:09:39 +01:00
test_for_deep_parameters_calibration ( M_ ) ;
2009-12-16 18:17:34 +01:00
options_old = options_ ;
if options_ . linear
options_ . order = 1 ;
end
if options_ . order == 1
options_ . replic = 1 ;
end
2005-02-18 20:54:39 +01:00
2019-12-13 18:20:10 +01:00
if options_ . order ~= 1 && M_ . hessian_eq_zero
2017-08-29 10:54:53 +02:00
options_ . order = 1 ;
warning ( ' stoch_simul: using order = 1 because Hessian is equal to zero' ) ;
end
2010-12-23 08:34:13 +01:00
if isempty ( options_ . qz_criterium )
options_ . qz_criterium = 1 + 1e-6 ;
end
2019-03-19 14:26:16 +01:00
if options_ . partial_information || options_ . ACES_solver
2010-03-25 00:26:05 +01:00
PI_PCL_solver = 1 ;
2010-03-29 12:44:38 +02:00
if options_ . order ~= 1
2013-11-28 10:57:54 +01:00
warning ( ' stoch_simul:: forcing order=1 since you are using partial_information or ACES solver' )
2010-03-29 12:44:38 +02:00
options_ . order = 1 ;
end
2010-03-23 11:09:59 +01:00
else
2010-03-25 00:26:05 +01:00
PI_PCL_solver = 0 ;
2010-03-23 11:09:59 +01:00
end
2005-09-11 11:43:58 +02:00
2009-12-16 18:17:34 +01:00
TeX = options_ . TeX ;
2017-10-10 10:05:59 +02:00
if isempty ( var_list )
var_list = M_ . endo_names ( 1 : M_ . orig_endo_nbr ) ;
2010-03-23 11:09:59 +01:00
end
2017-10-10 10:05:59 +02:00
[ i_var , nvar , index_uniques ] = varlist_indices ( var_list , M_ . endo_names ) ;
var_list = var_list ( index_uniques ) ;
2019-09-12 14:57:32 +02:00
oo_ . var_list = var_list ;
2010-03-23 11:09:59 +01:00
2009-12-16 18:17:34 +01:00
iter_ = max ( options_ . periods , 1 ) ;
if M_ . exo_nbr > 0
2005-09-11 11:43:58 +02:00
oo_ . exo_simul = ones ( iter_ + M_ . maximum_lag + M_ . maximum_lead , 1 ) * oo_ . exo_steady_state ' ;
2009-12-16 18:17:34 +01:00
end
2005-02-18 20:54:39 +01:00
2012-06-28 18:05:24 +02:00
check_model ( M_ ) ;
2005-09-11 11:43:58 +02:00
2023-10-08 22:08:57 +02:00
oo_ . dr = set_state_space ( oo_ . dr , M_ ) ;
2010-07-09 12:54:06 +02:00
2010-03-25 00:26:05 +01:00
if PI_PCL_solver
2010-03-23 11:09:59 +01:00
[ oo_ . dr , info ] = PCL_resol ( oo_ . steady_state , 0 ) ;
2011-03-13 21:19:55 +01:00
elseif options_ . discretionary_policy
2020-12-16 21:47:43 +01:00
if ~ options_ . order == 1
2013-11-29 17:49:57 +01:00
error ( ' discretionary_policy: only linear-quadratic problems can be solved' ) ;
2011-03-13 21:19:55 +01:00
end
2023-09-15 13:40:10 +02:00
[ oo_ . dr , info , M_ . params ] = discretionary_policy_1 ( M_ , options_ , oo_ . dr , oo_ . steady_state , oo_ . exo_steady_state , oo_ . exo_det_steady_state ) ;
2010-03-23 11:09:59 +01:00
else
2014-01-30 09:07:28 +01:00
if options_ . logged_steady_state %if steady state was previously logged, undo this
2014-01-29 19:52:20 +01:00
oo_ . dr . ys = exp ( oo_ . dr . ys ) ;
oo_ . steady_state = exp ( oo_ . steady_state ) ;
2015-03-07 12:36:58 +01:00
options_ . logged_steady_state = 0 ;
2014-01-29 19:52:20 +01:00
end
2023-09-15 13:40:10 +02:00
[ oo_ . dr , info , M_ . params ] = resol ( 0 , M_ , options_ , oo_ . dr , oo_ . steady_state , oo_ . exo_steady_state , oo_ . exo_det_steady_state ) ;
2010-03-23 11:09:59 +01:00
end
2005-09-11 11:43:58 +02:00
2017-05-16 15:10:20 +02:00
if options_ . loglinear && isfield ( oo_ . dr , ' ys' ) && options_ . logged_steady_state == 0 %log steady state for correct display of decision rule
2016-05-02 13:51:51 +02:00
oo_ . dr . ys = log_variable ( 1 : M_ . endo_nbr , oo_ . dr . ys , M_ ) ;
oo_ . steady_state = log_variable ( 1 : M_ . endo_nbr , oo_ . steady_state , M_ ) ;
2015-05-29 16:17:12 +02:00
options_old . logged_steady_state = 1 ; %make sure option is preserved outside of stoch_simul
options_ . logged_steady_state = 1 ; %set option for use in stoch_simul
2014-01-29 19:21:16 +01:00
end
2009-12-16 18:17:34 +01:00
if info ( 1 )
2006-11-18 08:37:22 +01:00
options_ = options_old ;
2013-06-12 10:54:33 +02:00
print_info ( info , options_ . noprint , options_ ) ;
2005-09-11 11:43:58 +02:00
return
2010-11-17 17:09:39 +01:00
end
2005-09-11 11:43:58 +02:00
2009-12-16 18:17:34 +01:00
if ~ options_ . noprint
2023-10-08 22:13:45 +02:00
if ~ options_ . nomodelsummary
skipline ( )
disp ( ' MODEL SUMMARY' )
skipline ( )
disp ( [ ' Number of variables: ' int2str ( M_ . endo_nbr ) ] )
disp ( [ ' Number of stochastic shocks: ' int2str ( M_ . exo_nbr ) ] )
disp ( [ ' Number of state variables: ' int2str ( M_ . nspred ) ] )
disp ( [ ' Number of jumpers: ' int2str ( M_ . nsfwrd ) ] )
disp ( [ ' Number of static variables: ' int2str ( M_ . nstatic ) ] )
my_title = ' MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS' ;
labels = M_ . exo_names ;
2017-10-10 10:05:59 +02:00
headers = vertcat ( ' Variables' , labels ) ;
lh = cellofchararraymaxlength ( labels ) + 2 ;
2023-10-08 22:13:45 +02:00
dyntable ( options_ , my_title , headers , labels , M_ . Sigma_e , lh , 10 , 6 ) ;
2017-09-09 08:42:08 +02:00
if options_ . TeX
2017-10-10 10:05:59 +02:00
labels = M_ . exo_names_tex ;
headers = vertcat ( ' Variables' , labels ) ;
lh = cellofchararraymaxlength ( labels ) + 2 ;
2023-10-08 22:13:45 +02:00
dyn_latex_table ( M_ , options_ , my_title , ' covar_ex_shocks' , headers , labels , M_ . Sigma_e , lh , 10 , 6 ) ;
end
if ~ all ( diag ( M_ . H ) == 0 )
my_title = ' MATRIX OF COVARIANCE OF MEASUREMENT ERRORS' ;
labels = cellfun ( @ ( x ) horzcat ( ' SE_' , x ) , options_ . varobs , ' UniformOutput' , false ) ;
headers = vertcat ( ' Variables' , labels ) ;
lh = cellofchararraymaxlength ( labels ) + 2 ;
dyntable ( options_ , my_title , headers , labels , M_ . H , lh , 10 , 6 ) ;
if options_ . TeX
labels = M_ . exo_names_tex ;
headers = vertcat ( ' Variables' , labels ) ;
lh = cellofchararraymaxlength ( labels ) + 2 ;
dyn_latex_table ( M_ , options_ , my_title , ' covar_ME' , headers , labels , M_ . H , lh , 10 , 6 ) ;
end
2017-09-09 08:42:08 +02:00
end
end
2010-03-23 11:09:59 +01:00
if options_ . partial_information
2013-07-10 17:12:34 +02:00
skipline ( )
2010-03-25 11:20:34 +01:00
disp ( ' SOLUTION UNDER PARTIAL INFORMATION' )
2013-07-10 17:12:34 +02:00
skipline ( )
2010-03-25 00:26:05 +01:00
if isfield ( options_ , ' varobs' ) && ~ isempty ( options_ . varobs )
2017-10-10 10:05:59 +02:00
PCL_varobs = options_ . varobs ;
2011-02-04 17:17:48 +01:00
disp ( ' OBSERVED VARIABLES' )
2010-03-25 00:26:05 +01:00
else
2017-10-10 10:05:59 +02:00
PCL_varobs = M_ . endo_names ;
2011-02-04 17:17:48 +01:00
disp ( ' VAROBS LIST NOT SPECIFIED' )
disp ( ' ASSUMED OBSERVED VARIABLES' )
2010-03-25 00:26:05 +01:00
end
2017-10-10 10:05:59 +02:00
for i = 1 : length ( PCL_varobs )
disp ( [ ' ' PCL_varobs { i } ] )
2010-03-23 11:09:59 +01:00
end
end
2013-07-10 17:12:34 +02:00
skipline ( )
2010-03-25 00:26:05 +01:00
if options_ . order < = 2 && ~ PI_PCL_solver
2013-09-10 16:35:50 +02:00
if ~ options_ . nofunctions
2023-09-08 14:22:52 +02:00
disp_dr ( M_ , options_ , oo_ . dr , options_ . order , var_list ) ;
2013-09-10 16:35:50 +02:00
end
2009-11-29 22:05:16 +01:00
end
2009-12-16 18:17:34 +01:00
end
2005-02-18 20:54:39 +01:00
2010-03-25 00:26:05 +01:00
if options_ . periods > 0 && ~ PI_PCL_solver
2011-01-02 16:54:08 +01:00
if options_ . periods < = options_ . drop
2014-03-03 19:50:25 +01:00
fprintf ( ' \nSTOCH_SIMUL error: The horizon of simulation is shorter than the number of observations to be dropped.\n' )
fprintf ( ' STOCH_SIMUL error: Either increase options_.periods or decrease options_.drop.\n' )
2009-12-16 18:17:34 +01:00
options_ = options_old ;
return
2005-02-18 20:54:39 +01:00
end
2011-12-28 11:11:06 +01:00
if isempty ( M_ . endo_histval )
2011-12-21 18:37:45 +01:00
y0 = oo_ . dr . ys ;
else
2017-02-14 12:54:22 +01:00
if options_ . loglinear
y0 = log_variable ( 1 : M_ . endo_nbr , M_ . endo_histval , M_ ) ;
else
y0 = M_ . endo_histval ;
end
2011-12-21 18:37:45 +01:00
end
2023-09-15 09:30:05 +02:00
[ oo_ . endo_simul , oo_ . exo_simul ] = simult ( y0 , oo_ . dr , M_ , options_ ) ;
2015-05-28 11:53:50 +02:00
if ~ options_ . minimal_workspace
2019-09-10 17:02:20 +02:00
dyn2vec ( M_ , oo_ , options_ ) ;
2015-05-28 11:53:50 +02:00
end
2010-03-23 11:09:59 +01:00
end
2019-03-19 14:26:16 +01:00
if ~ options_ . nomoments
2010-03-25 00:26:05 +01:00
if PI_PCL_solver
2017-10-10 10:05:59 +02:00
PCL_Part_info_moments ( 0 , PCL_varobs , oo_ . dr , i_var ) ;
2010-03-23 11:09:59 +01:00
elseif options_ . periods == 0
2020-12-15 14:38:33 +01:00
if options_ . order == 1 || ( options_ . order == 2 && ~ options_ . pruning )
2015-08-17 08:57:07 +02:00
oo_ = disp_th_moments ( oo_ . dr , var_list , M_ , options_ , oo_ ) ;
2020-12-15 14:38:33 +01:00
elseif ( ismember ( options_ . order , [ 2 , 3 ] ) ) && options_ . pruning
2020-06-29 13:16:57 +02:00
% There is no code for theoretical moments at 3rd order without pruning
2020-12-15 14:38:33 +01:00
oo_ = disp_th_moments_pruned_state_space ( oo_ . dr , M_ , options_ , i_var , oo_ ) ;
2011-10-27 18:03:42 +02:00
end
2010-03-23 11:09:59 +01:00
else
2015-08-07 16:57:28 +02:00
oo_ = disp_moments ( oo_ . endo_simul , var_list , M_ , options_ , oo_ ) ;
2005-02-18 20:54:39 +01:00
end
2009-12-16 18:17:34 +01:00
end
2005-02-18 20:54:39 +01:00
2005-09-11 11:43:58 +02:00
2011-09-17 12:33:07 +02:00
if options_ . irf
2017-10-10 10:05:59 +02:00
var_listTeX = M_ . endo_names_tex ( i_var ) ;
2020-02-24 16:13:44 +01:00
if ~ options_ . nograph || ( TeX && any ( strcmp ( ' eps' , cellstr ( options_ . graph_format ) ) ) )
2020-12-16 22:38:22 +01:00
if ~ exist ( [ M_ . dname ' /graphs' ] , ' dir' )
mkdir ( M_ . dname , ' graphs' ) ;
2019-11-21 10:12:46 +01:00
end
2019-11-21 11:58:16 +01:00
end
if TeX && any ( strcmp ( ' eps' , cellstr ( options_ . graph_format ) ) )
2020-12-16 22:38:22 +01:00
fidTeX = fopen ( [ M_ . dname , ' /graphs/' M_ . fname ' _IRF.tex' ] , ' w' ) ;
2009-12-16 18:17:34 +01:00
fprintf ( fidTeX , ' %% TeX eps-loader file generated by stoch_simul.m (Dynare).\n' ) ;
fprintf ( fidTeX , [ ' %% ' datestr ( now , 0 ) ' \n' ] ) ;
fprintf ( fidTeX , ' \n' ) ;
2005-09-11 11:43:58 +02:00
end
2023-06-23 15:57:17 +02:00
cs = get_lower_cholesky_covariance ( M_ . Sigma_e , options_ . add_tiny_number_to_cholesky ) ;
2023-06-23 14:41:12 +02:00
tit = M_ . exo_names ;
2005-09-11 11:43:58 +02:00
if TeX
2023-06-23 14:41:12 +02:00
titTeX = M_ . exo_names_tex ;
2005-02-18 20:54:39 +01:00
end
2022-09-21 09:27:43 +02:00
irf_shocks_indx = getIrfShocksIndx ( M_ , options_ ) ;
2011-03-31 16:33:47 +02:00
for i = irf_shocks_indx
2023-06-23 15:57:17 +02:00
if cs ( i , i ) > 5e-7
2010-03-25 00:26:05 +01:00
if PI_PCL_solver
y = PCL_Part_info_irf ( 0 , PCL_varobs , i_var , M_ , oo_ . dr , options_ . irf , i ) ;
2010-03-23 11:09:59 +01:00
else
2014-09-22 10:29:00 +02:00
if options_ . order > 1 && options_ . relative_irf % normalize shock to 0.01 before IRF generation for GIRFs; multiply with 100 later
2023-06-23 14:41:12 +02:00
y = irf ( M_ , options_ , oo_ . dr , cs ( : , i ) ./ cs ( i , i ) / 100 , options_ . irf , options_ . drop , ...
2017-05-16 15:10:20 +02:00
options_ . replic , options_ . order ) ;
2014-09-22 10:29:00 +02:00
else %for linear model, rescaling is done later
2023-06-23 14:41:12 +02:00
y = irf ( M_ , options_ , oo_ . dr , cs ( : , i ) , options_ . irf , options_ . drop , ...
2014-09-22 10:29:00 +02:00
options_ . replic , options_ . order ) ;
end
2010-03-23 11:09:59 +01:00
end
2013-10-02 09:48:07 +02:00
if ~ options_ . noprint && any ( any ( isnan ( y ) ) ) && ~ options_ . pruning && ~ ( options_ . order == 1 )
2017-10-10 10:05:59 +02:00
fprintf ( ' \nstoch_simul:: The simulations conducted for generating IRFs to %s were explosive.\n' , M_ . exo_names { i } )
2013-11-28 10:57:54 +01:00
fprintf ( ' stoch_simul:: No IRFs will be displayed. Either reduce the shock size, \n' )
fprintf ( ' stoch_simul:: use pruning, or set the approximation order to 1.' ) ;
2013-10-02 09:48:07 +02:00
skipline ( 2 ) ;
end
2009-12-16 18:17:34 +01:00
if options_ . relative_irf
2014-09-22 10:29:00 +02:00
if options_ . order == 1 %multiply with 100 for backward compatibility
y = 100 * y / cs ( i , i ) ;
end
2009-12-16 18:17:34 +01:00
end
irfs = [ ] ;
mylist = [ ] ;
if TeX
mylistTeX = [ ] ;
end
2010-03-23 11:09:59 +01:00
for j = 1 : nvar
2017-10-10 10:05:59 +02:00
assignin ( ' base' , [ M_ . endo_names { i_var ( j ) } ' _' M_ . exo_names { i } ] , ...
2010-03-23 11:09:59 +01:00
y ( i_var ( j ) , : ) ' ) ;
2019-09-11 10:11:36 +02:00
oo_ . irfs . ( [ M_ . endo_names { i_var ( j ) } ' _' M_ . exo_names { i } ] ) = y ( i_var ( j ) , : ) ;
2015-08-14 12:36:08 +02:00
if max ( abs ( y ( i_var ( j ) , : ) ) ) > = options_ . impulse_responses . plot_threshold
2010-03-23 11:09:59 +01:00
irfs = cat ( 1 , irfs , y ( i_var ( j ) , : ) ) ;
2010-09-26 13:42:41 +02:00
if isempty ( mylist )
2017-10-10 10:05:59 +02:00
mylist = var_list { j } ;
2010-09-26 13:42:41 +02:00
else
2017-10-10 10:05:59 +02:00
mylist = char ( mylist , var_list { j } ) ;
2010-09-26 13:42:41 +02:00
end
2009-12-16 18:17:34 +01:00
if TeX
2010-09-26 13:42:41 +02:00
if isempty ( mylistTeX )
2017-10-10 10:05:59 +02:00
mylistTeX = var_listTeX { j } ;
2010-09-26 13:42:41 +02:00
else
2017-10-10 10:05:59 +02:00
mylistTeX = char ( mylistTeX , var_listTeX { j } ) ;
2010-09-26 13:42:41 +02:00
end
2009-12-16 18:17:34 +01:00
end
2013-10-12 10:42:16 +02:00
else
if options_ . debug
2017-10-10 10:05:59 +02:00
fprintf ( ' stoch_simul:: The IRF of %s to %s is smaller than the irf_plot_threshold of %4.3f and will not be displayed.\n' , M_ . endo_names { i_var ( j ) } , M_ . exo_names { i } , options_ . impulse_responses . plot_threshold )
2013-10-12 10:42:16 +02:00
end
2009-12-16 18:17:34 +01:00
end
end
2019-03-19 14:26:16 +01:00
if ~ options_ . nograph
2009-12-16 18:17:34 +01:00
number_of_plots_to_draw = size ( irfs , 1 ) ;
[ nbplt , nr , nc , lr , lc , nstar ] = pltorg ( number_of_plots_to_draw ) ;
if nbplt == 0
elseif nbplt == 1
if options_ . relative_irf
2023-09-19 13:19:07 +02:00
hh_fig = dyn_figure ( options_ . nodisplay , ' Name' , [ ' Relative response to' ...
2017-10-10 10:05:59 +02:00
' orthogonalized shock to ' tit { i } ] ) ;
2009-12-16 18:17:34 +01:00
else
2023-09-19 13:19:07 +02:00
hh_fig = dyn_figure ( options_ . nodisplay , ' Name' , [ ' Orthogonalized shock to' ...
2017-10-10 10:05:59 +02:00
' ' tit { i } ] ) ;
2009-12-16 18:17:34 +01:00
end
for j = 1 : number_of_plots_to_draw
subplot ( nr , nc , j ) ;
plot ( 1 : options_ . irf , transpose ( irfs ( j , : ) ) , ' -k' , ' linewidth' , 1 ) ;
hold on
plot ( [ 1 options_ . irf ] , [ 0 0 ] , ' -r' , ' linewidth' , 0.5 ) ;
hold off
xlim ( [ 1 options_ . irf ] ) ;
2016-06-18 14:28:49 +02:00
remove_fractional_xticks ;
2020-06-17 20:23:49 +02:00
if TeX
title ( [ ' $' deblank ( mylistTeX ( j , : ) ) ' $' ] , ' Interpreter' , ' latex' ) ;
else
title ( deblank ( mylist ( j , : ) ) , ' Interpreter' , ' none' ) ;
end
2009-12-16 18:17:34 +01:00
end
2023-09-19 13:19:07 +02:00
dyn_saveas ( hh_fig , [ M_ . dname , ' /graphs/' M_ . fname ' _IRF_' tit { i } ] , options_ . nodisplay , options_ . graph_format ) ;
2015-05-12 08:53:57 +02:00
if TeX && any ( strcmp ( ' eps' , cellstr ( options_ . graph_format ) ) )
2009-12-16 18:17:34 +01:00
fprintf ( fidTeX , ' \\begin{figure}[H]\n' ) ;
fprintf ( fidTeX , ' \\centering \n' ) ;
2020-12-16 22:38:22 +01:00
fprintf ( fidTeX , ' \\includegraphics[width=%2.2f\\textwidth]{%s_IRF_%s}\n' , options_ . figures . textwidth * min ( j / nc , 1 ) , [ M_ . dname , ' /graphs/' M_ . fname ] , tit { i } ) ;
2017-10-10 10:05:59 +02:00
fprintf ( fidTeX , ' \\caption{Impulse response functions (orthogonalized shock to $%s$).}\n' , titTeX { i } ) ;
fprintf ( fidTeX , ' \\label{Fig:IRF:%s}\n' , tit { i } ) ;
2009-12-16 18:17:34 +01:00
fprintf ( fidTeX , ' \\end{figure}\n' ) ;
fprintf ( fidTeX , ' \n' ) ;
end
else
for fig = 1 : nbplt - 1
2012-04-20 20:17:20 +02:00
if options_ . relative_irf
2023-09-19 13:19:07 +02:00
hh_fig = dyn_figure ( options_ . nodisplay , ' Name' , [ ' Relative response to orthogonalized shock' ...
2017-10-10 10:05:59 +02:00
' to ' tit { i } ' figure ' int2str ( fig ) ] ) ;
2009-12-16 18:17:34 +01:00
else
2023-09-19 13:19:07 +02:00
hh_fig = dyn_figure ( options_ . nodisplay , ' Name' , [ ' Orthogonalized shock to ' tit { i } ...
2009-12-16 18:17:34 +01:00
' figure ' int2str ( fig ) ] ) ;
end
for plt = 1 : nstar
subplot ( nr , nc , plt ) ;
plot ( 1 : options_ . irf , transpose ( irfs ( ( fig - 1 ) * nstar + plt , : ) ) , ' -k' , ' linewidth' , 1 ) ;
hold on
plot ( [ 1 options_ . irf ] , [ 0 0 ] , ' -r' , ' linewidth' , 0.5 ) ;
hold off
xlim ( [ 1 options_ . irf ] ) ;
2016-06-18 14:28:49 +02:00
remove_fractional_xticks
2020-06-17 20:23:49 +02:00
if TeX
title ( [ ' $' deblank ( mylistTeX ( ( fig - 1 ) * nstar + plt , : ) ) ' $' ] , ' Interpreter' , ' latex' ) ;
else
title ( deblank ( mylist ( ( fig - 1 ) * nstar + plt , : ) ) , ' Interpreter' , ' none' ) ;
end
2009-12-16 18:17:34 +01:00
end
2023-09-19 13:19:07 +02:00
dyn_saveas ( hh_fig , [ M_ . dname , ' /graphs/' M_ . fname ' _IRF_' tit { i } int2str ( fig ) ] , options_ . nodisplay , options_ . graph_format ) ;
2015-05-12 08:53:57 +02:00
if TeX && any ( strcmp ( ' eps' , cellstr ( options_ . graph_format ) ) )
2009-12-16 18:17:34 +01:00
fprintf ( fidTeX , ' \\begin{figure}[H]\n' ) ;
fprintf ( fidTeX , ' \\centering \n' ) ;
2020-12-16 22:38:22 +01:00
fprintf ( fidTeX , ' \\includegraphics[width=%2.2f\\textwidth]{%s_IRF_%s%s}\n' , options_ . figures . textwidth * min ( plt / nc , 1 ) , [ M_ . dname , ' /graphs/' M_ . fname ] , tit { i } , int2str ( fig ) ) ;
2009-12-16 18:17:34 +01:00
if options_ . relative_irf
2019-02-25 12:38:20 +01:00
fprintf ( fidTeX , ' \\caption{Relative impulse response functions (orthogonalized shock to $%s$).}' , titTeX { i } ) ;
2009-12-16 18:17:34 +01:00
else
2019-02-25 12:38:20 +01:00
fprintf ( fidTeX , ' \\caption{Impulse response functions (orthogonalized shock to $%s$).}' , titTeX { i } ) ;
2009-12-16 18:17:34 +01:00
end
2017-10-10 10:05:59 +02:00
fprintf ( fidTeX , ' \\label{Fig:IRF:%s:%s}\n' , tit { i } , int2str ( fig ) ) ;
2009-12-16 18:17:34 +01:00
fprintf ( fidTeX , ' \\end{figure}\n' ) ;
fprintf ( fidTeX , ' \n' ) ;
end
end
2023-09-19 13:19:07 +02:00
hh_fig = dyn_figure ( options_ . nodisplay , ' Name' , [ ' Orthogonalized shock to ' tit { i } ' figure ' int2str ( nbplt ) ' .' ] ) ;
2011-09-17 12:33:07 +02:00
m = 0 ;
2017-05-16 12:42:01 +02:00
for plt = 1 : number_of_plots_to_draw - ( nbplt - 1 ) * nstar
2009-12-16 18:17:34 +01:00
m = m + 1 ;
subplot ( lr , lc , m ) ;
plot ( 1 : options_ . irf , transpose ( irfs ( ( nbplt - 1 ) * nstar + plt , : ) ) , ' -k' , ' linewidth' , 1 ) ;
hold on
plot ( [ 1 options_ . irf ] , [ 0 0 ] , ' -r' , ' linewidth' , 0.5 ) ;
hold off
xlim ( [ 1 options_ . irf ] ) ;
2016-06-18 14:28:49 +02:00
remove_fractional_xticks
2020-06-17 20:23:49 +02:00
if TeX
title ( [ ' $' deblank ( mylistTeX ( ( nbplt - 1 ) * nstar + plt , : ) ) ' $' ] , ' Interpreter' , ' latex' ) ;
else
title ( deblank ( mylist ( ( nbplt - 1 ) * nstar + plt , : ) ) , ' Interpreter' , ' none' ) ;
end
2009-12-16 18:17:34 +01:00
end
2023-09-19 13:19:07 +02:00
dyn_saveas ( hh_fig , [ M_ . dname , ' /graphs/' M_ . fname ' _IRF_' tit { i } int2str ( nbplt ) ] , options_ . nodisplay , options_ . graph_format ) ;
2015-05-12 08:53:57 +02:00
if TeX && any ( strcmp ( ' eps' , cellstr ( options_ . graph_format ) ) )
2009-12-16 18:17:34 +01:00
fprintf ( fidTeX , ' \\begin{figure}[H]\n' ) ;
fprintf ( fidTeX , ' \\centering \n' ) ;
2020-12-16 22:38:22 +01:00
fprintf ( fidTeX , ' \\includegraphics[width=%2.2f\\textwidth]{%s_IRF_%s%s}\n' , options_ . figures . textwidth * min ( m / lc , 1 ) , [ M_ . dname , ' /graphs/' M_ . fname ] , tit { i } , int2str ( nbplt ) ) ;
2009-12-16 18:17:34 +01:00
if options_ . relative_irf
2019-02-25 12:38:20 +01:00
fprintf ( fidTeX , ' \\caption{Relative impulse response functions (orthogonalized shock to $%s$).}' , titTeX { i } ) ;
2009-12-16 18:17:34 +01:00
else
2019-02-25 12:38:20 +01:00
fprintf ( fidTeX , ' \\caption{Impulse response functions (orthogonalized shock to $%s$).}' , titTeX { i } ) ;
2009-12-16 18:17:34 +01:00
end
2017-10-10 10:05:59 +02:00
fprintf ( fidTeX , ' \\label{Fig:IRF:%s:%s}\n' , tit { i } , int2str ( nbplt ) ) ;
2009-12-16 18:17:34 +01:00
fprintf ( fidTeX , ' \\end{figure}\n' ) ;
fprintf ( fidTeX , ' \n' ) ;
end
end
end
end
2011-02-09 15:21:03 +01:00
end
2015-05-12 08:53:57 +02:00
if TeX && any ( strcmp ( ' eps' , cellstr ( options_ . graph_format ) ) )
2011-02-09 15:21:03 +01:00
fprintf ( fidTeX , ' \n' ) ;
fprintf ( fidTeX , ' %% End Of TeX file. \n' ) ;
fclose ( fidTeX ) ;
2005-09-11 11:43:58 +02:00
end
2009-12-16 18:17:34 +01:00
end
2006-05-24 18:46:32 +02:00
2019-03-19 14:26:16 +01:00
if options_ . SpectralDensity . trigger
2015-08-04 08:45:55 +02:00
[ oo_ ] = UnivariateSpectralDensity ( M_ , oo_ , options_ , var_list ) ;
2009-12-16 18:17:34 +01:00
end
2007-01-22 17:34:54 +01:00
2006-11-18 08:37:22 +01:00
options_ = options_old ;
2010-03-25 11:20:34 +01:00
% temporary fix waiting for local options
2011-12-10 20:10:31 +01:00
options_ . partial_information = 0 ;
2020-03-03 11:45:38 +01:00
oo_ . gui . ran_stoch_simul = true ;