New option “filtered_theoretical_moments_grid”, that supersedes “hp_ngrid”

The old option is left for backward-compatibility purposes, but it has the same
effect as the new one.

Closes: #1093
parent 2fb18bba
......@@ -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.
......
......@@ -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*
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......
Subproject commit e9049aa81f085795ea11e3f4132f101d341e7d91
Subproject commit 1c44baea0575e30416fcf85830f7e3b2156bc874
......@@ -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);
......
......@@ -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_;
......
......@@ -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);
......@@ -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));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment