From f2cde3b6d97be71cb2246333e4564c049281be88 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Thu, 17 Dec 2020 10:12:21 +0100 Subject: [PATCH] Make schur_vec_tol settable and document it Related to https://git.dynare.org/Dynare/preprocessor/-/merge_requests/29 Also convert it to lowercase as all other options --- doc/manual/source/the-model-file.rst | 6 ++++++ matlab/UnivariateSpectralDensity.m | 2 +- matlab/default_option_values.m | 2 +- matlab/dynare_identification.m | 4 +++- matlab/get_variance_of_endogenous_variables.m | 2 +- matlab/pruned_state_space_system.m | 2 +- matlab/th_autocovariances.m | 4 ++-- 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index d5f6e6e01..105764c46 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -9829,6 +9829,12 @@ Performing identification analysis Tolerance level for selecting non-zero singular values. Default: ``1.e-3``. + .. option:: schur_vec_tol = DOUBLE + + Tolerance level used to find nonstationary variables in Schur decomposition + of the transition matrix. + Default: ``1.e-11``. + *Identification Strength Options* .. option:: no_identification_strength diff --git a/matlab/UnivariateSpectralDensity.m b/matlab/UnivariateSpectralDensity.m index 1c04d622d..e58077afc 100644 --- a/matlab/UnivariateSpectralDensity.m +++ b/matlab/UnivariateSpectralDensity.m @@ -98,7 +98,7 @@ end [vx, u] = lyapunov_symm(A,B*M_.Sigma_e*B',options_.lyapunov_fixed_point_tol,options_.qz_criterium,options_.lyapunov_complex_threshold,[],options_.debug); iky = iv(ivar); if ~isempty(u) - iky = iky(find(any(abs(ghx(iky,:)*u) < options_.Schur_vec_tol,2))); + iky = iky(find(any(abs(ghx(iky,:)*u) < options_.schur_vec_tol,2))); ivar = oo_.dr.order_var(iky); end diff --git a/matlab/default_option_values.m b/matlab/default_option_values.m index 8ecb60e92..0254bcf24 100644 --- a/matlab/default_option_values.m +++ b/matlab/default_option_values.m @@ -46,7 +46,7 @@ options_.gstep(2) = 1.0; options_.scalv = 1; options_.debug = false; options_.initval_file = false; -options_.Schur_vec_tol = 1e-11; % used to find nonstationary variables in Schur decomposition of the +options_.schur_vec_tol = 1e-11; % used to find nonstationary variables in Schur decomposition of the % transition matrix options_.qz_criterium = []; options_.qz_zero_threshold = 1e-6; diff --git a/matlab/dynare_identification.m b/matlab/dynare_identification.m index 063f4e451..c843f1b80 100644 --- a/matlab/dynare_identification.m +++ b/matlab/dynare_identification.m @@ -139,6 +139,8 @@ options_ident = set_default_option(options_ident,'tol_deriv',1.e-8); % tolerance level for selecting columns of non-zero derivatives options_ident = set_default_option(options_ident,'tol_sv',1.e-3); % tolerance level for selecting non-zero singular values in identification_checks.m +options_ident = set_default_option(options_ident,'schur_vec_tol',1e-11); + % tolerance level used to find nonstationary variables in Schur decomposition of the transition matrix. %check whether to compute identification strength based on information matrix if ~isfield(options_ident,'no_identification_strength') @@ -289,7 +291,7 @@ if options_ident.order == 3 end options_.ar = options_ident.ar; options_.prior_mc = options_ident.prior_mc; -options_.Schur_vec_tol = 1.e-8; +options_.schur_vec_tol = options_ident.schur_vec_tol; options_.nomoments = 0; options_.analytic_derivation=options_ident.analytic_derivation; % 1: analytic derivation of gradient and hessian of likelihood in dsge_likelihood.m, only works for stationary models, i.e. kalman_algo<3 diff --git a/matlab/get_variance_of_endogenous_variables.m b/matlab/get_variance_of_endogenous_variables.m index 965319b1b..02ea62d6b 100644 --- a/matlab/get_variance_of_endogenous_variables.m +++ b/matlab/get_variance_of_endogenous_variables.m @@ -48,7 +48,7 @@ n = length(i_var); [vx,u] = lyapunov_symm(A,B*Sigma_e*B',options_.lyapunov_fixed_point_tol,options_.qz_criterium,options_.lyapunov_complex_threshold, [], options_.debug); if size(u,2) > 0 - i_stat = find(any(abs(ghx*u) < options_.Schur_vec_tol,2)); %only set those variances of objective function for which variance is finite + i_stat = find(any(abs(ghx*u) < options_.schur_vec_tol,2)); %only set those variances of objective function for which variance is finite ghx = ghx(i_stat,:); ghu = ghu(i_stat,:); else diff --git a/matlab/pruned_state_space_system.m b/matlab/pruned_state_space_system.m index 1f180b9ae..c4022c7db 100644 --- a/matlab/pruned_state_space_system.m +++ b/matlab/pruned_state_space_system.m @@ -372,7 +372,7 @@ stationary_vars = (1:y_nbr)'; if ~isempty(Schur_u) %base this only on first order, because if first-order is stable so are the higher-order pruned systems x = abs(gx*Schur_u); - stationary_vars = find(all(x < options.Schur_vec_tol,2)); + stationary_vars = find(all(x < options.schur_vec_tol,2)); end if compute_derivs == 1 diff --git a/matlab/th_autocovariances.m b/matlab/th_autocovariances.m index 66169d4a8..29b70ff50 100644 --- a/matlab/th_autocovariances.m +++ b/matlab/th_autocovariances.m @@ -143,8 +143,8 @@ if local_order == 2 || options_.hp_filter == 0 stationary_vars = (1:length(ivar))'; if ~isempty(u) x = abs(ghx*u); - iky = iky(find(all(x(iky,:) < options_.Schur_vec_tol,2))); - stationary_vars = find(all(x(inv_order_var(ivar(stationary_vars)),:) < options_.Schur_vec_tol,2)); + iky = iky(find(all(x(iky,:) < options_.schur_vec_tol,2))); + stationary_vars = find(all(x(inv_order_var(ivar(stationary_vars)),:) < options_.schur_vec_tol,2)); end aa = ghx(iky,:); bb = ghu(iky,:);