From aff80b4ee30fe491b4917572ef9b0bd6e178ab86 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Fri, 15 Apr 2016 09:16:33 +0200 Subject: [PATCH] Improve speed of filtering unit tests and clean up setting of options --- tests/moments/example1_bp_test.mod | 14 +++++++------- tests/moments/example1_hp_test.mod | 17 +++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/tests/moments/example1_bp_test.mod b/tests/moments/example1_bp_test.mod index 5dfca6446..43c2c8747 100644 --- a/tests/moments/example1_bp_test.mod +++ b/tests/moments/example1_bp_test.mod @@ -29,9 +29,9 @@ varexo e, u; parameters beta, rho, alpha, delta, theta, psi, tau; alpha = 0.36; -rho = 0.95; +rho = 0.5; tau = 0.025; -beta = 0.99; +beta = 0.98; 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=5000000); +stoch_simul(order=1,nofunctions,periods=1000000); 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)))>2e-4; +if max(max(abs(oo_filtered_all_shocks_simulated.var-oo_filtered_all_shocks_theoretical.var)))>5e-4; error('Covariance wrong') end -if max(max(abs(oo_filtered_one_shock_simulated.var-oo_filtered_one_shock_theoretical.var)))>1e-4; +if max(max(abs(oo_filtered_one_shock_simulated.var-oo_filtered_one_shock_theoretical.var)))>5e-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 diff --git a/tests/moments/example1_hp_test.mod b/tests/moments/example1_hp_test.mod index 718db4417..d2ae7a4eb 100644 --- a/tests/moments/example1_hp_test.mod +++ b/tests/moments/example1_hp_test.mod @@ -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=5000000,nomoments); +stoch_simul(order=1,nofunctions,hp_filter=0,periods=2500000,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=5000000,nomoments); +stoch_simul(order=1,nofunctions,hp_filter=0,periods=2500000,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);