diff --git a/doc/manual/source/index.rst b/doc/manual/source/index.rst index d707b92f6408642116879cebcb3c60f714755b2d..2df8469ff13979e968b830c8e4ab6350a4aec1f1 100644 --- a/doc/manual/source/index.rst +++ b/doc/manual/source/index.rst @@ -25,7 +25,7 @@ The following people used to be members of the team: * Stéphane Lhuissier * George Perendia -Copyright © 1996-2019, Dynare Team. +Copyright © 1996-2020, Dynare Team. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 323b4b2169ede302631eaa9d283b3306dc70ad01..6a4717ae85da0c336daa960ab8e91c43cab9f69b 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -3073,13 +3073,6 @@ Computing the stochastic solution moments. This option is only available with simulated moments. Default: no filter. - .. option:: hp_ngrid = INTEGER - - Number of points in the grid for the discrete Inverse Fast - Fourier Transform used in the HP filter computation. It may be - necessary to increase it for highly autocorrelated - processes. Default: ``512``. - .. option:: bandpass_filter Uses a bandpass filter with the default passband before @@ -3095,6 +3088,14 @@ Computing the stochastic solution e.g. :math:`6` to :math:`32` quarters if the model frequency is quarterly. Default: ``[6,32]``. + .. option:: filtered_theoretical_moments_grid = INTEGER + + When computing filtered theoretical moments (with either option + ``hp_filter`` or option ``bandpass_filter``), this option governs the + number of points in the grid for the discrete Inverse Fast Fourier + Transform. It may be necessary to increase it for highly autocorrelated + processes. Default: ``512``. + .. option:: irf = INTEGER Number of periods on which to compute the IRFs. Setting @@ -3421,6 +3422,10 @@ Computing the stochastic solution stored in ´´oo_.SpectralDensity´´, defined below. Default: do not request spectral density estimates. + .. option:: hp_ngrid = INTEGER + + Deprecated option. It has the same effect as + :opt:`filtered_theoretical_moments_grid <filtered_theoretical_moments_grid = INTEGER>`. *Output* diff --git a/matlab/UnivariateSpectralDensity.m b/matlab/UnivariateSpectralDensity.m index b46bdfd9c6566063af7e13014ada2bc5850dd2f2..1c04d622d7a30611d42eabd08517f09bda504c50 100644 --- a/matlab/UnivariateSpectralDensity.m +++ b/matlab/UnivariateSpectralDensity.m @@ -19,7 +19,7 @@ function [oo_] = UnivariateSpectralDensity(M_,oo_,options_,var_list) % Adapted from th_autocovariances.m. -% Copyright (C) 2006-2018 Dynare Team +% Copyright (C) 2006-2020 Dynare Team % % This file is part of Dynare. % @@ -105,7 +105,7 @@ end iky = iv(ivar); aa = ghx(iky,:); bb = ghu(iky,:); -ngrid = options_.hp_ngrid; %number of grid points +ngrid = options_.filtered_theoretical_moments_grid; %number of grid points freqs = (0 : pi/(ngrid-1):pi)'; % grid on which to compute tpos = exp( sqrt(-1)*freqs); %positive frequencies tneg = exp(-sqrt(-1)*freqs); %negative frequencies diff --git a/matlab/default_option_values.m b/matlab/default_option_values.m index c64d246e851bfd6c2a4d177c9348af081b744d98..16e3bd4b80694cbd56abb25465bfc96ad1540ffb 100644 --- a/matlab/default_option_values.m +++ b/matlab/default_option_values.m @@ -12,7 +12,7 @@ function options_ = default_option_values(M_) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2018-2019 Dynare Team +% Copyright (C) 2018-2020 Dynare Team % % This file is part of Dynare. % @@ -155,7 +155,7 @@ options_.relative_irf = false; options_.ar = 5; options_.hp_filter = 0; options_.one_sided_hp_filter = 0; -options_.hp_ngrid = 512; +options_.filtered_theoretical_moments_grid = 512; options_.nodecomposition = false; options_.nomoments = false; options_.nocorr = false; diff --git a/matlab/th_autocovariances.m b/matlab/th_autocovariances.m index a095d64300963fd8c86b273820bd7783298402d2..66169d4a8e35b7794e0ea841c0fd875a8c2f5bff 100644 --- a/matlab/th_autocovariances.m +++ b/matlab/th_autocovariances.m @@ -42,7 +42,7 @@ function [Gamma_y,stationary_vars] = th_autocovariances(dr,ivar,M_,options_,node % E(x_t) = (I - {g_x}\right)^{- 1} 0.5\left( g_{\sigma\sigma} \sigma^2 + g_{xx} Var(\hat x_t) + g_{uu} Var(u_t) \right) % \] % -% Copyright (C) 2001-2019 Dynare Team +% Copyright (C) 2001-2020 Dynare Team % % This file is part of Dynare. % @@ -220,7 +220,7 @@ else% ==> Theoretical filters. bb = ghu(iky,:); %S in Uhlig (2001) lambda = options_.hp_filter; - ngrid = options_.hp_ngrid; + ngrid = options_.filtered_theoretical_moments_grid; freqs = 0 : ((2*pi)/ngrid) : (2*pi*(1 - .5/ngrid)); %[0,2*pi) tpos = exp( sqrt(-1)*freqs); %positive frequencies tneg = exp(-sqrt(-1)*freqs); %negative frequencies diff --git a/preprocessor b/preprocessor index 523e6bd0097dc948e704bac4dc24112a0639ca70..045e81d0d7ec1f4c82d7d8f73c36ad2213e6f3a6 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 523e6bd0097dc948e704bac4dc24112a0639ca70 +Subproject commit 045e81d0d7ec1f4c82d7d8f73c36ad2213e6f3a6 diff --git a/tests/moments/example1_bp_test.mod b/tests/moments/example1_bp_test.mod index 43c2c8747b390aae520492769ce5062dfeb31587..429040b1c55b3e8562fa4608b4b14c2ab1dacd3f 100644 --- a/tests/moments/example1_bp_test.mod +++ b/tests/moments/example1_bp_test.mod @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2001-2010 Dynare Team + * Copyright (C) 2001-2020 Dynare Team * * This file is part of Dynare. * @@ -67,7 +67,7 @@ end; steady(solve_algo=4,maxit=1000); -stoch_simul(order=1,nofunctions,irf=0,bandpass_filter=[6 32],hp_ngrid=8192); +stoch_simul(order=1,nofunctions,irf=0,bandpass_filter=[6 32],filtered_theoretical_moments_grid=8192); oo_filtered_all_shocks_theoretical=oo_; stoch_simul(order=1,nofunctions,periods=1000000); diff --git a/tests/moments/example1_hp_test.mod b/tests/moments/example1_hp_test.mod index d2ae7a4ebff3290cd8955ad6006060673519c65c..be200e60667f73cdf67487409fe333cc89c33789 100644 --- a/tests/moments/example1_hp_test.mod +++ b/tests/moments/example1_hp_test.mod @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2001-2010 Dynare Team + * Copyright (C) 2001-2020 Dynare Team * * This file is part of Dynare. * @@ -67,7 +67,7 @@ end; steady(solve_algo=4,maxit=1000); -stoch_simul(order=1,nofunctions,hp_filter=1600,irf=0,hp_ngrid=8192); +stoch_simul(order=1,nofunctions,hp_filter=1600,irf=0,filtered_theoretical_moments_grid=8192); total_var_filtered=diag(oo_.var); oo_filtered_all_shocks=oo_; diff --git a/tests/moments/example1_one_sided_hp_test.mod b/tests/moments/example1_one_sided_hp_test.mod index 9da0798b5f09e1b0075412bdd77e0b742d6fa0da..1e61f23d26ef407864f1dbfdecfc3bc95f944120 100644 --- a/tests/moments/example1_one_sided_hp_test.mod +++ b/tests/moments/example1_one_sided_hp_test.mod @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2001-2010 Dynare Team + * Copyright (C) 2001-2020 Dynare Team * * This file is part of Dynare. * @@ -66,6 +66,5 @@ var e, u = phi*0.009*0.009; end; steady(solve_algo=4,maxit=1000); -options_.hp_ngrid=2048*4; -stoch_simul(order=1,nofunctions,one_sided_hp_filter=1600,irf=0,periods=5000); \ No newline at end of file +stoch_simul(order=1,nofunctions,one_sided_hp_filter=1600,irf=0,periods=5000,filtered_theoretical_moments_grid=8192); diff --git a/tests/moments/test_AR1_spectral_density.mod b/tests/moments/test_AR1_spectral_density.mod index 334776b98b5115063aa240b92f450470b8184eba..3e95fd570559dc19ca727b47e9c2f7e2ce9a74e2 100644 --- a/tests/moments/test_AR1_spectral_density.mod +++ b/tests/moments/test_AR1_spectral_density.mod @@ -18,9 +18,8 @@ end; options_.SpectralDensity.trigger=1; options_.bandpass.indicator=0; -options_.hp_ngrid=2048; -stoch_simul(order=1,nofunctions,hp_filter=0,irf=0,periods=1000000); +stoch_simul(order=1,nofunctions,hp_filter=0,irf=0,periods=1000000,filtered_theoretical_moments_grid=2048); white_noise_sample=white_noise; @@ -50,7 +49,7 @@ end options_.hp_filter=0; stoch_simul(order=1,nofunctions,bandpass_filter=[6 32],irf=0); -theoretical_spectrum_white_noise=repmat(theoretical_spectrum_white_noise,1,options_.hp_ngrid); +theoretical_spectrum_white_noise=repmat(theoretical_spectrum_white_noise,1,options_.filtered_theoretical_moments_grid); passband=oo_.SpectralDensity.freqs>=2*pi/options_.bandpass.passband(2) & oo_.SpectralDensity.freqs<=2*pi/options_.bandpass.passband(1); if max(abs(oo_.SpectralDensity.density(strmatch('white_noise',M_.endo_names,'exact'),passband)-theoretical_spectrum_white_noise(passband)))>1e-10 error('Spectral Density is wrong') @@ -73,4 +72,4 @@ end % % % figure % % [pow,f]=psd(a_sample,1000,1,[],500); -% % plot(f(3:end)*2*pi,pow(3:end)/(2*pi)); \ No newline at end of file +% % plot(f(3:end)*2*pi,pow(3:end)/(2*pi));