Commit 31349d0b authored by MichelJuillard's avatar MichelJuillard

adding new test

parent f0efbee2
......@@ -150,7 +150,22 @@ EXTRA_DIST = \
ms-sbvar/archive-files/ftd_upperchol7v.m \
ms-sbvar/archive-files/specification_2v.dat \
ms-sbvar/archive-files/specification_2v2c.dat \
recursive/data_ca1.m
recursive/data_ca1.m \
kalman_filter_smoother/algo1.mod \
kalman_filter_smoother/algo2.mod \
kalman_filter_smoother/algo3.mod \
kalman_filter_smoother/algo4.mod \
kalman_filter_smoother/algo4a.mod \
kalman_filter_smoother/algo4b.mod \
kalman_filter_smoother/algoH1.mod \
kalman_filter_smoother/algoH2.mod \
kalman_filter_smoother/algoH3.mod \
kalman_filter_smoother/fs2000.mod \
kalman_filter_smoother/fs2000_1.mod \
kalman_filter_smoother/fs2000_2.mod \
kalman_filter_smoother/fs2000a.mod \
kalman_filter_smoother/gen_data.mod \
kalman_filter_smoother/fsdat_simul.m
TARGETS =
......
......@@ -32,7 +32,6 @@ end;
varobs dw dx dy z;
//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0);
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo1_mode);
//checking smoother consistency
......@@ -46,8 +45,12 @@ err = zeros(6,200);
for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end;
disp(max(max(abs(err))));
if max(max(abs(err))) > 1e-10;
error('Test fails')
endif;
d=load('data');
dat = [d.dw d.dx d.dy d.z];
disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])))));
\ No newline at end of file
if max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])))) > 1e-10;
error('Test fails');
end;
\ No newline at end of file
......@@ -32,7 +32,6 @@ end;
varobs dw dx dy z;
//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,kalman_algo=2);
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo1_mode,kalman_algo=2);
//checking smoother consistency
......@@ -46,11 +45,15 @@ err = zeros(6,200);
for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end;
disp(max(max(abs(err))));
if max(max(abs(err))) > 1e-10;
error('Test fails');
end;
d=load('data');
dat = [d.dw d.dx d.dy d.z];
disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])))));
if max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])))) > 1e-10;
error('Test fails');
end;
o1 = load('algo1_results');
obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'};
......@@ -64,7 +67,9 @@ for i=1:nobj_endo;
var2 = eval(['oo_.' obj_endo{i} '.' M_.endo_names(j,:)]);
err_endo(:,j) = var1-var2;
end;
disp(max(max(abs(err_endo))));
if max(max(abs(err_endo))) > 1e-10;
error('Test fails');
end;
end;
......@@ -76,6 +81,7 @@ for i=1:nobj_exo;
var2 = eval(['oo_.' obj_exo{i} '.' M_.exo_names(j,:)]);
err_exo(:,j,i) = var1 - var2;
end;
disp(max(max(abs(err_exo))));
if max(max(abs(err_exo))) > 1e-10;
error('Test fails')
end;
end;
disp(max(max(max(abs(err_exo)))));
......@@ -36,7 +36,6 @@ end;
varobs w x y;
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,diffuse_filter);
//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo3_mode,diffuse_filter);
//checking smoother consistency
X = oo_.SmoothedVariables;
......@@ -49,8 +48,12 @@ err = zeros(M_.endo_nbr,200);
for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end;
disp(max(max(abs(err))));
if max(max(abs(err))) > 1e-10;
error('Test fails');
end;
d=load('data');
dat = [d.w d.x d.y];
disp(max(max(abs(dat(1000:1199,:)-S(:,[7:9])))));
\ No newline at end of file
if max(max(abs(dat(1000:1199,:)-S(:,[7:9])))) > 1e-10;
error('Test fails');
end;
......@@ -35,7 +35,6 @@ end;
varobs w x y;
//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,diffuse_filter);
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo3_mode,diffuse_filter,kalman_algo=4);
//checking smoother consistency
......@@ -49,11 +48,15 @@ err = zeros(M_.endo_nbr,200);
for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end;
disp(max(max(abs(err))));
if max(max(abs(err))) > 1e-10;
error('Test fails');
end;
d=load('data');
dat = [d.w d.x d.y];
disp(max(max(abs(dat(1000:1199,:)-S(:,[7:9])))));
if max(max(abs(dat(1000:1199,:)-S(:,[7:9])))) > 1e-10;
error('Test fails');
end;
o1 = load('algo3_results');
obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'};
......@@ -67,7 +70,9 @@ for i=1:nobj_endo;
var2 = eval(['oo_.' obj_endo{i} '.' M_.endo_names(j,:)]);
err_endo(:,j) = var1-var2;
end;
disp(max(max(abs(err_endo))));
if max(max(abs(err_endo))) > 1e-10;
error('Test fails');
end;
end;
......@@ -79,6 +84,8 @@ for i=1:nobj_exo;
var2 = eval(['oo_.' obj_exo{i} '.' M_.exo_names(j,:)]);
err_exo(:,j,i) = var1 - var2;
end;
disp(max(max(abs(err_exo))));
if max(max(abs(err_exo))) > 1e-10;
error('Test fails');
end;
end;
disp(max(max(max(abs(err_exo)))));
......@@ -47,8 +47,12 @@ err = zeros(M_.endo_nbr,200);
for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end;
disp(max(max(abs(err))));
if max(max(abs(err))) > 1e-10;
error('Test fails');
end;
d=load('data');
dat = [d.dw d.dx d.y d.z];
disp(max(max(abs(dat(1000:1199,:)-S(:,[2 3 7 1])))));
\ No newline at end of file
if max(max(abs(dat(1000:1199,:)-S(:,[2 3 7 1])))) > 1e-10;
error('Test fails');
end;
var z dw dx dy dc1 dc2 y;
varexo e_w e_x e_y e_z;
parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c;
model(linear);
dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w;
dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x;
dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y;
z = rho_z*z(-1)+dw-dx+e_z;
dc1 = dc1(-1)+dx-b*dy-c*dw;
dc2 = dc2(-1)+dx-b*dy;
y = y(-1) + dy;
end;
estimated_params;
rho_w, normal_pdf, 0.5,0.2;
rho_x, normal_pdf, 0.5,0.2;
rho_y, normal_pdf, 0.5,0.2;
rho_z, normal_pdf, 0.8,0.2;
a1, normal_pdf, 0.1,0.2;
a2, normal_pdf, -0.1,0.2;
a3, normal_pdf, 0.1,0.2;
b , normal_pdf, 1,0.2;
c , normal_pdf, 1,0.2;
stderr e_w, uniform_pdf,,, 0.01, 0.1;
stderr e_x, uniform_pdf,,, 0.01, 0.1;
stderr e_y, uniform_pdf,,, 0.01, 0.1;
stderr e_z, uniform_pdf,,, 0.01, 0.1;
end;
varobs dw dx y z;
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,diffuse_filter);
//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo3_mode,diffuse_filter);
//checking smoother consistency
X = oo_.SmoothedVariables;
S = [X.z X.dw X.dx X.dy X.dc1 X.dc2 X.y];
X = oo_.SmoothedShocks;
E = [X.e_w X.e_x X.e_y X.e_z];
A = oo_.dr.ghx;
B = oo_.dr.ghu;
err = zeros(M_.endo_nbr,200);
for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end;
if max(max(abs(err))) > 1e-10;
error('Test fails');
end;
d=load('data');
dat = [d.dw d.dx d.y d.z];
if max(max(abs(dat(1000:1199,:)-S(:,[2 3 7 1])))) > 1e-10;
error('Test fails');
end;
......@@ -47,10 +47,14 @@ err = zeros(6,200);
for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end;
disp(max(max(abs(err))));
if max(max(abs(err))) > 1e-10;
error('Test fails');
end;
d=load('data');
dat = [d.dw d.dx d.dy d.z];
X = oo_.SmoothedMeasurementErrors;
ME = [X.dw X.dx X.dy X.z];
disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])-ME))));
\ No newline at end of file
if max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])-ME))) > 1e-10;
error('Test fails');
end;
......@@ -34,7 +34,6 @@ end;
varobs dw dx dy z;
//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,kalman_algo=2);
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algoH1_mode,kalman_algo=2,filtered_vars);
//checking smoother consistency
......@@ -68,7 +67,9 @@ for i=1:nobj_endo;
var2 = eval(['oo_.' obj_endo{i} '.' M_.endo_names(j,:)]);
err_endo(:,j) = var1-var2;
end;
disp(max(max(abs(err_endo))));
if max(max(abs(err_endo))) > 1e-10;
error('Test fails');
end;
end;
......@@ -80,8 +81,11 @@ for i=1:nobj_exo;
var2 = eval(['oo_.' obj_exo{i} '.' M_.exo_names(j,:)]);
err_exo(:,j,i) = var1 - var2;
end;
disp(max(max(abs(err_exo))));
if max(max(abs(err_exo))) > 1e-10;
error('Test fails');
end;
end;
disp(max(max(max(abs(err_exo)))));
disp(max(max(abs(o1.oo_.SmoothedMeasurementErrors.z - oo_.SmoothedMeasurementErrors.z))));
\ No newline at end of file
if max(max(abs(o1.oo_.SmoothedMeasurementErrors.z - oo_.SmoothedMeasurementErrors.z))) > 1e-10;
error('Test fails');
end;
\ No newline at end of file
......@@ -38,7 +38,6 @@ end;
varobs w x y;
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,diffuse_filter);
//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo3_mode,diffuse_filter);
stoch_simul(irf=0);
......@@ -53,10 +52,14 @@ err = zeros(M_.endo_nbr,200);
for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end;
disp(max(max(abs(err))));
if max(max(abs(err))) > 1e-10;
error('Test fails');
end;
d=load('data');
dat = [d.w d.x d.y];
X = oo_.SmoothedMeasurementErrors;
ME = [X.w X.x X.y];
disp(max(max(abs(dat(1000:1199,:)-S(:,[7:9])-ME))));
\ No newline at end of file
if max(max(abs(dat(1000:1199,:)-S(:,[7:9])-ME))) > 1E-10;
error('Test fails');
end;
// See fs2000.mod in the examples/ directory for details on the model
var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m;
parameters alp bet gam mst rho psi del;
alp = 0.33;
bet = 0.99;
gam = 0.003;
mst = 1.011;
rho = 0.7;
psi = 0.787;
del = 0.02;
model;
dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
-P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m;
m-1+d = l;
e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA;
end;
initval;
k = 6;
m = mst;
P = 2.25;
c = 0.45;
e = 1;
W = 4;
R = 1.02;
d = 0.85;
n = 0.19;
l = 0.86;
y = 0.6;
gy_obs = exp(gam);
gp_obs = exp(-gam);
dA = exp(gam);
end;
shocks;
var e_a; stderr 0.014;
var e_m; stderr 0.005;
end;
steady;
check;
estimated_params;
alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007;
rho, beta_pdf, 0.129, 0.223;
psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005;
stderr e_a, inv_gamma_pdf, 0.035449, inf;
stderr e_m, inv_gamma_pdf, 0.008862, inf;
end;
varobs gp_obs gy_obs;
//estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=2000,mh_nblocks=2,mh_jscale=0.8,mode_check);
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=0,mode_compute=0);
// See fs2000.mod in the examples/ directory for details on the model
// For initial value of the parameter, the filter reaches steady state at period 137
var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m;
parameters alp bet gam mst rho psi del;
alp = 0.33;
bet = 0.99;
gam = 0.003;
mst = 1.011;
rho = 0.7;
psi = 0.787;
del = 0.02;
model;
dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
-P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m;
m-1+d = l;
e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA;
end;
initval;
k = 6;
m = mst;
P = 2.25;
c = 0.45;
e = 1;
W = 4;
R = 1.02;
d = 0.85;
n = 0.19;
l = 0.86;
y = 0.6;
gy_obs = exp(gam);
gp_obs = exp(-gam);
dA = exp(gam);
end;
shocks;
var e_a; stderr 0.014;
var e_m; stderr 0.005;
end;
steady;
check;
estimated_params;
alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007;
rho, beta_pdf, 0.129, 0.223;
psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005;
stderr e_a, inv_gamma_pdf, 0.035449, inf;
stderr e_m, inv_gamma_pdf, 0.008862, inf;
end;
varobs gp_obs gy_obs;
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=0,mode_compute=0);
// See fs2000.mod in the examples/ directory for details on the model
// For initial value of the parameter, the filter reaches steady state at period 137
var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m;
parameters alp bet gam mst rho psi del;
alp = 0.33;
bet = 0.99;
gam = 0.003;
mst = 1.011;
rho = 0.7;
psi = 0.787;
del = 0.02;
model;
dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
-P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m;
m-1+d = l;
e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA;
end;
initval;
k = 6;
m = mst;
P = 2.25;
c = 0.45;
e = 1;
W = 4;
R = 1.02;
d = 0.85;
n = 0.19;
l = 0.86;
y = 0.6;
gy_obs = exp(gam);
gp_obs = exp(-gam);
dA = exp(gam);
end;
shocks;
var e_a; stderr 0.014;
var e_m; stderr 0.005;
end;
steady;
check;
estimated_params;
alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007;
rho, beta_pdf, 0.129, 0.223;
psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005;
stderr e_a, inv_gamma_pdf, 0.035449, inf;
stderr e_m, inv_gamma_pdf, 0.008862, inf;
end;
varobs gp_obs gy_obs;
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=0,mode_compute=0,kalman_algo=2);
// See fs2000.mod in the examples/ directory for details on the model
// This version estimates the model in level rather than in growth rates
var m P c e W R k d n l gy_obs gp_obs Y_obs P_obs y dA;
varexo e_a e_m;
parameters alp bet gam mst rho psi del;
alp = 0.33;
bet = 0.99;
gam = 0.003;
mst = 1.011;
rho = 0.7;
psi = 0.787;
del = 0.02;
model;
dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
-P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m;
m-1+d = l;
e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA;
Y_obs/Y_obs(-1) = gy_obs;
P_obs/P_obs(-1) = gp_obs;
end;
initval;
k = 6;
m = mst;
P = 2.25;
c = 0.45;
e = 1;
W = 4;
R = 1.02;
d = 0.85;
n = 0.19;
l = 0.86;
y = 0.6;
gy_obs = exp(gam);
gp_obs = exp(-gam);
dA = exp(gam);
end;
shocks;
var e_a; stderr 0.014;
var e_m; stderr 0.005;
end;
unit_root_vars P_obs Y_obs;
steady;
check;
estimated_params;
alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007;
rho, beta_pdf, 0.129, 0.223;
psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005;
stderr e_a, inv_gamma_pdf, 0.035449, inf;
stderr e_m, inv_gamma_pdf, 0.008862, inf;
end;
varobs P_obs Y_obs;
observation_trends;
P_obs (log(mst)-gam);
Y_obs (gam);
end;
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=0,
mode_compute=0,mh_nblocks=2,mh_drop=0.45,mh_jscale=0.65,diffuse_filter,smoother) P_obs gp_obs gy_obs;
This diff is collapsed.
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