Improve speed of filtering unit tests and clean up setting of options

time-shift
Johannes Pfeifer 2016-04-15 09:16:33 +02:00
parent 010b28e237
commit aff80b4ee3
2 changed files with 14 additions and 17 deletions

View File

@ -29,9 +29,9 @@ varexo e, u;
parameters beta, rho, alpha, delta, theta, psi, tau; parameters beta, rho, alpha, delta, theta, psi, tau;
alpha = 0.36; alpha = 0.36;
rho = 0.95; rho = 0.5;
tau = 0.025; tau = 0.025;
beta = 0.99; beta = 0.98;
delta = 0.025; delta = 0.025;
psi = 0; psi = 0;
theta = 2.95; theta = 2.95;
@ -84,7 +84,7 @@ stoch_simul(order=1,nofunctions,irf=0,periods=0);
oo_filtered_one_shock_theoretical=oo_; 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_; 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') error('Variance Decomposition wrong')
end 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') error('Covariance wrong')
end 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') error('Covariance wrong')
end end
@ -107,10 +107,10 @@ for ii=1:options_.ar
autocorr_model_one_shock_theoretical(:,ii)=diag(oo_filtered_one_shock_theoretical.autocorr{ii}); autocorr_model_one_shock_theoretical(:,ii)=diag(oo_filtered_one_shock_theoretical.autocorr{ii});
end 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') error('Correlation wrong')
end 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') error('Correlation wrong')
end end

View File

@ -66,16 +66,13 @@ var e, u = phi*0.009*0.009;
end; end;
steady(solve_algo=4,maxit=1000); 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); total_var_filtered=diag(oo_.var);
oo_filtered_all_shocks=oo_; 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; options_.nomoments=0;
oo_unfiltered_all_shocks=oo_; oo_unfiltered_all_shocks=oo_;
@ -87,8 +84,8 @@ oo_unfiltered_all_shocks=oo_;
[junk, b_filtered]=sample_hp_filter(b,1600); [junk, b_filtered]=sample_hp_filter(b,1600);
verbatim; verbatim;
total_std_all_shocks_filtered_sim=std([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]) cov_filtered_all_shocks=cov([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered]);
acf = zeros(6); acf = zeros(6);
[junk, acf(:,1)] = sample_autocovariance([y_filtered ],5); [junk, acf(:,1)] = sample_autocovariance([y_filtered ],5);
[junk, acf(:,2)] = sample_autocovariance([c_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); total_var_filtered_one_shock=diag(oo_.var);
oo_filtered_one_shock=oo_; 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_; oo_unfiltered_one_shock=oo_;
[junk, y_filtered]=sample_hp_filter(y,1600); [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); [junk, b_filtered]=sample_hp_filter(b,1600);
verbatim; verbatim;
total_std_one_shock_filtered_sim=std([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]) cov_filtered_one_shock=cov([y_filtered c_filtered k_filtered a_filtered h_filtered b_filtered]);
acf = zeros(6); acf = zeros(6);
[junk, acf(:,1)] = sample_autocovariance([y_filtered ],5); [junk, acf(:,1)] = sample_autocovariance([y_filtered ],5);
[junk, acf(:,2)] = sample_autocovariance([c_filtered ],5); [junk, acf(:,2)] = sample_autocovariance([c_filtered ],5);