Commit 3d6c1845 authored by MichelJuillard's avatar 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
......@@ -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);
......
......@@ -169,6 +169,7 @@ options_.nofunctions = false;
options_.bandpass.indicator = 0;
options_.bandpass.passband = [6; 32];
options_.bandpass.K=12;
% Extended path options
%
......
......@@ -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
......@@ -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);
......
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