Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dynare
dynare
Commits
3d6c1845
Commit
3d6c1845
authored
Apr 15, 2016
by
MichelJuillard
Browse files
Merge pull request #1168 from JohannesPfeifer/filter_tests
Improve speed of filtering unit tests and clean up setting of options
parents
a047b42d
3542d086
Changes
4
Hide whitespace changes
Inline
Side-by-side
matlab/disp_moments.m
View file @
3d6c1845
...
...
@@ -189,7 +189,7 @@ elseif ~options_.hp_filter && options_.one_sided_hp_filter && ~options_.bandpass
[
hptrend
,
y
]
=
one_sided_hp_filter
(
y
,
options_
.
one_sided_hp_filter
);
elseif
~
options_
.
hp_filter
&&
~
options_
.
one_sided_hp_filter
&&
options_
.
bandpass
.
indicator
data_temp
=
dseries
(
y
,
'0q1'
);
data_temp
=
baxter_king_filter
(
data_temp
,
options_
.
bandpass
.
passband
(
1
),
options_
.
bandpass
.
passband
(
2
),
12
);
data_temp
=
baxter_king_filter
(
data_temp
,
options_
.
bandpass
.
passband
(
1
),
options_
.
bandpass
.
passband
(
2
),
options_
.
bandpass
.
K
);
y
=
data_temp
.
data
;
elseif
~
options_
.
hp_filter
&&
~
options_
.
one_sided_hp_filter
&&
~
options_
.
bandpass
.
indicator
y
=
bsxfun
(
@
minus
,
y
,
m
);
...
...
matlab/global_initialization.m
View file @
3d6c1845
...
...
@@ -169,6 +169,7 @@ options_.nofunctions = false;
options_
.
bandpass
.
indicator
=
0
;
options_
.
bandpass
.
passband
=
[
6
;
32
];
options_
.
bandpass
.
K
=
12
;
% Extended path options
%
...
...
tests/moments/example1_bp_test.mod
View file @
3d6c1845
...
...
@@ -29,9 +29,9 @@ varexo e, u;
parameters beta, rho, alpha, delta, theta, psi, tau;
alpha = 0.36;
rho = 0.
9
5;
rho = 0.5;
tau = 0.025;
beta = 0.9
9
;
beta = 0.9
8
;
delta = 0.025;
psi = 0;
theta = 2.95;
...
...
@@ -84,7 +84,7 @@ stoch_simul(order=1,nofunctions,irf=0,periods=0);
oo_filtered_one_shock_theoretical=oo_;
stoch_simul(order=1,nofunctions,periods=
5
000000);
stoch_simul(order=1,nofunctions,periods=
1
000000);
oo_filtered_one_shock_simulated=oo_;
...
...
@@ -92,11 +92,11 @@ if max(abs((1-diag(oo_filtered_one_shock_simulated.var)./(diag(oo_filtered_all_s
error('Variance Decomposition wrong')
end
if max(max(abs(oo_filtered_all_shocks_simulated.var-oo_filtered_all_shocks_theoretical.var)))>
2
e-4;
if max(max(abs(oo_filtered_all_shocks_simulated.var-oo_filtered_all_shocks_theoretical.var)))>
5
e-4;
error('Covariance wrong')
end
if max(max(abs(oo_filtered_one_shock_simulated.var-oo_filtered_one_shock_theoretical.var)))>
1
e-4;
if max(max(abs(oo_filtered_one_shock_simulated.var-oo_filtered_one_shock_theoretical.var)))>
5
e-4;
error('Covariance wrong')
end
...
...
@@ -107,10 +107,10 @@ for ii=1:options_.ar
autocorr_model_one_shock_theoretical(:,ii)=diag(oo_filtered_one_shock_theoretical.autocorr{ii});
end
if max(max(abs(autocorr_model_all_shocks_simulated-autocorr_model_all_shocks_theoretical)))>
2e-2
;
if max(max(abs(autocorr_model_all_shocks_simulated-autocorr_model_all_shocks_theoretical)))>
0.05
;
error('Correlation wrong')
end
if max(max(abs(autocorr_model_one_shock_simulated-autocorr_model_one_shock_theoretical)))>
2e-2
;
if max(max(abs(autocorr_model_one_shock_simulated-autocorr_model_one_shock_theoretical)))>
0.05
;
error('Correlation wrong')
end
tests/moments/example1_hp_test.mod
View file @
3d6c1845
...
...
@@ -66,16 +66,13 @@ var e, u = phi*0.009*0.009;
end;
steady(solve_algo=4,maxit=1000);
options_.hp_ngrid=2048*4;
options_.bandpass.indicator=0;
options_.bandpass.passband=[6 32];
stoch_simul(order=1,nofunctions,hp_filter=1600,irf=0);
stoch_simul(order=1,nofunctions,hp_filter=1600,irf=0
,hp_ngrid=8192
);
total_var_filtered=diag(oo_.var);
oo_filtered_all_shocks=oo_;
stoch_simul(order=1,nofunctions,hp_filter=0,periods=5
0
00000,nomoments);
stoch_simul(order=1,nofunctions,hp_filter=0,periods=
2
500000,nomoments);
options_.nomoments=0;
oo_unfiltered_all_shocks=oo_;
...
...
@@ -87,8 +84,8 @@ oo_unfiltered_all_shocks=oo_;
[junk, b_filtered]=sample_hp_filter(b,1600);
verbatim;
total_std_all_shocks_filtered_sim=std([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered])
cov_filtered_all_shocks=cov([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered])
total_std_all_shocks_filtered_sim=std([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered])
;
cov_filtered_all_shocks=cov([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered])
;
acf = zeros(6);
[junk, acf(:,1)] = sample_autocovariance([y_filtered ],5);
[junk, acf(:,2)] = sample_autocovariance([c_filtered ],5);
...
...
@@ -110,7 +107,7 @@ stoch_simul(order=1,nofunctions,hp_filter=1600,irf=0,periods=0);
total_var_filtered_one_shock=diag(oo_.var);
oo_filtered_one_shock=oo_;
stoch_simul(order=1,nofunctions,hp_filter=0,periods=5
0
00000,nomoments);
stoch_simul(order=1,nofunctions,hp_filter=0,periods=
2
500000,nomoments);
oo_unfiltered_one_shock=oo_;
[junk, y_filtered]=sample_hp_filter(y,1600);
...
...
@@ -121,8 +118,8 @@ oo_unfiltered_one_shock=oo_;
[junk, b_filtered]=sample_hp_filter(b,1600);
verbatim;
total_std_one_shock_filtered_sim=std([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered])
cov_filtered_one_shock=cov([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered])
total_std_one_shock_filtered_sim=std([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered])
;
cov_filtered_one_shock=cov([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered])
;
acf = zeros(6);
[junk, acf(:,1)] = sample_autocovariance([y_filtered ],5);
[junk, acf(:,2)] = sample_autocovariance([c_filtered ],5);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment