Converted MOD test files to Unix newline convention

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3253 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
sebastien 2009-12-16 17:25:06 +00:00
parent c3d6567d30
commit 6c185e2c6b
85 changed files with 7629 additions and 7629 deletions

View File

@ -1,82 +1,82 @@
// This file replicates the estimation of the CIA model from // This file replicates the estimation of the CIA model from
// Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models" // Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models"
// Journal of Applied Econometrics, 15, 645-670. // Journal of Applied Econometrics, 15, 645-670.
// the data are the ones provided on Schorfheide's web site with the programs. // the data are the ones provided on Schorfheide's web site with the programs.
// http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP // http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP
// You need to have fsdat.m in the same directory as this file. // You need to have fsdat.m in the same directory as this file.
// This file replicates: // This file replicates:
// -the posterior mode as computed by Frank's Gauss programs // -the posterior mode as computed by Frank's Gauss programs
// -the parameter mean posterior estimates reported in the paper // -the parameter mean posterior estimates reported in the paper
// -the model probability (harmonic mean) reported in the paper // -the model probability (harmonic mean) reported in the paper
// This file was tested with dyn_mat_test_0218.zip // This file was tested with dyn_mat_test_0218.zip
// the smooth shocks are probably stil buggy // the smooth shocks are probably stil buggy
// //
// The equations are taken from J. Nason and T. Cogley (1994) // The equations are taken from J. Nason and T. Cogley (1994)
// "Testing the implications of long-run neutrality for monetary business // "Testing the implications of long-run neutrality for monetary business
// cycle models" Journal of Applied Econometrics, 9, S37-S70. // cycle models" Journal of Applied Econometrics, 9, S37-S70.
// Note that there is an initial minus sign missing in equation (A1), p. S63. // Note that there is an initial minus sign missing in equation (A1), p. S63.
// //
// Michel Juillard, February 2004 // Michel Juillard, February 2004
options_.usePartInfo=0; options_.usePartInfo=0;
var m P c e W R k d n l gy_obs gp_obs Y_obs P_obs y dA P2 c2; var m P c e W R k d n l gy_obs gp_obs Y_obs P_obs y dA P2 c2;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model ; model ;
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; 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)))))/(c2(+1)*P2(+1)*m(+1))=0; -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)))))/(c2(+1)*P2(+1)*m(+1))=0;
W = l/n; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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; 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); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
Y_obs/Y_obs(-1) = gy_obs; Y_obs/Y_obs(-1) = gy_obs;
P_obs/P_obs(-1) = gp_obs; P_obs/P_obs(-1) = gp_obs;
P2 = P(+1); P2 = P(+1);
c2 = c(+1); c2 = c(+1);
end; end;
initval; initval;
k = 6; k = 6;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
unit_root_vars P_obs Y_obs; unit_root_vars P_obs Y_obs;
steady; steady;
stoch_simul(order=1,irf=0); stoch_simul(order=1,irf=0);

View File

@ -1,90 +1,90 @@
// This file replicates the estimation of the CIA model from // This file replicates the estimation of the CIA model from
// Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models" // Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models"
// Journal of Applied Econometrics, 15, 645-670. // Journal of Applied Econometrics, 15, 645-670.
// the data are the ones provided on Schorfheide's web site with the programs. // the data are the ones provided on Schorfheide's web site with the programs.
// http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP // http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP
// You need to have fsdat.m in the same directory as this file. // You need to have fsdat.m in the same directory as this file.
// This file replicates: // This file replicates:
// -the posterior mode as computed by Frank's Gauss programs // -the posterior mode as computed by Frank's Gauss programs
// -the parameter mean posterior estimates reported in the paper // -the parameter mean posterior estimates reported in the paper
// -the model probability (harmonic mean) reported in the paper // -the model probability (harmonic mean) reported in the paper
// This file was tested with dyn_mat_test_0218.zip // This file was tested with dyn_mat_test_0218.zip
// the smooth shocks are probably stil buggy // the smooth shocks are probably stil buggy
// //
// The equations are taken from J. Nason and T. Cogley (1994) // The equations are taken from J. Nason and T. Cogley (1994)
// "Testing the implications of long-run neutrality for monetary business // "Testing the implications of long-run neutrality for monetary business
// cycle models" Journal of Applied Econometrics, 9, S37-S70. // cycle models" Journal of Applied Econometrics, 9, S37-S70.
// Note that there is an initial minus sign missing in equation (A1), p. S63. // Note that there is an initial minus sign missing in equation (A1), p. S63.
// //
// Michel Juillard, February 2004 // Michel Juillard, February 2004
options_.usePartInfo=0; options_.usePartInfo=0;
var m P c e W R k d n l gy_obs gp_obs Y_obs P_obs y dA P2 c2; var m P c e W R k d n l gy_obs gp_obs Y_obs P_obs y dA P2 c2;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model ; model ;
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; 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)))))/(c2(+1)*P2(+1)*m(+1))=0; -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)))))/(c2(+1)*P2(+1)*m(+1))=0;
W = l/n; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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; 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); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
Y_obs/Y_obs(-1) = gy_obs; Y_obs/Y_obs(-1) = gy_obs;
P_obs/P_obs(-1) = gp_obs; P_obs/P_obs(-1) = gp_obs;
P2 = P(+1); P2 = P(+1);
c2 = c(+1); c2 = c(+1);
end; end;
initval; initval;
k = 6; k = 6;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
unit_root_vars P_obs Y_obs; unit_root_vars P_obs Y_obs;
steady; steady;
stoch_simul(aim_solver, order=1, irf=0); stoch_simul(aim_solver, order=1, irf=0);
benchmark = load('fs2000_b1L1L_results'); benchmark = load('fs2000_b1L1L_results');
threshold = 1e-8; threshold = 1e-8;
if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold)); if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold));
error('error in ghx'); error('error in ghx');
elseif max(max(abs(benchmark.oo_.dr.ghu-oo_.dr.ghu) > threshold)); elseif max(max(abs(benchmark.oo_.dr.ghu-oo_.dr.ghu) > threshold));
error('error in ghy'); error('error in ghy');
end; end;

View File

@ -1,78 +1,78 @@
// This file replicates the estimation of the CIA model from // This file replicates the estimation of the CIA model from
// Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models" // Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models"
// Journal of Applied Econometrics, 15, 645-670. // Journal of Applied Econometrics, 15, 645-670.
// the data are the ones provided on Schorfheide's web site with the programs. // the data are the ones provided on Schorfheide's web site with the programs.
// http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP // http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP
// You need to have fsdat.m in the same directory as this file. // You need to have fsdat.m in the same directory as this file.
// This file replicates: // This file replicates:
// -the posterior mode as computed by Frank's Gauss programs // -the posterior mode as computed by Frank's Gauss programs
// -the parameter mean posterior estimates reported in the paper // -the parameter mean posterior estimates reported in the paper
// -the model probability (harmonic mean) reported in the paper // -the model probability (harmonic mean) reported in the paper
// This file was tested with dyn_mat_test_0218.zip // This file was tested with dyn_mat_test_0218.zip
// the smooth shocks are probably stil buggy // the smooth shocks are probably stil buggy
// //
// The equations are taken from J. Nason and T. Cogley (1994) // The equations are taken from J. Nason and T. Cogley (1994)
// "Testing the implications of long-run neutrality for monetary business // "Testing the implications of long-run neutrality for monetary business
// cycle models" Journal of Applied Econometrics, 9, S37-S70. // cycle models" Journal of Applied Econometrics, 9, S37-S70.
// Note that there is an initial minus sign missing in equation (A1), p. S63. // Note that there is an initial minus sign missing in equation (A1), p. S63.
// //
// Michel Juillard, February 2004 // Michel Juillard, February 2004
var m P c e W R k d n l gy_obs gp_obs y dA; var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model; model;
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(0.5*m(-1)+0.25*m(-2)+0.13*m(-3)+0.06*m(-4)+0.03*m(-5)+0.015*m(-6)+0.007*m(-7)+0.004*m(-8)+0.003*m(-9)+0.001*m(-10))+e_m; log(m) = (1-rho)*log(mst) + rho*log(0.5*m(-1)+0.25*m(-2)+0.13*m(-3)+0.06*m(-4)+0.03*m(-5)+0.015*m(-6)+0.007*m(-7)+0.004*m(-8)+0.003*m(-9)+0.001*m(-10))+e_m;
-P/(((1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9)))*m/9)+bet*((1.3*P(+1)+P(+5)+0.7*P(+9))/3)*(alp*exp(-alp*(gam+log((1.3*e(+1)+e(+5)+0.7*e(+9))/3)))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0; -P/(((1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9)))*m/9)+bet*((1.3*P(+1)+P(+5)+0.7*P(+9))/3)*(alp*exp(-alp*(gam+log((1.3*e(+1)+e(+5)+0.7*e(+9))/3)))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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* (1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9))/9) = 0; 1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l* (1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9))/9) = 0;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a)*4)*k(-4); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a)*4)*k(-4);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
end; end;
initval; initval;
k = 6; k = 6;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
steady; steady;
check; check;
stoch_simul(order=1,irf=0); stoch_simul(order=1,irf=0);

View File

@ -1,86 +1,86 @@
// This file replicates the estimation of the CIA model from // This file replicates the estimation of the CIA model from
// Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models" // Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models"
// Journal of Applied Econometrics, 15, 645-670. // Journal of Applied Econometrics, 15, 645-670.
// the data are the ones provided on Schorfheide's web site with the programs. // the data are the ones provided on Schorfheide's web site with the programs.
// http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP // http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP
// You need to have fsdat.m in the same directory as this file. // You need to have fsdat.m in the same directory as this file.
// This file replicates: // This file replicates:
// -the posterior mode as computed by Frank's Gauss programs // -the posterior mode as computed by Frank's Gauss programs
// -the parameter mean posterior estimates reported in the paper // -the parameter mean posterior estimates reported in the paper
// -the model probability (harmonic mean) reported in the paper // -the model probability (harmonic mean) reported in the paper
// This file was tested with dyn_mat_test_0218.zip // This file was tested with dyn_mat_test_0218.zip
// the smooth shocks are probably stil buggy // the smooth shocks are probably stil buggy
// //
// The equations are taken from J. Nason and T. Cogley (1994) // The equations are taken from J. Nason and T. Cogley (1994)
// "Testing the implications of long-run neutrality for monetary business // "Testing the implications of long-run neutrality for monetary business
// cycle models" Journal of Applied Econometrics, 9, S37-S70. // cycle models" Journal of Applied Econometrics, 9, S37-S70.
// Note that there is an initial minus sign missing in equation (A1), p. S63. // Note that there is an initial minus sign missing in equation (A1), p. S63.
// //
// Michel Juillard, February 2004 // Michel Juillard, February 2004
var m P c e W R k d n l gy_obs gp_obs y dA; var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model; model;
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(0.5*m(-1)+0.25*m(-2)+0.13*m(-3)+0.06*m(-4)+0.03*m(-5)+0.015*m(-6)+0.007*m(-7)+0.004*m(-8)+0.003*m(-9)+0.001*m(-10))+e_m; log(m) = (1-rho)*log(mst) + rho*log(0.5*m(-1)+0.25*m(-2)+0.13*m(-3)+0.06*m(-4)+0.03*m(-5)+0.015*m(-6)+0.007*m(-7)+0.004*m(-8)+0.003*m(-9)+0.001*m(-10))+e_m;
-P/(((1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9)))*m/9)+bet*((1.3*P(+1)+P(+5)+0.7*P(+9))/3)*(alp*exp(-alp*(gam+log((1.3*e(+1)+e(+5)+0.7*e(+9))/3)))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0; -P/(((1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9)))*m/9)+bet*((1.3*P(+1)+P(+5)+0.7*P(+9))/3)*(alp*exp(-alp*(gam+log((1.3*e(+1)+e(+5)+0.7*e(+9))/3)))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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* (1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9))/9) = 0; 1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l* (1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9))/9) = 0;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a)*4)*k(-4); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a)*4)*k(-4);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
end; end;
initval; initval;
k = 6; k = 6;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
steady; steady;
check; check;
stoch_simul(aim_solver, order=1,irf=0); stoch_simul(aim_solver, order=1,irf=0);
benchmark = load('fs2000x10L9_L_results'); benchmark = load('fs2000x10L9_L_results');
threshold = 1e-8; threshold = 1e-8;
if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold)); if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold));
error('error in ghx'); error('error in ghx');
elseif max(max(abs(benchmark.oo_.dr.ghu-oo_.dr.ghu) > threshold)); elseif max(max(abs(benchmark.oo_.dr.ghu-oo_.dr.ghu) > threshold));
error('error in ghy'); error('error in ghy');
end; end;

View File

@ -1,59 +1,59 @@
//Model with up to 10 lags and leads up to 9 - but not all, with some missing //Model with up to 10 lags and leads up to 9 - but not all, with some missing
var m P c e W R k d n l gy_obs gp_obs y dA; var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model; model;
dA = exp(gam+e_a); % missing 0.06*m(-4) and +0.25*m(-2) dA = exp(gam+e_a); % missing 0.06*m(-4) and +0.25*m(-2)
log(m) = (1-rho)*log(mst) + rho*log(0.75*m(-1)+0.13*m(-3)+0.09*m(-5)+0.015*m(-6)+0.007*m(-7)+0.004*m(-8)+0.003*m(-9)+0.001*m(-10))+e_m; log(m) = (1-rho)*log(mst) + rho*log(0.75*m(-1)+0.13*m(-3)+0.09*m(-5)+0.015*m(-6)+0.007*m(-7)+0.004*m(-8)+0.003*m(-9)+0.001*m(-10))+e_m;
-P/(((1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9)))*m/9)+bet*((1.3*P(+1)+P(+5)+0.7*P(+9))/3)*(alp*exp(-alp*(gam+log((1.3*e(+1)+e(+5)+0.7*e(+9))/3)))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0; -P/(((1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9)))*m/9)+bet*((1.3*P(+1)+P(+5)+0.7*P(+9))/3)*(alp*exp(-alp*(gam+log((1.3*e(+1)+e(+5)+0.7*e(+9))/3)))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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* (1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9))/9) = 0; 1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l* (1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9))/9) = 0;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a)*4)*k(-4); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a)*4)*k(-4);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
end; end;
initval; initval;
k = 6; k = 6;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
steady; steady;
stoch_simul(order=1,irf=0); stoch_simul(order=1,irf=0);

View File

@ -1,67 +1,67 @@
//Model with up to 10 lags and leads up to 9 - but not all, with some missing //Model with up to 10 lags and leads up to 9 - but not all, with some missing
var m P c e W R k d n l gy_obs gp_obs y dA; var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model; model;
dA = exp(gam+e_a); % missing 0.06*m(-4) and +0.25*m(-2) dA = exp(gam+e_a); % missing 0.06*m(-4) and +0.25*m(-2)
log(m) = (1-rho)*log(mst) + rho*log(0.75*m(-1)+0.13*m(-3)+0.09*m(-5)+0.015*m(-6)+0.007*m(-7)+0.004*m(-8)+0.003*m(-9)+0.001*m(-10))+e_m; log(m) = (1-rho)*log(mst) + rho*log(0.75*m(-1)+0.13*m(-3)+0.09*m(-5)+0.015*m(-6)+0.007*m(-7)+0.004*m(-8)+0.003*m(-9)+0.001*m(-10))+e_m;
-P/(((1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9)))*m/9)+bet*((1.3*P(+1)+P(+5)+0.7*P(+9))/3)*(alp*exp(-alp*(gam+log((1.3*e(+1)+e(+5)+0.7*e(+9))/3)))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0; -P/(((1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9)))*m/9)+bet*((1.3*P(+1)+P(+5)+0.7*P(+9))/3)*(alp*exp(-alp*(gam+log((1.3*e(+1)+e(+5)+0.7*e(+9))/3)))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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* (1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9))/9) = 0; 1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l* (1.3*c(+1)+c(+5)+0.7*c(+9))*(1.3*P(+1)+P(+5)+0.7*P(+9))/9) = 0;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a)*4)*k(-4); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a)*4)*k(-4);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
end; end;
initval; initval;
k = 6; k = 6;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
steady; steady;
stoch_simul(aim_solver, order=1,irf=0); stoch_simul(aim_solver, order=1,irf=0);
benchmark = load('fs2000x10_L9_L_results'); benchmark = load('fs2000x10_L9_L_results');
threshold = 1e-8; threshold = 1e-8;
if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold)); if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold));
error('error in ghx'); error('error in ghx');
elseif max(max(abs(benchmark.oo_.dr.ghu-oo_.dr.ghu) > threshold)); elseif max(max(abs(benchmark.oo_.dr.ghu-oo_.dr.ghu) > threshold));
error('error in ghy'); error('error in ghy');
end; end;

View File

@ -1,47 +1,47 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54; psi1 = 1.54;
psi2 = 0.25; psi2 = 0.25;
psi3 = 0.25; psi3 = 0.25;
rho_R = 0.5; rho_R = 0.5;
alpha = 0.3; alpha = 0.3;
rr = 2.51; rr = 2.51;
k = 0.5; k = 0.5;
tau = 0.5; tau = 0.5;
rho_q = 0.4; rho_q = 0.4;
rho_A = 0.2; rho_A = 0.2;
rho_ys = 0.9; rho_ys = 0.9;
rho_pies = 0.7; rho_pies = 0.7;
// GP extended to see effect of 2 lags and 2 leads // GP extended to see effect of 2 lags and 2 leads
model(linear); model(linear);
//y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); //y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
y = 0.3*y +0.3*y(-1) +0.3*y(-2)-(tau +alpha*(2-alpha)*(1-tau))*(R-pie)-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq + alpha*(2-alpha)*((1-tau)/tau)*(y_s(11)-y_s)-A; y = 0.3*y +0.3*y(-1) +0.3*y(-2)-(tau +alpha*(2-alpha)*(1-tau))*(R-pie)-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq + alpha*(2-alpha)*((1-tau)/tau)*(y_s(11)-y_s)-A;
//y = 0.3*y(+2)+0.3*y(+1)+0.3*y(-2) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); //y = 0.3*y(+2)+0.3*y(+1)+0.3*y(-2) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
//pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; //pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = exp(-rr/400)*pie(-1)+alpha*exp(-rr/400)*dq-alpha*dq(-1)+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = exp(-rr/400)*pie(-1)+alpha*exp(-rr/400)*dq-alpha*dq(-1)+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s; pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R; R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q; dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys; y_s = rho_ys*y_s(-1)+e_ys;
//pie_s = rho_pies*pie_s(-1)+e_pies; //pie_s = rho_pies*pie_s(-1)+e_pies;
pie_s = rho_pies*pie_s(-1)+(1-rho_pies)*pie_s(-2)+e_pies; pie_s = rho_pies*pie_s(-1)+(1-rho_pies)*pie_s(-2)+e_pies;
A = rho_A*A(-1)+e_A; A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A; y_obs = y-y(-1)+A;
pie_obs = 4*pie; pie_obs = 4*pie;
R_obs = 4*R; R_obs = 4*R;
end; end;
shocks; shocks;
var e_R = 1.25^2; var e_R = 1.25^2;
var e_q = 2.5^2; var e_q = 2.5^2;
var e_A = 1.89; var e_A = 1.89;
var e_ys = 1.89; var e_ys = 1.89;
var e_pies = 1.89; var e_pies = 1.89;
end; end;
stoch_simul(order=1,irf=0); stoch_simul(order=1,irf=0);

View File

@ -1,55 +1,55 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54; psi1 = 1.54;
psi2 = 0.25; psi2 = 0.25;
psi3 = 0.25; psi3 = 0.25;
rho_R = 0.5; rho_R = 0.5;
alpha = 0.3; alpha = 0.3;
rr = 2.51; rr = 2.51;
k = 0.5; k = 0.5;
tau = 0.5; tau = 0.5;
rho_q = 0.4; rho_q = 0.4;
rho_A = 0.2; rho_A = 0.2;
rho_ys = 0.9; rho_ys = 0.9;
rho_pies = 0.7; rho_pies = 0.7;
// GP extended to see effect of 2 lags and 2 leads // GP extended to see effect of 2 lags and 2 leads
model(linear); model(linear);
//y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); //y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
y = 0.3*y +0.3*y(-1) +0.3*y(-2)-(tau +alpha*(2-alpha)*(1-tau))*(R-pie)-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq + alpha*(2-alpha)*((1-tau)/tau)*(y_s(11)-y_s)-A; y = 0.3*y +0.3*y(-1) +0.3*y(-2)-(tau +alpha*(2-alpha)*(1-tau))*(R-pie)-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq + alpha*(2-alpha)*((1-tau)/tau)*(y_s(11)-y_s)-A;
//y = 0.3*y(+2)+0.3*y(+1)+0.3*y(-2) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); //y = 0.3*y(+2)+0.3*y(+1)+0.3*y(-2) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
//pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; //pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = exp(-rr/400)*pie(-1)+alpha*exp(-rr/400)*dq-alpha*dq(-1)+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = exp(-rr/400)*pie(-1)+alpha*exp(-rr/400)*dq-alpha*dq(-1)+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s; pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R; R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q; dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys; y_s = rho_ys*y_s(-1)+e_ys;
//pie_s = rho_pies*pie_s(-1)+e_pies; //pie_s = rho_pies*pie_s(-1)+e_pies;
pie_s = rho_pies*pie_s(-1)+(1-rho_pies)*pie_s(-2)+e_pies; pie_s = rho_pies*pie_s(-1)+(1-rho_pies)*pie_s(-2)+e_pies;
A = rho_A*A(-1)+e_A; A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A; y_obs = y-y(-1)+A;
pie_obs = 4*pie; pie_obs = 4*pie;
R_obs = 4*R; R_obs = 4*R;
end; end;
shocks; shocks;
var e_R = 1.25^2; var e_R = 1.25^2;
var e_q = 2.5^2; var e_q = 2.5^2;
var e_A = 1.89; var e_A = 1.89;
var e_ys = 1.89; var e_ys = 1.89;
var e_pies = 1.89; var e_pies = 1.89;
end; end;
stoch_simul(aim_solver, order=1,irf=0); stoch_simul(aim_solver, order=1,irf=0);
benchmark = load('ls2003_2L0L_results'); benchmark = load('ls2003_2L0L_results');
threshold = 1e-8; threshold = 1e-8;
if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold)); if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold));
error('error in ghx'); error('error in ghx');
elseif max(max(abs(benchmark.oo_.dr.ghu-oo_.dr.ghu) > threshold)); elseif max(max(abs(benchmark.oo_.dr.ghu-oo_.dr.ghu) > threshold));
error('error in ghy'); error('error in ghy');
end; end;

View File

@ -1,45 +1,45 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54; psi1 = 1.54;
psi2 = 0.25; psi2 = 0.25;
psi3 = 0.25; psi3 = 0.25;
rho_R = 0.5; rho_R = 0.5;
alpha = 0.3; alpha = 0.3;
rr = 2.51; rr = 2.51;
k = 0.5; k = 0.5;
tau = 0.5; tau = 0.5;
rho_q = 0.4; rho_q = 0.4;
rho_A = 0.2; rho_A = 0.2;
rho_ys = 0.9; rho_ys = 0.9;
rho_pies = 0.7; rho_pies = 0.7;
// GP extended to see effect of 2 lags and 2 leads // GP extended to see effect of 2 lags and 2 leads
model(linear); model(linear);
//y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); //y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
y = 0.3*y(+2)+0.3*y(+1)+0.3*y(-2) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); y = 0.3*y(+2)+0.3*y(+1)+0.3*y(-2) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s; pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R; R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q; dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys; y_s = rho_ys*y_s(-1)+e_ys;
//pie_s = rho_pies*pie_s(-1)+e_pies; //pie_s = rho_pies*pie_s(-1)+e_pies;
pie_s = rho_pies*pie_s(-1)+(1-rho_pies)*pie_s(-2)+e_pies; pie_s = rho_pies*pie_s(-1)+(1-rho_pies)*pie_s(-2)+e_pies;
A = rho_A*A(-1)+e_A; A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A; y_obs = y-y(-1)+A;
pie_obs = 4*pie; pie_obs = 4*pie;
R_obs = 4*R; R_obs = 4*R;
end; end;
shocks; shocks;
var e_R = 1.25^2; var e_R = 1.25^2;
var e_q = 2.5^2; var e_q = 2.5^2;
var e_A = 1.89; var e_A = 1.89;
var e_ys = 1.89; var e_ys = 1.89;
var e_pies = 1.89; var e_pies = 1.89;
end; end;
stoch_simul(order=1,irf=0); stoch_simul(order=1,irf=0);

View File

@ -1,54 +1,54 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54; psi1 = 1.54;
psi2 = 0.25; psi2 = 0.25;
psi3 = 0.25; psi3 = 0.25;
rho_R = 0.5; rho_R = 0.5;
alpha = 0.3; alpha = 0.3;
rr = 2.51; rr = 2.51;
k = 0.5; k = 0.5;
tau = 0.5; tau = 0.5;
rho_q = 0.4; rho_q = 0.4;
rho_A = 0.2; rho_A = 0.2;
rho_ys = 0.9; rho_ys = 0.9;
rho_pies = 0.7; rho_pies = 0.7;
// GP extended to see effect of 2 lags and 2 leads // GP extended to see effect of 2 lags and 2 leads
model(linear); model(linear);
//y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); //y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
y = 0.3*y(+2)+0.3*y(+1)+0.3*y(-2) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); y = 0.3*y(+2)+0.3*y(+1)+0.3*y(-2) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s; pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R; R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q; dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys; y_s = rho_ys*y_s(-1)+e_ys;
//pie_s = rho_pies*pie_s(-1)+e_pies; //pie_s = rho_pies*pie_s(-1)+e_pies;
pie_s = rho_pies*pie_s(-1)+(1-rho_pies)*pie_s(-2)+e_pies; pie_s = rho_pies*pie_s(-1)+(1-rho_pies)*pie_s(-2)+e_pies;
A = rho_A*A(-1)+e_A; A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A; y_obs = y-y(-1)+A;
pie_obs = 4*pie; pie_obs = 4*pie;
R_obs = 4*R; R_obs = 4*R;
end; end;
shocks; shocks;
var e_R = 1.25^2; var e_R = 1.25^2;
var e_q = 2.5^2; var e_q = 2.5^2;
var e_A = 1.89; var e_A = 1.89;
var e_ys = 1.89; var e_ys = 1.89;
var e_pies = 1.89; var e_pies = 1.89;
end; end;
stoch_simul(aim_solver, order=1,irf=0); stoch_simul(aim_solver, order=1,irf=0);
benchmark = load('ls2003_2L2L_results'); benchmark = load('ls2003_2L2L_results');
threshold = 1e-8; threshold = 1e-8;
if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold)); if max(max(abs(benchmark.oo_.dr.ghx-oo_.dr.ghx) > threshold));
error('error in ghx'); error('error in ghx');
elseif max(max(abs(benchmark.oo_.dr.ghu-oo_.dr.ghu) > threshold)); elseif max(max(abs(benchmark.oo_.dr.ghu-oo_.dr.ghu) > threshold));
error('error in ghy'); error('error in ghy');
end; end;

View File

@ -1,23 +1,23 @@
var dx dy x y; var dx dy x y;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y; parameters rho_x rho_y;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
model; model;
dx = rho_x*dx(-1)+e_x; dx = rho_x*dx(-1)+e_x;
dy = rho_y*dy(-1)+e_y; dy = rho_y*dy(-1)+e_y;
x = x(-1)+dx; x = x(-1)+dx;
y = y(-1)+dy; y = y(-1)+dy;
end; end;
shocks; shocks;
var e_x; stderr 0.01; var e_x; stderr 0.01;
var e_y; stderr 0.01; var e_y; stderr 0.01;
end; end;
stoch_simul(order=1,periods=1000,irf=0,nomoments); stoch_simul(order=1,periods=1000,irf=0,nomoments);
datatomfile('data1',[]); datatomfile('data1',[]);

View File

@ -1,23 +1,23 @@
var dx dy; var dx dy;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y; parameters rho_x rho_y;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
model; model;
dx = rho_x*dx(-1)+e_x; dx = rho_x*dx(-1)+e_x;
dy = rho_y*dy(-1)+e_y; dy = rho_y*dy(-1)+e_y;
end; end;
estimated_params; estimated_params;
rho_x,NORMAL_PDF,0.5,0.1; rho_x,NORMAL_PDF,0.5,0.1;
rho_y,NORMAL_PDF,-0.3,0.1; rho_y,NORMAL_PDF,-0.3,0.1;
stderr e_x,INV_GAMMA_PDF,0.01,inf; stderr e_x,INV_GAMMA_PDF,0.01,inf;
stderr e_y,INV_GAMMA_PDF,0.01,inf; stderr e_y,INV_GAMMA_PDF,0.01,inf;
end; end;
varobs dx dy; varobs dx dy;
check; check;
estimation(datafile=data1,nobs=1000,mh_replic=2000); estimation(datafile=data1,nobs=1000,mh_replic=2000);

View File

@ -1,25 +1,25 @@
var dx dy x y; var dx dy x y;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y; parameters rho_x rho_y;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
model; model;
dx = rho_x*dx(-1)+e_x; dx = rho_x*dx(-1)+e_x;
dy = rho_y*dy(-1)+e_y; dy = rho_y*dy(-1)+e_y;
x = x(-1)+dx; x = x(-1)+dx;
y = y(-1)+dy; y = y(-1)+dy;
end; end;
estimated_params; estimated_params;
rho_x,NORMAL_PDF,0.5,0.1; rho_x,NORMAL_PDF,0.5,0.1;
rho_y,NORMAL_PDF,-0.3,0.1; rho_y,NORMAL_PDF,-0.3,0.1;
stderr e_x,INV_GAMMA_PDF,0.01,inf; stderr e_x,INV_GAMMA_PDF,0.01,inf;
stderr e_y,INV_GAMMA_PDF,0.01,inf; stderr e_y,INV_GAMMA_PDF,0.01,inf;
end; end;
varobs x y; varobs x y;
unit_root_vars x y; unit_root_vars x y;
estimation(datafile=data1,nobs=1000,mh_replic=0); estimation(datafile=data1,nobs=1000,mh_replic=0);

View File

@ -1,27 +1,27 @@
var dx dy x y; var dx dy x y;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y; parameters rho_x rho_y;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
model; model;
dx = rho_x*dx(-1)+e_x; dx = rho_x*dx(-1)+e_x;
dy = rho_y*dy(-1)+e_y; dy = rho_y*dy(-1)+e_y;
x = x(-1)+dx; x = x(-1)+dx;
y = y(-1)+dy; y = y(-1)+dy;
end; end;
estimated_params; estimated_params;
rho_x,NORMAL_PDF,0.5,0.1; rho_x,NORMAL_PDF,0.5,0.1;
rho_y,NORMAL_PDF,-0.3,0.1; rho_y,NORMAL_PDF,-0.3,0.1;
stderr e_x,INV_GAMMA_PDF,0.01,inf; stderr e_x,INV_GAMMA_PDF,0.01,inf;
stderr e_y,INV_GAMMA_PDF,0.01,inf; stderr e_y,INV_GAMMA_PDF,0.01,inf;
stderr x,INV_GAMMA_PDF,0.01,inf; stderr x,INV_GAMMA_PDF,0.01,inf;
stderr y,INV_GAMMA_PDF,0.01,inf; stderr y,INV_GAMMA_PDF,0.01,inf;
end; end;
varobs x y; varobs x y;
unit_root_vars x y; unit_root_vars x y;
estimation(datafile=data1,nobs=1000,mh_replic=2000,lik_init=2); estimation(datafile=data1,nobs=1000,mh_replic=2000,lik_init=2);

View File

@ -1,26 +1,26 @@
var dx dy x y; var dx dy x y;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y b a1 a2; parameters rho_x rho_y b a1 a2;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
b = 1; b = 1;
a1 = -0.1; a1 = -0.1;
a2 = 0.2; a2 = 0.2;
model; model;
dx = rho_x*dx(-1)+a1*(x(-1)-b*y(-1))+e_x; dx = rho_x*dx(-1)+a1*(x(-1)-b*y(-1))+e_x;
dy = rho_y*dy(-1)+a2*(x(-1)-b*y(-1))+e_y; dy = rho_y*dy(-1)+a2*(x(-1)-b*y(-1))+e_y;
x = x(-1)+dx; x = x(-1)+dx;
y = y(-1)+dy; y = y(-1)+dy;
end; end;
shocks; shocks;
var e_x; stderr 0.01; var e_x; stderr 0.01;
var e_y; stderr 0.01; var e_y; stderr 0.01;
end; end;
stoch_simul(order=1,periods=1000,irf=0,nomoments); stoch_simul(order=1,periods=1000,irf=0,nomoments);
datatomfile('data2',[]); datatomfile('data2',[]);

View File

@ -1,33 +1,33 @@
var dx dy x y; var dx dy x y;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y b a1 a2; parameters rho_x rho_y b a1 a2;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
b = 1; b = 1;
a1 = -0.1; a1 = -0.1;
a2 = 0.2; a2 = 0.2;
model; model;
dx = rho_x*dx(-1)+a1*(x(-1)-b*y(-1))+e_x; dx = rho_x*dx(-1)+a1*(x(-1)-b*y(-1))+e_x;
dy = rho_y*dy(-1)+a2*(x(-1)-b*y(-1))+e_y; dy = rho_y*dy(-1)+a2*(x(-1)-b*y(-1))+e_y;
x = x(-1)+dx; x = x(-1)+dx;
y = y(-1)+dy; y = y(-1)+dy;
end; end;
estimated_params; estimated_params;
rho_x,NORMAL_PDF,0.5,0.1; rho_x,NORMAL_PDF,0.5,0.1;
rho_y,NORMAL_PDF,-0.3,0.1; rho_y,NORMAL_PDF,-0.3,0.1;
b,NORMAL_PDF,1,0.1; b,NORMAL_PDF,1,0.1;
a1,NORMAL_PDF,-0.1,0.1; a1,NORMAL_PDF,-0.1,0.1;
a2,NORMAL_PDF,0.2,0.1; a2,NORMAL_PDF,0.2,0.1;
stderr e_x,INV_GAMMA_PDF,0.01,inf; stderr e_x,INV_GAMMA_PDF,0.01,inf;
stderr e_y,INV_GAMMA_PDF,0.01,inf; stderr e_y,INV_GAMMA_PDF,0.01,inf;
end; end;
varobs dx dy; varobs dx dy;
unit_root_vars x y; unit_root_vars x y;
estimation(datafile=data2,nobs=100,mh_replic=0,lik_init=2); estimation(datafile=data2,nobs=100,mh_replic=0,lik_init=2);

View File

@ -1,33 +1,33 @@
var dx dy x y; var dx dy x y;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y b a1 a2; parameters rho_x rho_y b a1 a2;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
b = 1; b = 1;
a1 = -0.1; a1 = -0.1;
a2 = 0.2; a2 = 0.2;
model; model;
dx = rho_x*dx(-1)+a1*(x(-1)-b*y(-1))+e_x; dx = rho_x*dx(-1)+a1*(x(-1)-b*y(-1))+e_x;
dy = rho_y*dy(-1)+a2*(x(-1)-b*y(-1))+e_y; dy = rho_y*dy(-1)+a2*(x(-1)-b*y(-1))+e_y;
x = x(-1)+dx; x = x(-1)+dx;
y = y(-1)+dy; y = y(-1)+dy;
end; end;
estimated_params; estimated_params;
rho_x,NORMAL_PDF,0.5,0.1; rho_x,NORMAL_PDF,0.5,0.1;
rho_y,NORMAL_PDF,-0.3,0.1; rho_y,NORMAL_PDF,-0.3,0.1;
b,NORMAL_PDF,1,0.1; b,NORMAL_PDF,1,0.1;
a1,NORMAL_PDF,-0.1,0.1; a1,NORMAL_PDF,-0.1,0.1;
a2,NORMAL_PDF,0.2,0.1; a2,NORMAL_PDF,0.2,0.1;
stderr e_x,INV_GAMMA_PDF,0.01,inf; stderr e_x,INV_GAMMA_PDF,0.01,inf;
stderr e_y,INV_GAMMA_PDF,0.01,inf; stderr e_y,INV_GAMMA_PDF,0.01,inf;
end; end;
varobs x y; varobs x y;
unit_root_vars x y; unit_root_vars x y;
estimation(datafile=data2,nobs=100,mh_replic=0,lik_init=2); estimation(datafile=data2,nobs=100,mh_replic=0,lik_init=2);

View File

@ -1,31 +1,31 @@
var dx dy coint_err; var dx dy coint_err;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y b a1 a2; parameters rho_x rho_y b a1 a2;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
b = 1; b = 1;
a1 = -0.1; a1 = -0.1;
a2 = 0.2; a2 = 0.2;
model; model;
dx = rho_x*dx(-1)+a1*coint_err(-1)+e_x; dx = rho_x*dx(-1)+a1*coint_err(-1)+e_x;
dy = rho_y*dy(-1)+a2*coint_err(-1)+e_y; dy = rho_y*dy(-1)+a2*coint_err(-1)+e_y;
coint_err = dx-b*dy+coint_err(-1); coint_err = dx-b*dy+coint_err(-1);
end; end;
estimated_params; estimated_params;
rho_x,NORMAL_PDF,0.5,0.1; rho_x,NORMAL_PDF,0.5,0.1;
rho_y,NORMAL_PDF,-0.3,0.1; rho_y,NORMAL_PDF,-0.3,0.1;
b,NORMAL_PDF,1,0.1; b,NORMAL_PDF,1,0.1;
a1,NORMAL_PDF,-0.1,0.1; a1,NORMAL_PDF,-0.1,0.1;
a2,NORMAL_PDF,0.2,0.1; a2,NORMAL_PDF,0.2,0.1;
stderr e_x,INV_GAMMA_PDF,0.01,inf; stderr e_x,INV_GAMMA_PDF,0.01,inf;
stderr e_y,INV_GAMMA_PDF,0.01,inf; stderr e_y,INV_GAMMA_PDF,0.01,inf;
end; end;
varobs dx dy; varobs dx dy;
estimation(datafile=data2,nobs=100,mh_replic=0); estimation(datafile=data2,nobs=100,mh_replic=0);

View File

@ -1,24 +1,24 @@
var dx dy; var dx dy;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y; parameters rho_x rho_y;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
model; model;
dx = rho_x*dx(-1)+e_x; dx = rho_x*dx(-1)+e_x;
dy = rho_y*dy(-1)+e_y; dy = rho_y*dy(-1)+e_y;
end; end;
estimated_params; estimated_params;
rho_x,NORMAL_PDF,0.5,0.1; rho_x,NORMAL_PDF,0.5,0.1;
rho_y,NORMAL_PDF,-0.3,0.1; rho_y,NORMAL_PDF,-0.3,0.1;
stderr e_x,INV_GAMMA_PDF,0.01,inf; stderr e_x,INV_GAMMA_PDF,0.01,inf;
stderr e_y,INV_GAMMA_PDF,0.01,inf; stderr e_y,INV_GAMMA_PDF,0.01,inf;
end; end;
varobs dx dy; varobs dx dy;
check; check;
estimation(datafile=data1,nobs=1000,mh_replic=0,load_mh_file); estimation(datafile=data1,nobs=1000,mh_replic=0,load_mh_file);
stab_map_; stab_map_;

View File

@ -1,91 +1,91 @@
var m P c e W R k d n l gy_obs gp_obs y dA; var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
@#if block_bytecode == 2 @#if block_bytecode == 2
model(block, bytecode); model(block, bytecode);
@#else @#else
@# if block_bytecode == 1 @# if block_bytecode == 1
model(block); model(block);
@# else @# else
model; model;
@# endif @# endif
@#endif @#endif
/*0*/ exp(gam+e_a) = dA ; /*0*/ exp(gam+e_a) = dA ;
/*1*/ log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; /*1*/ log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
/*2*/ -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; /*2*/ -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;
/*3*/ l/n = W; /*3*/ l/n = W;
/*4*/ -(psi/(1-psi))*(c*P/(1-n))+l/n = 0; /*4*/ -(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
/*5*/ R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W; /*5*/ R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
/*6*/ 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; /*6*/ 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;
/*7*/ c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1); /*7*/ c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
/*8*/ P*c = m; /*8*/ P*c = m;
/*9*/ m-1+d = l; /*9*/ m-1+d = l;
/*10*/ e = exp(e_a); /*10*/ e = exp(e_a);
/*11*/ k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)) = y ; /*11*/ k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)) = y ;
/*12*/ gy_obs = dA*y/y(-1); /*12*/ gy_obs = dA*y/y(-1);
/*13*/ gp_obs = (P/P(-1))*m(-1)/dA; /*13*/ gp_obs = (P/P(-1))*m(-1)/dA;
end; end;
initval; initval;
k = 6; k = 6;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
e_a=0; e_a=0;
e_m=0; e_m=0;
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
options_.maxit_=10; options_.maxit_=10;
steady(solve_algo = @{solve_algo}); steady(solve_algo = @{solve_algo});
@#if block_bytecode > 0 @#if block_bytecode > 0
model_info; model_info;
@#endif @#endif
shocks; shocks;
var e_a; var e_a;
periods 1; periods 1;
values 0.16; values 0.16;
end; end;
simul(periods=200, stack_solve_algo = @{stack_solve_algo}); simul(periods=200, stack_solve_algo = @{stack_solve_algo});
@#if block_bytecode > 0 @#if block_bytecode > 0
if ~exist('fs2000_simk_results.mat','file'); if ~exist('fs2000_simk_results.mat','file');
error('fs2000_simk must be run first'); error('fs2000_simk must be run first');
end; end;
oo1 = load('fs2000_simk_results','oo_'); oo1 = load('fs2000_simk_results','oo_');
err = max(max(abs(oo_.endo_simul - oo1.oo_.endo_simul))) err = max(max(abs(oo_.endo_simul - oo1.oo_.endo_simul)))
disp(['Max error in simulation: ' num2str(err)]) disp(['Max error in simulation: ' num2str(err)])
if err > 1e-4 if err > 1e-4
error('Error above the threshold') error('Error above the threshold')
end; end;
@#endif @#endif

View File

@ -1,80 +1,80 @@
var y a k c i h eoy eoc eoh oy oc oh; var y a k c i h eoy eoc eoh oy oc oh;
varexo e eeoy eeoc eeoh; varexo e eeoy eeoc eeoh;
parameters theta rho eta gam bet delta aa r11 r12 r13 r21 r22 r23 r31 r32 r33 scy shc shy; parameters theta rho eta gam bet delta aa r11 r12 r13 r21 r22 r23 r31 r32 r33 scy shc shy;
bet = 0.99; bet = 0.99;
delta = 0.025; delta = 0.025;
theta = 0.2; theta = 0.2;
rho = 0.9959; rho = 0.9959;
eta = 1.0051; eta = 1.0051;
gam = 0.0045; gam = 0.0045;
aa = 1.8; aa = 1.8;
r11 = 0.99; r11 = 0.99;
r12 = 0; r12 = 0;
r13 = 0; r13 = 0;
r21 = 0; r21 = 0;
r22 = 0.99; r22 = 0.99;
r23 = 0; r23 = 0;
r31 = 0; r31 = 0;
r32 = 0; r32 = 0;
r33 = 0.99; r33 = 0.99;
scy = 0.0040; scy = 0.0040;
shy = 0.0015; shy = 0.0015;
shc = 0.0010; shc = 0.0010;
model(block,cutoff=0); model(block,cutoff=0);
exp(y) = exp(a)*exp(k(-1))^theta*exp(h)^(1-theta); exp(y) = exp(a)*exp(k(-1))^theta*exp(h)^(1-theta);
a = (1-rho)*aa+rho*a(-1)+e; a = (1-rho)*aa+rho*a(-1)+e;
exp(y) = exp(c) + exp(i); exp(y) = exp(c) + exp(i);
eta*exp(k) = (1-delta)*exp(k(-1))+exp(i); eta*exp(k) = (1-delta)*exp(k(-1))+exp(i);
gam*exp(c)*exp(h) = (1-theta)*exp(y); gam*exp(c)*exp(h) = (1-theta)*exp(y);
eta/exp(c) = bet*(1/exp(c(+1)))*(theta*(exp(y(+1))/exp(k))+1-delta); eta/exp(c) = bet*(1/exp(c(+1)))*(theta*(exp(y(+1))/exp(k))+1-delta);
eoy = r11*eoy(-1) + r12*eoc(-1) + r13*eoh(-1) + eeoy; eoy = r11*eoy(-1) + r12*eoc(-1) + r13*eoh(-1) + eeoy;
eoc = r21*eoy(-1) + r22*eoc(-1) + r23*eoh(-1) + scy*eeoy+eeoc; eoc = r21*eoy(-1) + r22*eoc(-1) + r23*eoh(-1) + scy*eeoy+eeoc;
eoh = r31*eoy(-1) + r32*eoc(-1) + r33*eoh(-1) + shy*eeoy+shc*eeoc+eeoh; eoh = r31*eoy(-1) + r32*eoc(-1) + r33*eoh(-1) + shy*eeoy+shc*eeoc+eeoh;
oy = y + eoy; oy = y + eoy;
oc = c + eoc; oc = c + eoc;
oh = h + eoh; oh = h + eoh;
end; end;
initval; initval;
e=0; e=0;
eeoy=0; eeoy=0;
eeoc=0; eeoc=0;
eeoh=0; eeoh=0;
y= 7.99331700544506; y= 7.99331700544506;
a= 1.8; a= 1.8;
k= 9.59646163090336; k= 9.59646163090336;
c= 7.83132048725623; c= 7.83132048725623;
i= 6.09323152367607; i= 6.09323152367607;
h= 5.34253084908048; h= 5.34253084908048;
eoy= 0.0000; eoy= 0.0000;
eoc= 0.0000; eoc= 0.0000;
eoh= 0; eoh= 0;
oy= 7.99331700544506; oy= 7.99331700544506;
oc= 7.83132048725623; oc= 7.83132048725623;
oh= 5.34253084908048; oh= 5.34253084908048;
k=k+0.000001; k=k+0.000001;
end; end;
options_.dynatol=1e-12; options_.dynatol=1e-12;
options_.maxit_=5; options_.maxit_=5;
options_.slowc=1; options_.slowc=1;
steady(solve_algo=2); steady(solve_algo=2);
options_.dynatol=4e-5; options_.dynatol=4e-5;
shocks; shocks;
var e; var e;
periods 1; periods 1;
values 0.02; values 0.02;
end; end;
options_.maxit_=20; options_.maxit_=20;
model_info; model_info;
simul(periods=2000, stack_solve_algo = 1); simul(periods=2000, stack_solve_algo = 1);
rplot y; rplot y;
rplot k; rplot k;

View File

@ -1,73 +1,73 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs vv ww; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs vv ww;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54; psi1 = 1.54;
psi2 = 0.25; psi2 = 0.25;
psi3 = 0.25; psi3 = 0.25;
rho_R = 0.5; rho_R = 0.5;
alpha = 0.3; alpha = 0.3;
rr = 2.51; rr = 2.51;
k = 0.5; k = 0.5;
tau = 0.5; tau = 0.5;
rho_q = 0.4; rho_q = 0.4;
rho_A = 0.2; rho_A = 0.2;
rho_ys = 0.9; rho_ys = 0.9;
rho_pies = 0.7; rho_pies = 0.7;
model(block, bytecode, cutoff=0); model(block, bytecode, cutoff=0);
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s; pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R; R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q; dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys; y_s = rho_ys*y_s(-1)+e_ys;
pie_s = rho_pies*pie_s(-1)+e_pies; pie_s = rho_pies*pie_s(-1)+e_pies;
A = rho_A*A(-1)+e_A; A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A; y_obs = y-y(-1)+A;
pie_obs = 4*pie; pie_obs = 4*pie;
R_obs = 4*R; R_obs = 4*R;
vv = 0.2*ww+0.5*vv(-1)+1; vv = 0.2*ww+0.5*vv(-1)+1;
ww = 0.1*vv+0.5*ww(-1)+2; ww = 0.1*vv+0.5*ww(-1)+2;
/* A lt= /* A lt=
0.5*vv-0.2*ww = 1 0.5*vv-0.2*ww = 1
-0.1*vv+0.5*ww = 2 -0.1*vv+0.5*ww = 2
[ 0.5 -0.2][vv] [1] [ 0.5 -0.2][vv] [1]
= =
[-0.1 0.5][ww] [2] [-0.1 0.5][ww] [2]
det = 0.25-0.02 = 0.23 det = 0.25-0.02 = 0.23
[vv] [0.5 0.2] [1] [0.9] [3.91304] [vv] [0.5 0.2] [1] [0.9] [3.91304]
= 1/0.23* = 1/0.23* = = 1/0.23* = 1/0.23* =
[ww] [0.1 0.5] [2] [1.1] [4.7826] [ww] [0.1 0.5] [2] [1.1] [4.7826]
*/ */
end; end;
shocks; shocks;
var e_R = 1.25^2; var e_R = 1.25^2;
var e_q = 2.5^2; var e_q = 2.5^2;
var e_A = 1.89; var e_A = 1.89;
var e_ys = 1.89; var e_ys = 1.89;
var e_pies = 1.89; var e_pies = 1.89;
end; end;
options_.maxit_=100; options_.maxit_=100;
steady(solve_algo = 5); steady(solve_algo = 5);
model_info; model_info;
//check; //check;
shocks; shocks;
var e_q; var e_q;
periods 1; periods 1;
values 0.5; values 0.5;
end; end;
simul(periods=20, markowitz=0, stack_solve_algo = 5); simul(periods=20, markowitz=0, stack_solve_algo = 5);
rplot vv; rplot vv;
rplot ww; rplot ww;
rplot A; rplot A;
rplot pie; rplot pie;

View File

@ -1,27 +1,27 @@
var dx dy x y; var dx dy x y;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y; parameters rho_x rho_y;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
model(block); model(block);
dx = rho_x*dx(-1)+e_x; dx = rho_x*dx(-1)+e_x;
dy = rho_y*dy(-1)+e_y; dy = rho_y*dy(-1)+e_y;
x = x(-1)+dx; x = x(-1)+dx;
y = y(-1)+dy; y = y(-1)+dy;
end; end;
shocks; shocks;
var e_x; stderr 0.01; var e_x; stderr 0.01;
var e_y; stderr 0.01; var e_y; stderr 0.01;
end; end;
steady; steady;
check; check;
model_info; model_info;
simul(periods=50); simul(periods=50);
/*stoch_simul(order=1,periods=1000,irf=0,nomoments); /*stoch_simul(order=1,periods=1000,irf=0,nomoments);
datatomfile('data1',[]); datatomfile('data1',[]);
*/ */

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +1,37 @@
options_.maxit_ = 100; options_.maxit_ = 100;
var c k; var c k;
varexo x; varexo x;
parameters alph gam delt bet aa; parameters alph gam delt bet aa;
alph=0.5; alph=0.5;
gam=0.5; gam=0.5;
delt=0.02; delt=0.02;
bet=0.05; bet=0.05;
aa=0.5; aa=0.5;
model(block, bytecode); model(block, bytecode);
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
end; end;
initval; initval;
x = 1; x = 1;
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1)); k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
c = aa*k^alph-delt*k; c = aa*k^alph-delt*k;
end; end;
steady(solve_algo = 5); steady(solve_algo = 5);
//check; //check;
model_info; model_info;
shocks; shocks;
var x; var x;
periods 1; periods 1;
values 1.02; values 1.02;
end; end;
simul(periods = 200, stack_solve_algo = 5, markowitz = 2); simul(periods = 200, stack_solve_algo = 5, markowitz = 2);
rplot c; rplot c;
rplot k; rplot k;

View File

@ -1,37 +1,37 @@
// check shocks on several periods // check shocks on several periods
var c k; var c k;
varexo x; varexo x;
parameters alph gam delt bet aa; parameters alph gam delt bet aa;
alph=0.5; alph=0.5;
gam=0.5; gam=0.5;
delt=0.02; delt=0.02;
bet=0.05; bet=0.05;
aa=0.5; aa=0.5;
model(block); model(block);
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
end; end;
initval; initval;
x = 1; x = 1;
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1)); k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
c = aa*k^alph-delt*k +1 ; c = aa*k^alph-delt*k +1 ;
end; end;
steady; steady;
//check; //check;
shocks; shocks;
var x; var x;
periods 1 2 3 4; periods 1 2 3 4;
values 1.1 1.2 1.3 1.4; values 1.1 1.2 1.3 1.4;
end; end;
simul(periods=200, stack_solve_algo = 2); simul(periods=200, stack_solve_algo = 2);
rplot c; rplot c;
rplot k; rplot k;

View File

@ -1,30 +1,30 @@
var dx dy; var dx dy;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y; parameters rho_x rho_y;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
model; model;
dx = rho_x*dx(-1)+e_x; dx = rho_x*dx(-1)+e_x;
dy = rho_y*dy(-1)+e_y; dy = rho_y*dy(-1)+e_y;
end; end;
estimated_params; estimated_params;
rho_x,NORMAL_PDF,0.5,0.1; rho_x,NORMAL_PDF,0.5,0.1;
rho_y,NORMAL_PDF,-0.3,0.1; rho_y,NORMAL_PDF,-0.3,0.1;
stderr e_x,INV_GAMMA_PDF,0.01,inf; stderr e_x,INV_GAMMA_PDF,0.01,inf;
stderr e_y,INV_GAMMA_PDF,0.01,inf; stderr e_y,INV_GAMMA_PDF,0.01,inf;
end; end;
varobs dx dy; varobs dx dy;
check; check;
estimation(datafile = bvar_sample, mh_replic = 1200, mh_jscale = 1.3, estimation(datafile = bvar_sample, mh_replic = 1200, mh_jscale = 1.3,
first_obs = 9); first_obs = 9);
bvar_density 8; bvar_density 8;
bvar_forecast(forecast = 10, bvar_replic = 2000, nobs = 200) 8; bvar_forecast(forecast = 10, bvar_replic = 2000, nobs = 200) 8;

View File

@ -1,23 +1,23 @@
var dx dy; var dx dy;
varexo e_x e_y; varexo e_x e_y;
parameters rho_x rho_y; parameters rho_x rho_y;
rho_x = 0.5; rho_x = 0.5;
rho_y = -0.3; rho_y = -0.3;
model; model;
dx = rho_x*dx(-1)+e_x; dx = rho_x*dx(-1)+e_x;
dy = rho_y*dy(-1)+e_y; dy = rho_y*dy(-1)+e_y;
end; end;
estimated_params; estimated_params;
rho_x,NORMAL_PDF,0.5,0.1; rho_x,NORMAL_PDF,0.5,0.1;
rho_y,NORMAL_PDF,-0.3,0.1; rho_y,NORMAL_PDF,-0.3,0.1;
stderr e_x,INV_GAMMA_PDF,0.01,inf; stderr e_x,INV_GAMMA_PDF,0.01,inf;
stderr e_y,INV_GAMMA_PDF,0.01,inf; stderr e_y,INV_GAMMA_PDF,0.01,inf;
end; end;
varobs dx dy; varobs dx dy;
check; check;
estimation(datafile=test,nobs=1000,mh_replic=2000,mh_jscale=1.3); estimation(datafile=test,nobs=1000,mh_replic=2000,mh_jscale=1.3);

View File

@ -1,44 +1,44 @@
// example 2 from Collard's guide to Dynare // example 2 from Collard's guide to Dynare
var y, c, k, a, h, b; var y, c, k, a, h, b;
varexo e,u; varexo e,u;
parameters beta, rho, beta, alpha, delta, theta, psi, tau ; parameters beta, rho, beta, alpha, delta, theta, psi, tau ;
alpha = 0.36; alpha = 0.36;
rho = 0.95; rho = 0.95;
tau = 0.025; tau = 0.025;
beta = 0.99; beta = 0.99;
delta = 0.025; delta = 0.025;
psi = 0; psi = 0;
theta = 2.95; theta = 2.95;
model; model;
exp(c)*theta*exp(h)^(1+psi)=(1-alpha)*exp(y); exp(c)*theta*exp(h)^(1+psi)=(1-alpha)*exp(y);
exp(k) = beta*(((exp(b)*exp(c))/(exp(b(+1))*exp(c(+1)))) exp(k) = beta*(((exp(b)*exp(c))/(exp(b(+1))*exp(c(+1))))
*(exp(b(+1))*alpha*exp(y(+1))+(1-delta)*exp(k))); *(exp(b(+1))*alpha*exp(y(+1))+(1-delta)*exp(k)));
exp(y) = exp(a)*(exp(k(-1))^alpha)*(exp(h)^(1-alpha)); exp(y) = exp(a)*(exp(k(-1))^alpha)*(exp(h)^(1-alpha));
exp(k) = exp(b)*(exp(y)-exp(c))+(1-delta)*exp(k(-1)); exp(k) = exp(b)*(exp(y)-exp(c))+(1-delta)*exp(k(-1));
a = rho*a(-1)+tau*b(-1) + e; a = rho*a(-1)+tau*b(-1) + e;
b = tau*a(-1)+rho*b(-1) + u; b = tau*a(-1)+rho*b(-1) + u;
end; end;
initval; initval;
y = 0.1; y = 0.1;
c = -0.2; c = -0.2;
h = -1.2; h = -1.2;
k = 2.4; k = 2.4;
a = 0; a = 0;
b = 0; b = 0;
e = 0; e = 0;
u = 0; u = 0;
end; end;
steady; steady;
shocks; shocks;
var e = 0.009^2; var e = 0.009^2;
var u = 0.009^2; var u = 0.009^2;
end; end;
stoch_simul(dr_algo=1,drop=200); stoch_simul(dr_algo=1,drop=200);

View File

@ -1,89 +1,89 @@
// This file replicates the estimation of the CIA model from // This file replicates the estimation of the CIA model from
// Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models" // Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models"
// Journal of Applied Econometrics, 15, 645-670. // Journal of Applied Econometrics, 15, 645-670.
// the data are the ones provided on Schorfheide's web site with the programs. // the data are the ones provided on Schorfheide's web site with the programs.
// http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP // http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP
// You need to have fsdat.m in the same directory as this file. // You need to have fsdat.m in the same directory as this file.
// This file replicates: // This file replicates:
// -the posterior mode as computed by Frank's Gauss programs // -the posterior mode as computed by Frank's Gauss programs
// -the parameter mean posterior estimates reported in the paper // -the parameter mean posterior estimates reported in the paper
// -the model probability (harmonic mean) reported in the paper // -the model probability (harmonic mean) reported in the paper
// This file was tested with dyn_mat_test_0218.zip // This file was tested with dyn_mat_test_0218.zip
// the smooth shocks are probably stil buggy // the smooth shocks are probably stil buggy
// //
// The equations are taken from J. Nason and T. Cogley (1994) // The equations are taken from J. Nason and T. Cogley (1994)
// "Testing the implications of long-run neutrality for monetary business // "Testing the implications of long-run neutrality for monetary business
// cycle models" Journal of Applied Econometrics, 9, S37-S70. // cycle models" Journal of Applied Econometrics, 9, S37-S70.
// Note that there is an initial minus sign missing in equation (A1), p. S63. // Note that there is an initial minus sign missing in equation (A1), p. S63.
// //
// Michel Juillard, February 2004 // Michel Juillard, February 2004
var m P c e W R k d n l gy_obs gp_obs y dA; var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model; model;
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; 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; -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; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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; 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); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
end; end;
initval; initval;
k = 6; k = 6;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
steady; steady;
estimated_params; estimated_params;
alp, beta_pdf, 0.356, 0.02; alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002; bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003; gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007; mst, normal_pdf, 1.0002, 0.007;
rho, beta_pdf, 0.129, 0.223; rho, beta_pdf, 0.129, 0.223;
psi, beta_pdf, 0.65, 0.05; psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005; del, beta_pdf, 0.01, 0.005;
stderr e_a, inv_gamma_pdf, 0.035449, inf; stderr e_a, inv_gamma_pdf, 0.035449, inf;
stderr e_m, inv_gamma_pdf, 0.008862, inf; stderr e_m, inv_gamma_pdf, 0.008862, inf;
end; end;
varobs gp_obs gy_obs; varobs gp_obs gy_obs;
estimation(datafile=fsdat,nobs=192,loglinear,mh_replic=2000,mh_nblocks=5,mh_jscale=0.8); estimation(datafile=fsdat,nobs=192,loglinear,mh_replic=2000,mh_nblocks=5,mh_jscale=0.8);

View File

@ -1,102 +1,102 @@
// This file replicates the estimation of the CIA model from // This file replicates the estimation of the CIA model from
// Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models" // Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models"
// Journal of Applied Econometrics, 15, 645-670. // Journal of Applied Econometrics, 15, 645-670.
// the data are the ones provided on Schorfheide's web site with the programs. // the data are the ones provided on Schorfheide's web site with the programs.
// http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP // http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP
// You need to have fsdat.m in the same directory as this file. // You need to have fsdat.m in the same directory as this file.
// This file replicates: // This file replicates:
// -the posterior mode as computed by Frank's Gauss programs // -the posterior mode as computed by Frank's Gauss programs
// -the parameter mean posterior estimates reported in the paper // -the parameter mean posterior estimates reported in the paper
// -the model probability (harmonic mean) reported in the paper // -the model probability (harmonic mean) reported in the paper
// This file was tested with dyn_mat_test_0218.zip // This file was tested with dyn_mat_test_0218.zip
// the smooth shocks are probably stil buggy // the smooth shocks are probably stil buggy
// //
// The equations are taken from J. Nason and T. Cogley (1994) // The equations are taken from J. Nason and T. Cogley (1994)
// "Testing the implications of long-run neutrality for monetary business // "Testing the implications of long-run neutrality for monetary business
// cycle models" Journal of Applied Econometrics, 9, S37-S70. // cycle models" Journal of Applied Econometrics, 9, S37-S70.
// Note that there is an initial minus sign missing in equation (A1), p. S63. // Note that there is an initial minus sign missing in equation (A1), p. S63.
// //
// Michel Juillard, February 2004 // Michel Juillard, February 2004
var m P c e W R k d n l gy_obs gp_obs Y_obs P_obs y dA; 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; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model; model;
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; 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; -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; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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; 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); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
Y_obs/Y_obs(-1) = gy_obs; Y_obs/Y_obs(-1) = gy_obs;
P_obs/P_obs(-1) = gp_obs; P_obs/P_obs(-1) = gp_obs;
end; end;
initval; initval;
k = 6; k = 6;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
steady; steady;
check; check;
estimated_params; estimated_params;
alp, beta_pdf, 0.356, 0.02; alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002; bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003; gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007; mst, normal_pdf, 1.0002, 0.007;
rho, beta_pdf, 0.129, 0.223; rho, beta_pdf, 0.129, 0.223;
psi, beta_pdf, 0.65, 0.05; psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005; del, beta_pdf, 0.01, 0.005;
stderr e_a, inv_gamma_pdf, 0.035449, inf; stderr e_a, inv_gamma_pdf, 0.035449, inf;
stderr e_m, inv_gamma_pdf, 0.008862, inf; stderr e_m, inv_gamma_pdf, 0.008862, inf;
end; end;
varobs P_obs Y_obs; varobs P_obs Y_obs;
observation_trends; observation_trends;
P_obs (log(mst)-gam); P_obs (log(mst)-gam);
Y_obs (gam); Y_obs (gam);
end; end;
unit_root_vars P_obs Y_obs; unit_root_vars P_obs Y_obs;
//stoch_simul(order=1,nomoments,irf=0); //stoch_simul(order=1,nomoments,irf=0);
estimation(datafile=fsdat,nobs=192,loglinear,mh_replic=0,mh_nblocks=2,mh_drop=0.45,mode_compute=0,mode_file=fs2000b_mode,load_mh_file); estimation(datafile=fsdat,nobs=192,loglinear,mh_replic=0,mh_nblocks=2,mh_drop=0.45,mode_compute=0,mode_file=fs2000b_mode,load_mh_file);
stab_map_; stab_map_;

View File

@ -1,59 +1,59 @@
/* Used to check that Dynare++ and Dynare with k_order_solver=1 give the same result */ /* Used to check that Dynare++ and Dynare with k_order_solver=1 give the same result */
var m m_1 P P_1 c e W R k d n l gy_obs gp_obs y dA P2 c2; var m m_1 P P_1 c e W R k d n l gy_obs gp_obs y dA P2 c2;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model; model;
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m_1(-1))+e_m; log(m) = (1-rho)*log(mst) + rho*log(m_1(-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)))))/(c2(+1)*P2(+1)*m(+1))=0; -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)))))/(c2(+1)*P2(+1)*m(+1))=0;
W = l/n; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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; 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); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P_1(-1))*m_1(-1)/dA; gp_obs = (P/P_1(-1))*m_1(-1)/dA;
P2 = P(+1); P2 = P(+1);
c2 = c(+1); c2 = c(+1);
m_1 = m; m_1 = m;
P_1 = P; P_1 = P;
end; end;
initval; initval;
m = mst; m = mst;
m_1=mst; m_1=mst;
P = 2.25; P = 2.25;
P_1 = 2.25; P_1 = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
k = 6; k = 6;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
P2=P; P2=P;
c2=c; c2=c;
end; end;
vcov = [0.014, 0;0, 0.005]; vcov = [0.014, 0;0, 0.005];

View File

@ -1,87 +1,87 @@
/* Checks that, for order = 2, k_order_solver = 0 (fs2000k2a) /* Checks that, for order = 2, k_order_solver = 0 (fs2000k2a)
and k_order_solver = 1 (this file) give the same results */ and k_order_solver = 1 (this file) give the same results */
var m P c e W R k d n l gy_obs gp_obs y dA ; var m P c e W R k d n l gy_obs gp_obs y dA ;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model (use_dll); model (use_dll);
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; 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; -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; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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; 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); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
end; end;
initval; initval;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
k = 6; k = 6;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
steady; steady;
stoch_simul(order=2,k_order_solver,periods=1000); stoch_simul(order=2,k_order_solver,periods=1000);
if ~exist('fs2000k2a_results.mat','file'); if ~exist('fs2000k2a_results.mat','file');
error('fs2000k2a must be run first'); error('fs2000k2a must be run first');
end; end;
oo1 = load('fs2000k2a_results','oo_'); oo1 = load('fs2000k2a_results','oo_');
dr0 = oo1.oo_.dr; dr0 = oo1.oo_.dr;
dr = oo_.dr; dr = oo_.dr;
if max(max(abs(dr0.ghx - dr.ghx))) > 1e-12; if max(max(abs(dr0.ghx - dr.ghx))) > 1e-12;
error('error in ghx'); error('error in ghx');
end; end;
if max(max(abs(dr0.ghu - dr.ghu))) > 1e-12; if max(max(abs(dr0.ghu - dr.ghu))) > 1e-12;
error('error in ghu'); error('error in ghu');
end; end;
if max(max(abs(dr0.ghxx - dr.ghxx))) > 1e-12; if max(max(abs(dr0.ghxx - dr.ghxx))) > 1e-12;
error('error in ghxx'); error('error in ghxx');
end; end;
if max(max(abs(dr0.ghuu - dr.ghuu))) > 1e-12; if max(max(abs(dr0.ghuu - dr.ghuu))) > 1e-12;
error('error in ghuu'); error('error in ghuu');
end; end;
if max(max(abs(dr0.ghxu - dr.ghxu))) > 1e-12; if max(max(abs(dr0.ghxu - dr.ghxu))) > 1e-12;
error('error in ghxu'); error('error in ghxu');
end; end;
if max(max(abs(dr0.ghs2 - dr.ghs2))) > 1e-12; if max(max(abs(dr0.ghs2 - dr.ghs2))) > 1e-12;
error('error in ghs2'); error('error in ghs2');
end; end;

View File

@ -1,60 +1,60 @@
/* Checks that, for order = 2, k_order_solver = 0 (this file) /* Checks that, for order = 2, k_order_solver = 0 (this file)
and k_order_solver = 1 (fs2000k2) give the same results */ and k_order_solver = 1 (fs2000k2) give the same results */
var m P c e W R k d n l gy_obs gp_obs y dA ; var m P c e W R k d n l gy_obs gp_obs y dA ;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model; model;
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; 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; -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; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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; 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); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
end; end;
initval; initval;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
k = 6; k = 6;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
steady; steady;
stoch_simul(order=2); stoch_simul(order=2);

View File

@ -1,80 +1,80 @@
// checks whether second order coefficients are the same with order=2 and order=3 with k_order_solver=1 // checks whether second order coefficients are the same with order=2 and order=3 with k_order_solver=1
var m P c e W R k d n l gy_obs gp_obs y dA ; var m P c e W R k d n l gy_obs gp_obs y dA ;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model (use_dll); model (use_dll);
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; 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; -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; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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; 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); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P(-1))*m(-1)/dA; gp_obs = (P/P(-1))*m(-1)/dA;
end; end;
initval; initval;
m = mst; m = mst;
P = 2.25; P = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
k = 6; k = 6;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
steady; steady;
stoch_simul(order=3,periods=1000); stoch_simul(order=3,periods=1000);
if ~exist('fs2000k2a_results.mat','file'); if ~exist('fs2000k2a_results.mat','file');
error('fs2000k2a must be run first'); error('fs2000k2a must be run first');
end; end;
oo1 = load('fs2000k2a_results','oo_'); oo1 = load('fs2000k2a_results','oo_');
dr0 = oo1.oo_.dr; dr0 = oo1.oo_.dr;
dr = oo_.dr; dr = oo_.dr;
if max(max(abs(dr0.ghxx - dr.ghxx))) > 1e-12; if max(max(abs(dr0.ghxx - dr.ghxx))) > 1e-12;
error('error in ghxx'); error('error in ghxx');
end; end;
if max(max(abs(dr0.ghuu - dr.ghuu))) > 1e-12; if max(max(abs(dr0.ghuu - dr.ghuu))) > 1e-12;
error('error in ghuu'); error('error in ghuu');
end; end;
if max(max(abs(dr0.ghxu - dr.ghxu))) > 1e-12; if max(max(abs(dr0.ghxu - dr.ghxu))) > 1e-12;
error('error in ghxu'); error('error in ghxu');
end; end;
if max(max(abs(dr0.ghs2 - dr.ghs2))) > 1e-12; if max(max(abs(dr0.ghs2 - dr.ghs2))) > 1e-12;
error('error in ghs2'); error('error in ghs2');
end; end;

View File

@ -1,98 +1,98 @@
/* Checks that, for order = 2 and k_order_solver = 1, a model with 2 leads /* Checks that, for order = 2 and k_order_solver = 1, a model with 2 leads
and the same model with one lead (using auxiliary vars) give the same result */ and the same model with one lead (using auxiliary vars) give the same result */
var m m_1 P P_1 c e W R k d n l gy_obs gp_obs y dA AUXv; var m m_1 P P_1 c e W R k d n l gy_obs gp_obs y dA AUXv;
varexo e_a e_m; varexo e_a e_m;
parameters alp bet gam mst rho psi del; parameters alp bet gam mst rho psi del;
alp = 0.33; alp = 0.33;
bet = 0.99; bet = 0.99;
gam = 0.003; gam = 0.003;
mst = 1.011; mst = 1.011;
rho = 0.7; rho = 0.7;
psi = 0.787; psi = 0.787;
del = 0.02; del = 0.02;
model(use_dll); model(use_dll);
dA = exp(gam+e_a); dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m_1(-1))+e_m; log(m) = (1-rho)*log(mst) + rho*log(m_1(-1))+e_m;
-P/(c(+1)*P(+1)*m)+AUXv(+1)=0; -P/(c(+1)*P(+1)*m)+AUXv(+1)=0;
W = l/n; W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -(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; 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; 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); c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m; P*c = m;
m-1+d = l; m-1+d = l;
e = exp(e_a); e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)); y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-1); gy_obs = dA*y/y(-1);
gp_obs = (P/P_1(-1))*m_1(-1)/dA; gp_obs = (P/P_1(-1))*m_1(-1)/dA;
m_1 = m; m_1 = m;
P_1 = P; P_1 = P;
AUXv = bet*P*(alp*exp(-alp*(gam+log(e)))*k(-1)^(alp-1)*n^(1-alp)+(1-del)*exp(-(gam+log(e))))/(c(+1)*P(+1)*m); AUXv = bet*P*(alp*exp(-alp*(gam+log(e)))*k(-1)^(alp-1)*n^(1-alp)+(1-del)*exp(-(gam+log(e))))/(c(+1)*P(+1)*m);
end; end;
initval; initval;
m = mst; m = mst;
m_1=mst; m_1=mst;
P = 2.25; P = 2.25;
P_1 = 2.25; P_1 = 2.25;
c = 0.45; c = 0.45;
e = 1; e = 1;
W = 4; W = 4;
R = 1.02; R = 1.02;
k = 6; k = 6;
d = 0.85; d = 0.85;
n = 0.19; n = 0.19;
l = 0.86; l = 0.86;
y = 0.6; y = 0.6;
gy_obs = exp(gam); gy_obs = exp(gam);
gp_obs = exp(-gam); gp_obs = exp(-gam);
dA = exp(gam); dA = exp(gam);
AUXv = 1; AUXv = 1;
end; end;
shocks; shocks;
var e_a; stderr 0.014; var e_a; stderr 0.014;
var e_m; stderr 0.005; var e_m; stderr 0.005;
end; end;
steady; steady;
stoch_simul(order=2,k_order_solver,irf=0); stoch_simul(order=2,k_order_solver,irf=0);
if ~exist('fs2000k2_results.mat','file'); if ~exist('fs2000k2_results.mat','file');
error('fs2000k2 must be run first'); error('fs2000k2 must be run first');
end; end;
oo1 = load('fs2000k2_results','oo_'); oo1 = load('fs2000k2_results','oo_');
dr0 = oo1.oo_.dr; dr0 = oo1.oo_.dr;
dr = oo_.dr; dr = oo_.dr;
ikr = [2:10 1 13:17]; ikr = [2:10 1 13:17];
ikc = [1 3 4 2]; ikc = [1 3 4 2];
ikc2 = [1 3 4 2 9 11 12 10 13 15 16 14 5 7 8 6]; ikc2 = [1 3 4 2 9 11 12 10 13 15 16 14 5 7 8 6];
ikc2u = [1 2 5 6 7 8 3 4]; ikc2u = [1 2 5 6 7 8 3 4];
if max(max(abs(dr0.ghx - dr.ghx(ikr,ikc)))) > 1e-12; if max(max(abs(dr0.ghx - dr.ghx(ikr,ikc)))) > 1e-12;
error('error in ghx'); error('error in ghx');
end; end;
if max(max(abs(dr0.ghu - dr.ghu(ikr,:)))) > 1e-12; if max(max(abs(dr0.ghu - dr.ghu(ikr,:)))) > 1e-12;
error('error in ghu'); error('error in ghu');
end; end;
if max(max(abs(dr0.ghxx - dr.ghxx(ikr,ikc2)))) > 1e-12; if max(max(abs(dr0.ghxx - dr.ghxx(ikr,ikc2)))) > 1e-12;
error('error in ghxx'); error('error in ghxx');
end; end;
if max(max(abs(dr0.ghuu - dr.ghuu(ikr,:)))) > 1e-12; if max(max(abs(dr0.ghuu - dr.ghuu(ikr,:)))) > 1e-12;
error('error in ghuu'); error('error in ghuu');
end; end;
if max(max(abs(dr0.ghxu - dr.ghxu(ikr,ikc2u)))) > 1e-12; if max(max(abs(dr0.ghxu - dr.ghxu(ikr,ikc2u)))) > 1e-12;
error('error in ghxu'); error('error in ghxu');
end; end;
if max(max(abs(dr0.ghs2 - dr.ghs2(ikr,:)))) > 1e-12; if max(max(abs(dr0.ghs2 - dr.ghs2(ikr,:)))) > 1e-12;
error('error in ghs2'); error('error in ghs2');
end; end;

View File

@ -1,53 +1,53 @@
var z dw dx dy dc1 dc2; var z dw dx dy dc1 dc2;
varexo e_w e_x e_y e_z; varexo e_w e_x e_y e_z;
parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c; parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c;
model(linear); model(linear);
dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w; dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w;
dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x; dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x;
dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y; dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y;
z = rho_z*z(-1)+dw-dx+e_z; z = rho_z*z(-1)+dw-dx+e_z;
dc1 = dc1(-1)+dx-b*dy-c*dw; dc1 = dc1(-1)+dx-b*dy-c*dw;
dc2 = dc2(-1)+dx-b*dy; dc2 = dc2(-1)+dx-b*dy;
end; end;
estimated_params; estimated_params;
rho_w, normal_pdf, 0.5,0.2; rho_w, normal_pdf, 0.5,0.2;
rho_x, normal_pdf, 0.5,0.2; rho_x, normal_pdf, 0.5,0.2;
rho_y, normal_pdf, 0.5,0.2; rho_y, normal_pdf, 0.5,0.2;
rho_z, normal_pdf, 0.8,0.2; rho_z, normal_pdf, 0.8,0.2;
a1, normal_pdf, 0.1,0.2; a1, normal_pdf, 0.1,0.2;
a2, normal_pdf, -0.1,0.2; a2, normal_pdf, -0.1,0.2;
a3, normal_pdf, 0.1,0.2; a3, normal_pdf, 0.1,0.2;
b , normal_pdf, 1,0.2; b , normal_pdf, 1,0.2;
c , normal_pdf, 1,0.2; c , normal_pdf, 1,0.2;
stderr e_w, uniform_pdf,,, 0.01, 0.1; stderr e_w, uniform_pdf,,, 0.01, 0.1;
stderr e_x, 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_y, uniform_pdf,,, 0.01, 0.1;
stderr e_z, uniform_pdf,,, 0.01, 0.1; stderr e_z, uniform_pdf,,, 0.01, 0.1;
end; end;
varobs dw dx dy z; 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);
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo1_mode); estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo1_mode);
//checking smoother consistency //checking smoother consistency
X = oo_.SmoothedVariables; X = oo_.SmoothedVariables;
S = [X.z X.dw X.dx X.dy X.dc1 X.dc2]; S = [X.z X.dw X.dx X.dy X.dc1 X.dc2];
X = oo_.SmoothedShocks; X = oo_.SmoothedShocks;
E = [X.e_w X.e_x X.e_y X.e_z]; E = [X.e_w X.e_x X.e_y X.e_z];
A = oo_.dr.ghx; A = oo_.dr.ghx;
B = oo_.dr.ghu; B = oo_.dr.ghu;
err = zeros(6,200); err = zeros(6,200);
for t=2:200; for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)'; err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end; end;
disp(max(max(abs(err)))); disp(max(max(abs(err))));
d=load('data'); d=load('data');
dat = [d.dw d.dx d.dy d.z]; dat = [d.dw d.dx d.dy d.z];
disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1]))))); disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])))));

View File

@ -1,81 +1,81 @@
var z dw dx dy dc1 dc2; var z dw dx dy dc1 dc2;
varexo e_w e_x e_y e_z; varexo e_w e_x e_y e_z;
parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c; parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c;
model(linear); model(linear);
dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w; dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w;
dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x; dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x;
dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y; dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y;
z = rho_z*z(-1)+dw-dx+e_z; z = rho_z*z(-1)+dw-dx+e_z;
dc1 = dc1(-1)+dx-b*dy-c*dw; dc1 = dc1(-1)+dx-b*dy-c*dw;
dc2 = dc2(-1)+dx-b*dy; dc2 = dc2(-1)+dx-b*dy;
end; end;
estimated_params; estimated_params;
rho_w, normal_pdf, 0.5,0.2; rho_w, normal_pdf, 0.5,0.2;
rho_x, normal_pdf, 0.5,0.2; rho_x, normal_pdf, 0.5,0.2;
rho_y, normal_pdf, 0.5,0.2; rho_y, normal_pdf, 0.5,0.2;
rho_z, normal_pdf, 0.8,0.2; rho_z, normal_pdf, 0.8,0.2;
a1, normal_pdf, 0.1,0.2; a1, normal_pdf, 0.1,0.2;
a2, normal_pdf, -0.1,0.2; a2, normal_pdf, -0.1,0.2;
a3, normal_pdf, 0.1,0.2; a3, normal_pdf, 0.1,0.2;
b , normal_pdf, 1,0.2; b , normal_pdf, 1,0.2;
c , normal_pdf, 1,0.2; c , normal_pdf, 1,0.2;
stderr e_w, uniform_pdf,,, 0.01, 0.1; stderr e_w, uniform_pdf,,, 0.01, 0.1;
stderr e_x, 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_y, uniform_pdf,,, 0.01, 0.1;
stderr e_z, uniform_pdf,,, 0.01, 0.1; stderr e_z, uniform_pdf,,, 0.01, 0.1;
end; end;
varobs dw dx dy z; 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,kalman_algo=2);
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo1_mode,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 //checking smoother consistency
X = oo_.SmoothedVariables; X = oo_.SmoothedVariables;
S = [X.z X.dw X.dx X.dy X.dc1 X.dc2]; S = [X.z X.dw X.dx X.dy X.dc1 X.dc2];
X = oo_.SmoothedShocks; X = oo_.SmoothedShocks;
E = [X.e_w X.e_x X.e_y X.e_z]; E = [X.e_w X.e_x X.e_y X.e_z];
A = oo_.dr.ghx; A = oo_.dr.ghx;
B = oo_.dr.ghu; B = oo_.dr.ghu;
err = zeros(6,200); err = zeros(6,200);
for t=2:200; for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)'; err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end; end;
disp(max(max(abs(err)))); disp(max(max(abs(err))));
d=load('data'); d=load('data');
dat = [d.dw d.dx d.dy d.z]; dat = [d.dw d.dx d.dy d.z];
disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1]))))); disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])))));
o1 = load('algo1_results'); o1 = load('algo1_results');
obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'}; obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'};
obj_exo = {'SmoothedShocks';}; obj_exo = {'SmoothedShocks';};
nobj_endo = size(obj_endo,1); nobj_endo = size(obj_endo,1);
nobj_exo = size(obj_exo,1); nobj_exo = size(obj_exo,1);
for i=1:nobj_endo; for i=1:nobj_endo;
err_endo = zeros(eval(['size(oo_.' obj_endo{i} '.' M_.endo_names(1,:) ',1);']),M_.endo_nbr); err_endo = zeros(eval(['size(oo_.' obj_endo{i} '.' M_.endo_names(1,:) ',1);']),M_.endo_nbr);
for j=1:M_.endo_nbr; for j=1:M_.endo_nbr;
var1 = eval(['o1.oo_.' obj_endo{i} '.' M_.endo_names(j,:)]); var1 = eval(['o1.oo_.' obj_endo{i} '.' M_.endo_names(j,:)]);
var2 = eval(['oo_.' obj_endo{i} '.' M_.endo_names(j,:)]); var2 = eval(['oo_.' obj_endo{i} '.' M_.endo_names(j,:)]);
err_endo(:,j) = var1-var2; err_endo(:,j) = var1-var2;
end; end;
disp(max(max(abs(err_endo)))); disp(max(max(abs(err_endo))));
end; end;
err_exo = zeros(200,M_.exo_nbr,nobj_exo); err_exo = zeros(200,M_.exo_nbr,nobj_exo);
for i=1:nobj_exo; for i=1:nobj_exo;
err_exo = zeros(size(eval(['oo_.' obj_exo{i} '.' M_.exo_names(1,:)]),1),M_.exo_nbr); err_exo = zeros(size(eval(['oo_.' obj_exo{i} '.' M_.exo_names(1,:)]),1),M_.exo_nbr);
for j=1:M_.exo_nbr; for j=1:M_.exo_nbr;
var1 = eval(['o1.oo_.' obj_exo{i} '.' M_.exo_names(j,:)]); var1 = eval(['o1.oo_.' obj_exo{i} '.' M_.exo_names(j,:)]);
var2 = eval(['oo_.' obj_exo{i} '.' M_.exo_names(j,:)]); var2 = eval(['oo_.' obj_exo{i} '.' M_.exo_names(j,:)]);
err_exo(:,j,i) = var1 - var2; err_exo(:,j,i) = var1 - var2;
end; end;
disp(max(max(abs(err_exo)))); disp(max(max(abs(err_exo))));
end; end;
disp(max(max(max(abs(err_exo))))); disp(max(max(max(abs(err_exo)))));

View File

@ -1,56 +1,56 @@
var z dw dx dy dc1 dc2 w x y; var z dw dx dy dc1 dc2 w x y;
varexo e_w e_x e_y e_z; varexo e_w e_x e_y e_z;
parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c; parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c;
model(linear); model(linear);
dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w; dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w;
dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x; dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x;
dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y; dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y;
z = rho_z*z(-1)+dw-dx+e_z; z = rho_z*z(-1)+dw-dx+e_z;
dc1 = dc1(-1)+dx-b*dy-c*dw; dc1 = dc1(-1)+dx-b*dy-c*dw;
dc2 = dc2(-1)+dx-b*dy; dc2 = dc2(-1)+dx-b*dy;
w = w(-1) + dw; w = w(-1) + dw;
x = x(-1) + dx; x = x(-1) + dx;
y = y(-1) + dy; y = y(-1) + dy;
end; end;
estimated_params; estimated_params;
rho_w, normal_pdf, 0.5,0.2; rho_w, normal_pdf, 0.5,0.2;
rho_x, normal_pdf, 0.5,0.2; rho_x, normal_pdf, 0.5,0.2;
rho_y, normal_pdf, 0.5,0.2; rho_y, normal_pdf, 0.5,0.2;
rho_z, normal_pdf, 0.8,0.2; rho_z, normal_pdf, 0.8,0.2;
a1, normal_pdf, 0.1,0.2; a1, normal_pdf, 0.1,0.2;
a2, normal_pdf, -0.1,0.2; a2, normal_pdf, -0.1,0.2;
a3, normal_pdf, 0.1,0.2; a3, normal_pdf, 0.1,0.2;
b , normal_pdf, 1,0.2; b , normal_pdf, 1,0.2;
c , normal_pdf, 1,0.2; c , normal_pdf, 1,0.2;
stderr e_w, uniform_pdf,,, 0.01, 0.1; stderr e_w, uniform_pdf,,, 0.01, 0.1;
stderr e_x, 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_y, uniform_pdf,,, 0.01, 0.1;
stderr e_z, inv_gamma_pdf,0.01, inf; stderr e_z, inv_gamma_pdf,0.01, inf;
end; end;
varobs w x y; 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,diffuse_filter);
//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo3_mode,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 //checking smoother consistency
X = oo_.SmoothedVariables; X = oo_.SmoothedVariables;
S = [X.z X.dw X.dx X.dy X.dc1 X.dc2 X.w X.x X.y]; S = [X.z X.dw X.dx X.dy X.dc1 X.dc2 X.w X.x X.y];
X = oo_.SmoothedShocks; X = oo_.SmoothedShocks;
E = [X.e_w X.e_x X.e_y X.e_z]; E = [X.e_w X.e_x X.e_y X.e_z];
A = oo_.dr.ghx; A = oo_.dr.ghx;
B = oo_.dr.ghu; B = oo_.dr.ghu;
err = zeros(M_.endo_nbr,200); err = zeros(M_.endo_nbr,200);
for t=2:200; for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)'; err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end; end;
disp(max(max(abs(err)))); disp(max(max(abs(err))));
d=load('data'); d=load('data');
dat = [d.w d.x d.y]; dat = [d.w d.x d.y];
disp(max(max(abs(dat(1000:1199,:)-S(:,[7:9]))))); disp(max(max(abs(dat(1000:1199,:)-S(:,[7:9])))));

View File

@ -1,84 +1,84 @@
var z dw dx dy dc1 dc2 w x y; var z dw dx dy dc1 dc2 w x y;
varexo e_w e_x e_y e_z; varexo e_w e_x e_y e_z;
parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c; parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c;
model(linear); model(linear);
dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w; dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w;
dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x; dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x;
dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y; dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y;
z = rho_z*z(-1)+dw-dx+e_z; z = rho_z*z(-1)+dw-dx+e_z;
dc1 = dc1(-1)+dx-b*dy-c*dw; dc1 = dc1(-1)+dx-b*dy-c*dw;
dc2 = dc2(-1)+dx-b*dy; dc2 = dc2(-1)+dx-b*dy;
w = w(-1) + dw; w = w(-1) + dw;
x = x(-1) + dx; x = x(-1) + dx;
y = y(-1) + dy; y = y(-1) + dy;
end; end;
estimated_params; estimated_params;
rho_w, normal_pdf, 0.5,0.2; rho_w, normal_pdf, 0.5,0.2;
rho_x, normal_pdf, 0.5,0.2; rho_x, normal_pdf, 0.5,0.2;
rho_y, normal_pdf, 0.5,0.2; rho_y, normal_pdf, 0.5,0.2;
rho_z, normal_pdf, 0.8,0.2; rho_z, normal_pdf, 0.8,0.2;
a1, normal_pdf, 0.1,0.2; a1, normal_pdf, 0.1,0.2;
a2, normal_pdf, -0.1,0.2; a2, normal_pdf, -0.1,0.2;
a3, normal_pdf, 0.1,0.2; a3, normal_pdf, 0.1,0.2;
b , normal_pdf, 1,0.2; b , normal_pdf, 1,0.2;
c , normal_pdf, 1,0.2; c , normal_pdf, 1,0.2;
stderr e_w, uniform_pdf,,, 0.01, 0.1; stderr e_w, uniform_pdf,,, 0.01, 0.1;
stderr e_x, 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_y, uniform_pdf,,, 0.01, 0.1;
stderr e_z, inv_gamma_pdf,0.01, inf; stderr e_z, inv_gamma_pdf,0.01, inf;
end; end;
varobs w x y; 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,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); 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 //checking smoother consistency
X = oo_.SmoothedVariables; X = oo_.SmoothedVariables;
S = [X.z X.dw X.dx X.dy X.dc1 X.dc2 X.w X.x X.y]; S = [X.z X.dw X.dx X.dy X.dc1 X.dc2 X.w X.x X.y];
X = oo_.SmoothedShocks; X = oo_.SmoothedShocks;
E = [X.e_w X.e_x X.e_y X.e_z]; E = [X.e_w X.e_x X.e_y X.e_z];
A = oo_.dr.ghx; A = oo_.dr.ghx;
B = oo_.dr.ghu; B = oo_.dr.ghu;
err = zeros(M_.endo_nbr,200); err = zeros(M_.endo_nbr,200);
for t=2:200; for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)'; err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end; end;
disp(max(max(abs(err)))); disp(max(max(abs(err))));
d=load('data'); d=load('data');
dat = [d.w d.x d.y]; dat = [d.w d.x d.y];
disp(max(max(abs(dat(1000:1199,:)-S(:,[7:9]))))); disp(max(max(abs(dat(1000:1199,:)-S(:,[7:9])))));
o1 = load('algo3_results'); o1 = load('algo3_results');
obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'}; obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'};
obj_exo = {'SmoothedShocks';}; obj_exo = {'SmoothedShocks';};
nobj_endo = size(obj_endo,1); nobj_endo = size(obj_endo,1);
nobj_exo = size(obj_exo,1); nobj_exo = size(obj_exo,1);
for i=1:nobj_endo; for i=1:nobj_endo;
err_endo = zeros(eval(['size(oo_.' obj_endo{i} '.' M_.endo_names(1,:) ',1);']),M_.endo_nbr); err_endo = zeros(eval(['size(oo_.' obj_endo{i} '.' M_.endo_names(1,:) ',1);']),M_.endo_nbr);
for j=1:M_.endo_nbr; for j=1:M_.endo_nbr;
var1 = eval(['o1.oo_.' obj_endo{i} '.' M_.endo_names(j,:)]); var1 = eval(['o1.oo_.' obj_endo{i} '.' M_.endo_names(j,:)]);
var2 = eval(['oo_.' obj_endo{i} '.' M_.endo_names(j,:)]); var2 = eval(['oo_.' obj_endo{i} '.' M_.endo_names(j,:)]);
err_endo(:,j) = var1-var2; err_endo(:,j) = var1-var2;
end; end;
disp(max(max(abs(err_endo)))); disp(max(max(abs(err_endo))));
end; end;
err_exo = zeros(200,M_.exo_nbr,nobj_exo); err_exo = zeros(200,M_.exo_nbr,nobj_exo);
for i=1:nobj_exo; for i=1:nobj_exo;
err_exo = zeros(size(eval(['oo_.' obj_exo{i} '.' M_.exo_names(1,:)]),1),M_.exo_nbr); err_exo = zeros(size(eval(['oo_.' obj_exo{i} '.' M_.exo_names(1,:)]),1),M_.exo_nbr);
for j=1:M_.exo_nbr; for j=1:M_.exo_nbr;
var1 = eval(['o1.oo_.' obj_exo{i} '.' M_.exo_names(j,:)]); var1 = eval(['o1.oo_.' obj_exo{i} '.' M_.exo_names(j,:)]);
var2 = eval(['oo_.' obj_exo{i} '.' M_.exo_names(j,:)]); var2 = eval(['oo_.' obj_exo{i} '.' M_.exo_names(j,:)]);
err_exo(:,j,i) = var1 - var2; err_exo(:,j,i) = var1 - var2;
end; end;
disp(max(max(abs(err_exo)))); disp(max(max(abs(err_exo))));
end; end;
disp(max(max(max(abs(err_exo))))); disp(max(max(max(abs(err_exo)))));

View File

@ -1,54 +1,54 @@
var z dw dx dy dc1 dc2 y; var z dw dx dy dc1 dc2 y;
varexo e_w e_x e_y e_z; varexo e_w e_x e_y e_z;
parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c; parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c;
model(linear); model(linear);
dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w; dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w;
dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x; dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x;
dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y; dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y;
z = rho_z*z(-1)+dw-dx+e_z; z = rho_z*z(-1)+dw-dx+e_z;
dc1 = dc1(-1)+dx-b*dy-c*dw; dc1 = dc1(-1)+dx-b*dy-c*dw;
dc2 = dc2(-1)+dx-b*dy; dc2 = dc2(-1)+dx-b*dy;
y = y(-1) + dy; y = y(-1) + dy;
end; end;
estimated_params; estimated_params;
rho_w, normal_pdf, 0.5,0.2; rho_w, normal_pdf, 0.5,0.2;
rho_x, normal_pdf, 0.5,0.2; rho_x, normal_pdf, 0.5,0.2;
rho_y, normal_pdf, 0.5,0.2; rho_y, normal_pdf, 0.5,0.2;
rho_z, normal_pdf, 0.8,0.2; rho_z, normal_pdf, 0.8,0.2;
a1, normal_pdf, 0.1,0.2; a1, normal_pdf, 0.1,0.2;
a2, normal_pdf, -0.1,0.2; a2, normal_pdf, -0.1,0.2;
a3, normal_pdf, 0.1,0.2; a3, normal_pdf, 0.1,0.2;
b , normal_pdf, 1,0.2; b , normal_pdf, 1,0.2;
c , normal_pdf, 1,0.2; c , normal_pdf, 1,0.2;
stderr e_w, uniform_pdf,,, 0.01, 0.1; stderr e_w, uniform_pdf,,, 0.01, 0.1;
stderr e_x, 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_y, uniform_pdf,,, 0.01, 0.1;
stderr e_z, uniform_pdf,,, 0.01, 0.1; stderr e_z, uniform_pdf,,, 0.01, 0.1;
end; end;
varobs dw dx y z; 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,diffuse_filter);
//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo3_mode,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 //checking smoother consistency
X = oo_.SmoothedVariables; X = oo_.SmoothedVariables;
S = [X.z X.dw X.dx X.dy X.dc1 X.dc2 X.y]; S = [X.z X.dw X.dx X.dy X.dc1 X.dc2 X.y];
X = oo_.SmoothedShocks; X = oo_.SmoothedShocks;
E = [X.e_w X.e_x X.e_y X.e_z]; E = [X.e_w X.e_x X.e_y X.e_z];
A = oo_.dr.ghx; A = oo_.dr.ghx;
B = oo_.dr.ghu; B = oo_.dr.ghu;
err = zeros(M_.endo_nbr,200); err = zeros(M_.endo_nbr,200);
for t=2:200; for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)'; err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end; end;
disp(max(max(abs(err)))); disp(max(max(abs(err))));
d=load('data'); d=load('data');
dat = [d.dw d.dx d.y d.z]; dat = [d.dw d.dx d.y d.z];
disp(max(max(abs(dat(1000:1199,:)-S(:,[2 3 7 1]))))); disp(max(max(abs(dat(1000:1199,:)-S(:,[2 3 7 1])))));

View File

@ -1,57 +1,57 @@
var z dw dx dy dc1 dc2; var z dw dx dy dc1 dc2;
varexo e_w e_x e_y e_z; varexo e_w e_x e_y e_z;
parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c; parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c;
model(linear); model(linear);
dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w; dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w;
dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x; dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x;
dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y; dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y;
z = rho_z*z(-1)+dw-dx+e_z; z = rho_z*z(-1)+dw-dx+e_z;
dc1 = dc1(-1)+dx-b*dy-c*dw; dc1 = dc1(-1)+dx-b*dy-c*dw;
dc2 = dc2(-1)+dx-b*dy; dc2 = dc2(-1)+dx-b*dy;
end; end;
estimated_params; estimated_params;
rho_w, normal_pdf, 0.5,0.2; rho_w, normal_pdf, 0.5,0.2;
rho_x, normal_pdf, 0.5,0.2; rho_x, normal_pdf, 0.5,0.2;
rho_y, normal_pdf, 0.5,0.2; rho_y, normal_pdf, 0.5,0.2;
rho_z, normal_pdf, 0.8,0.2; rho_z, normal_pdf, 0.8,0.2;
a1, normal_pdf, 0.1,0.2; a1, normal_pdf, 0.1,0.2;
a2, normal_pdf, -0.1,0.2; a2, normal_pdf, -0.1,0.2;
a3, normal_pdf, 0.1,0.2; a3, normal_pdf, 0.1,0.2;
b , normal_pdf, 1,0.2; b , normal_pdf, 1,0.2;
c , normal_pdf, 1,0.2; c , normal_pdf, 1,0.2;
stderr e_w, uniform_pdf,,, 0.01, 0.1; stderr e_w, uniform_pdf,,, 0.01, 0.1;
stderr e_x, 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_y, uniform_pdf,,, 0.01, 0.1;
stderr e_z, uniform_pdf,,, 0.01, 0.1; stderr e_z, uniform_pdf,,, 0.01, 0.1;
stderr z, normal_pdf, 0, 0.1; stderr z, normal_pdf, 0, 0.1;
end; end;
varobs dw dx dy z; 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);
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algoH1_mode); estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algoH1_mode);
//checking smoother consistency //checking smoother consistency
X = oo_.SmoothedVariables; X = oo_.SmoothedVariables;
S = [X.z X.dw X.dx X.dy X.dc1 X.dc2]; S = [X.z X.dw X.dx X.dy X.dc1 X.dc2];
X = oo_.SmoothedShocks; X = oo_.SmoothedShocks;
E = [X.e_w X.e_x X.e_y X.e_z]; E = [X.e_w X.e_x X.e_y X.e_z];
A = oo_.dr.ghx; A = oo_.dr.ghx;
B = oo_.dr.ghu; B = oo_.dr.ghu;
err = zeros(6,200); err = zeros(6,200);
for t=2:200; for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)'; err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end; end;
disp(max(max(abs(err)))); disp(max(max(abs(err))));
d=load('data'); d=load('data');
dat = [d.dw d.dx d.dy d.z]; dat = [d.dw d.dx d.dy d.z];
X = oo_.SmoothedMeasurementErrors; X = oo_.SmoothedMeasurementErrors;
ME = [X.dw X.dx X.dy X.z]; ME = [X.dw X.dx X.dy X.z];
disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])-ME)))); disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])-ME))));

View File

@ -1,87 +1,87 @@
var z dw dx dy dc1 dc2; var z dw dx dy dc1 dc2;
varexo e_w e_x e_y e_z; varexo e_w e_x e_y e_z;
parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c; parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c;
model(linear); model(linear);
dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w; dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w;
dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x; dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x;
dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y; dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y;
z = rho_z*z(-1)+dw-dx+e_z; z = rho_z*z(-1)+dw-dx+e_z;
dc1 = dc1(-1)+dx-b*dy-c*dw; dc1 = dc1(-1)+dx-b*dy-c*dw;
dc2 = dc2(-1)+dx-b*dy; dc2 = dc2(-1)+dx-b*dy;
end; end;
estimated_params; estimated_params;
rho_w, normal_pdf, 0.5,0.2; rho_w, normal_pdf, 0.5,0.2;
rho_x, normal_pdf, 0.5,0.2; rho_x, normal_pdf, 0.5,0.2;
rho_y, normal_pdf, 0.5,0.2; rho_y, normal_pdf, 0.5,0.2;
rho_z, normal_pdf, 0.8,0.2; rho_z, normal_pdf, 0.8,0.2;
a1, normal_pdf, 0.1,0.2; a1, normal_pdf, 0.1,0.2;
a2, normal_pdf, -0.1,0.2; a2, normal_pdf, -0.1,0.2;
a3, normal_pdf, 0.1,0.2; a3, normal_pdf, 0.1,0.2;
b , normal_pdf, 1,0.2; b , normal_pdf, 1,0.2;
c , normal_pdf, 1,0.2; c , normal_pdf, 1,0.2;
stderr e_w, uniform_pdf,,, 0.01, 0.1; stderr e_w, uniform_pdf,,, 0.01, 0.1;
stderr e_x, 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_y, uniform_pdf,,, 0.01, 0.1;
stderr e_z, uniform_pdf,,, 0.01, 0.1; stderr e_z, uniform_pdf,,, 0.01, 0.1;
stderr z, normal_pdf, 0, 0.1; stderr z, normal_pdf, 0, 0.1;
end; end;
varobs dw dx dy z; 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,kalman_algo=2);
estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algoH1_mode,kalman_algo=2); estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algoH1_mode,kalman_algo=2);
//checking smoother consistency //checking smoother consistency
X = oo_.SmoothedVariables; X = oo_.SmoothedVariables;
S = [X.z X.dw X.dx X.dy X.dc1 X.dc2]; S = [X.z X.dw X.dx X.dy X.dc1 X.dc2];
X = oo_.SmoothedShocks; X = oo_.SmoothedShocks;
E = [X.e_w X.e_x X.e_y X.e_z]; E = [X.e_w X.e_x X.e_y X.e_z];
A = oo_.dr.ghx; A = oo_.dr.ghx;
B = oo_.dr.ghu; B = oo_.dr.ghu;
err = zeros(6,200); err = zeros(6,200);
for t=2:200; for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)'; err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end; end;
disp(max(max(abs(err)))); disp(max(max(abs(err))));
d=load('data'); d=load('data');
dat = [d.dw d.dx d.dy d.z]; dat = [d.dw d.dx d.dy d.z];
X = oo_.SmoothedMeasurementErrors; X = oo_.SmoothedMeasurementErrors;
ME = [X.dw X.dx X.dy X.z]; ME = [X.dw X.dx X.dy X.z];
disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])-ME)))); disp(max(max(abs(dat(1000:1199,:)-S(:,[2:4 1])-ME))));
o1 = load('algoH1_results'); o1 = load('algoH1_results');
obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'}; obj_endo={'SmoothedVariables'; 'FilteredVariables'; 'UpdatedVariables'};
obj_exo = {'SmoothedShocks';}; obj_exo = {'SmoothedShocks';};
nobj_endo = size(obj_endo,1); nobj_endo = size(obj_endo,1);
nobj_exo = size(obj_exo,1); nobj_exo = size(obj_exo,1);
for i=1:nobj_endo; for i=1:nobj_endo;
err_endo = zeros(eval(['size(oo_.' obj_endo{i} '.' M_.endo_names(1,:) ',1);']),M_.endo_nbr); err_endo = zeros(eval(['size(oo_.' obj_endo{i} '.' M_.endo_names(1,:) ',1);']),M_.endo_nbr);
for j=1:M_.endo_nbr; for j=1:M_.endo_nbr;
var1 = eval(['o1.oo_.' obj_endo{i} '.' M_.endo_names(j,:)]); var1 = eval(['o1.oo_.' obj_endo{i} '.' M_.endo_names(j,:)]);
var2 = eval(['oo_.' obj_endo{i} '.' M_.endo_names(j,:)]); var2 = eval(['oo_.' obj_endo{i} '.' M_.endo_names(j,:)]);
err_endo(:,j) = var1-var2; err_endo(:,j) = var1-var2;
end; end;
disp(max(max(abs(err_endo)))); disp(max(max(abs(err_endo))));
end; end;
err_exo = zeros(200,M_.exo_nbr,nobj_exo); err_exo = zeros(200,M_.exo_nbr,nobj_exo);
for i=1:nobj_exo; for i=1:nobj_exo;
err_exo = zeros(size(eval(['oo_.' obj_exo{i} '.' M_.exo_names(1,:)]),1),M_.exo_nbr); err_exo = zeros(size(eval(['oo_.' obj_exo{i} '.' M_.exo_names(1,:)]),1),M_.exo_nbr);
for j=1:M_.exo_nbr; for j=1:M_.exo_nbr;
var1 = eval(['o1.oo_.' obj_exo{i} '.' M_.exo_names(j,:)]); var1 = eval(['o1.oo_.' obj_exo{i} '.' M_.exo_names(j,:)]);
var2 = eval(['oo_.' obj_exo{i} '.' M_.exo_names(j,:)]); var2 = eval(['oo_.' obj_exo{i} '.' M_.exo_names(j,:)]);
err_exo(:,j,i) = var1 - var2; err_exo(:,j,i) = var1 - var2;
end; end;
disp(max(max(abs(err_exo)))); disp(max(max(abs(err_exo))));
end; end;
disp(max(max(max(abs(err_exo))))); disp(max(max(max(abs(err_exo)))));
disp(max(max(abs(o1.oo_.SmoothedMeasurementErrors.z - oo_.SmoothedMeasurementErrors.z)))); disp(max(max(abs(o1.oo_.SmoothedMeasurementErrors.z - oo_.SmoothedMeasurementErrors.z))));

View File

@ -1,62 +1,62 @@
var z dw dx dy dc1 dc2 w x y; var z dw dx dy dc1 dc2 w x y;
varexo e_w e_x e_y e_z; varexo e_w e_x e_y e_z;
parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c; parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c;
model(linear); model(linear);
dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w; dw = rho_w*dw(-1)+a1*(dc1(-1))+e_w;
dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x; dx = rho_x*dx(-1)+a2*(dc1(-1))+e_x;
dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y; dy = rho_y*dy(-1)+a3*(dc2(-1))+e_y;
z = rho_z*z(-1)+dw-dx+e_z; z = rho_z*z(-1)+dw-dx+e_z;
dc1 = dc1(-1)+dx-b*dy-c*dw; dc1 = dc1(-1)+dx-b*dy-c*dw;
dc2 = dc2(-1)+dx-b*dy; dc2 = dc2(-1)+dx-b*dy;
w = w(-1) + dw; w = w(-1) + dw;
x = x(-1) + dx; x = x(-1) + dx;
y = y(-1) + dy; y = y(-1) + dy;
end; end;
estimated_params; estimated_params;
rho_w, normal_pdf, 0.5,0.2; rho_w, normal_pdf, 0.5,0.2;
rho_x, normal_pdf, 0.5,0.2; rho_x, normal_pdf, 0.5,0.2;
rho_y, normal_pdf, 0.5,0.2; rho_y, normal_pdf, 0.5,0.2;
rho_z, normal_pdf, 0.8,0.2; rho_z, normal_pdf, 0.8,0.2;
a1, normal_pdf, 0.1,0.2; a1, normal_pdf, 0.1,0.2;
a2, normal_pdf, -0.1,0.2; a2, normal_pdf, -0.1,0.2;
a3, normal_pdf, 0.1,0.2; a3, normal_pdf, 0.1,0.2;
b , normal_pdf, 1,0.2; b , normal_pdf, 1,0.2;
c , normal_pdf, 1,0.2; c , normal_pdf, 1,0.2;
stderr e_w, uniform_pdf,,, 0.01, 0.1; stderr e_w, uniform_pdf,,, 0.01, 0.1;
stderr e_x, 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_y, uniform_pdf,,, 0.01, 0.1;
stderr e_z, inv_gamma_pdf,0.01, inf; stderr e_z, inv_gamma_pdf,0.01, inf;
stderr w, inv_gamma_pdf, 0.01,inf; stderr w, inv_gamma_pdf, 0.01,inf;
end; end;
varobs w x y; 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,diffuse_filter);
//estimation(datafile=data,first_obs=1000,nobs=200,mh_replic=0,mode_compute=0,mode_file=algo3_mode,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); stoch_simul(irf=0);
//checking smoother consistency //checking smoother consistency
X = oo_.SmoothedVariables; X = oo_.SmoothedVariables;
S = [X.z X.dw X.dx X.dy X.dc1 X.dc2 X.w X.x X.y]; S = [X.z X.dw X.dx X.dy X.dc1 X.dc2 X.w X.x X.y];
X = oo_.SmoothedShocks; X = oo_.SmoothedShocks;
E = [X.e_w X.e_x X.e_y X.e_z]; E = [X.e_w X.e_x X.e_y X.e_z];
A = oo_.dr.ghx; A = oo_.dr.ghx;
B = oo_.dr.ghu; B = oo_.dr.ghu;
err = zeros(M_.endo_nbr,200); err = zeros(M_.endo_nbr,200);
for t=2:200; for t=2:200;
err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)'; err(:,t) = S(t,:)'-A*S(t-1,:)'-B*E(t,:)';
end; end;
disp(max(max(abs(err)))); disp(max(max(abs(err))));
d=load('data'); d=load('data');
dat = [d.w d.x d.y]; dat = [d.w d.x d.y];
X = oo_.SmoothedMeasurementErrors; X = oo_.SmoothedMeasurementErrors;
ME = [X.w X.x X.y]; ME = [X.w X.x X.y];
disp(max(max(abs(dat(1000:1199,:)-S(:,[7:9])-ME)))); disp(max(max(abs(dat(1000:1199,:)-S(:,[7:9])-ME))));

View File

@ -1,38 +1,38 @@
var w x y z dw dx dy; var w x y z dw dx dy;
varexo e_w e_x e_y e_z; varexo e_w e_x e_y e_z;
parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c; parameters rho_w rho_x rho_y rho_z a1 a2 a3 b c;
rho_w = 0.5; rho_w = 0.5;
rho_x = 0.5; rho_x = 0.5;
rho_y = 0.5; rho_y = 0.5;
rho_z = 0.8; rho_z = 0.8;
a1 = 0.1; a1 = 0.1;
a2 = -0.1; a2 = -0.1;
a3 = 0.1; a3 = 0.1;
b = 1; b = 1;
c = 1; c = 1;
model(linear); model(linear);
dw = rho_w*dw(-1)+a1*(x(-1)-b*y(-1)-c*w(-1))+e_w; dw = rho_w*dw(-1)+a1*(x(-1)-b*y(-1)-c*w(-1))+e_w;
dx = rho_x*dx(-1)+a2*(x(-1)-b*y(-1)-c*w(-1))+e_x; dx = rho_x*dx(-1)+a2*(x(-1)-b*y(-1)-c*w(-1))+e_x;
dy = rho_y*dy(-1)+a3*(x(-1)-b*y(-1))+e_y; dy = rho_y*dy(-1)+a3*(x(-1)-b*y(-1))+e_y;
z = rho_z*z(-1)+dw-dx+e_z; z = rho_z*z(-1)+dw-dx+e_z;
w = w(-1)+dw; w = w(-1)+dw;
x = x(-1)+dx; x = x(-1)+dx;
y = y(-1)+dy; y = y(-1)+dy;
end; end;
shocks; shocks;
var e_w; stderr 0.05; var e_w; stderr 0.05;
var e_x; stderr 0.05; var e_x; stderr 0.05;
var e_y; stderr 0.05; var e_y; stderr 0.05;
var e_z; stderr 0.05; var e_z; stderr 0.05;
end; end;
stoch_simul(periods=2000,irf=0,simul_seed=7); stoch_simul(periods=2000,irf=0,simul_seed=7);
plot([w x y z]); plot([w x y z]);
save data w x y z dw dx dy; save data w x y z dw dx dy;

View File

@ -1,65 +1,65 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54; psi1 = 1.54;
psi2 = 0.25; psi2 = 0.25;
psi3 = 0.25; psi3 = 0.25;
rho_R = 0.5; rho_R = 0.5;
alpha = 0.3; alpha = 0.3;
rr = 2.51; rr = 2.51;
k = 0.5; k = 0.5;
tau = 0.5; tau = 0.5;
rho_q = 0.4; rho_q = 0.4;
rho_A = 0.2; rho_A = 0.2;
rho_ys = 0.9; rho_ys = 0.9;
rho_pies = 0.7; rho_pies = 0.7;
model(linear); model(linear);
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s; pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R; R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q; dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys; y_s = rho_ys*y_s(-1)+e_ys;
pie_s = rho_pies*pie_s(-1)+e_pies; pie_s = rho_pies*pie_s(-1)+e_pies;
A = rho_A*A(-1)+e_A; A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A; y_obs = y-y(-1)+A;
pie_obs = 4*pie; pie_obs = 4*pie;
R_obs = 4*R; R_obs = 4*R;
end; end;
shocks; shocks;
var e_R = 1.25^2; var e_R = 1.25^2;
var e_q = 2.5^2; var e_q = 2.5^2;
var e_A = 1.89; var e_A = 1.89;
var e_ys = 1.89; var e_ys = 1.89;
var e_pies = 1.89; var e_pies = 1.89;
end; end;
varobs y_obs R_obs pie_obs dq de; varobs y_obs R_obs pie_obs dq de;
estimated_params; estimated_params;
psi1 , gamma_pdf,1.5,0.5; psi1 , gamma_pdf,1.5,0.5;
psi2 , gamma_pdf,0.25,0.125; psi2 , gamma_pdf,0.25,0.125;
psi3 , gamma_pdf,0.25,0.125; psi3 , gamma_pdf,0.25,0.125;
rho_R ,beta_pdf,0.5,0.2; rho_R ,beta_pdf,0.5,0.2;
alpha ,beta_pdf,0.3,0.1; alpha ,beta_pdf,0.3,0.1;
rr ,gamma_pdf,2.5,1; rr ,gamma_pdf,2.5,1;
k , gamma_pdf,0.5,0.25; k , gamma_pdf,0.5,0.25;
tau ,gamma_pdf,0.5,0.2; tau ,gamma_pdf,0.5,0.2;
rho_q ,beta_pdf,0.4,0.2; rho_q ,beta_pdf,0.4,0.2;
rho_A ,beta_pdf,0.5,0.2; rho_A ,beta_pdf,0.5,0.2;
rho_ys ,beta_pdf,0.8,0.1; rho_ys ,beta_pdf,0.8,0.1;
rho_pies,beta_pdf,0.7,0.15; rho_pies,beta_pdf,0.7,0.15;
stderr e_R,inv_gamma_pdf,1.2533,0.6551; stderr e_R,inv_gamma_pdf,1.2533,0.6551;
stderr e_q,inv_gamma_pdf,2.5066,1.3103; stderr e_q,inv_gamma_pdf,2.5066,1.3103;
stderr e_A,inv_gamma_pdf,1.2533,0.6551; stderr e_A,inv_gamma_pdf,1.2533,0.6551;
stderr e_ys,inv_gamma_pdf,1.2533,0.6551; stderr e_ys,inv_gamma_pdf,1.2533,0.6551;
stderr e_pies,inv_gamma_pdf,1.88,0.9827; stderr e_pies,inv_gamma_pdf,1.88,0.9827;
end; end;
estimation(datafile=data_ca1,first_obs=8,nobs=79,mh_nblocks=10,prefilter=1,mh_jscale=0.5,mh_replic=0); estimation(datafile=data_ca1,first_obs=8,nobs=79,mh_nblocks=10,prefilter=1,mh_jscale=0.5,mh_replic=0);

View File

@ -1,65 +1,65 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54; psi1 = 1.54;
psi2 = 0.25; psi2 = 0.25;
psi3 = 0.25; psi3 = 0.25;
rho_R = 0.5; rho_R = 0.5;
alpha = 0.3; alpha = 0.3;
rr = 2.51; rr = 2.51;
k = 0.5; k = 0.5;
tau = 0.5; tau = 0.5;
rho_q = 0.4; rho_q = 0.4;
rho_A = 0.2; rho_A = 0.2;
rho_ys = 0.9; rho_ys = 0.9;
rho_pies = 0.7; rho_pies = 0.7;
model(linear); model(linear);
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s; pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R; R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q; dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys; y_s = rho_ys*y_s(-1)+e_ys;
pie_s = rho_pies*pie_s(-1)+e_pies; pie_s = rho_pies*pie_s(-1)+e_pies;
A = rho_A*A(-1)+e_A; A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A; y_obs = y-y(-1)+A;
pie_obs = 4*pie; pie_obs = 4*pie;
R_obs = 4*R; R_obs = 4*R;
end; end;
shocks; shocks;
var e_R = 1.25^2; var e_R = 1.25^2;
var e_q = 2.5^2; var e_q = 2.5^2;
var e_A = 1.89; var e_A = 1.89;
var e_ys = 1.89; var e_ys = 1.89;
var e_pies = 1.89; var e_pies = 1.89;
end; end;
varobs y_obs R_obs pie_obs dq de; varobs y_obs R_obs pie_obs dq de;
estimated_params; estimated_params;
psi1 , gamma_pdf,1.5,0.5; psi1 , gamma_pdf,1.5,0.5;
psi2 , gamma_pdf,0.25,0.125; psi2 , gamma_pdf,0.25,0.125;
psi3 , gamma_pdf,0.25,0.125; psi3 , gamma_pdf,0.25,0.125;
rho_R ,beta_pdf,0.5,0.2; rho_R ,beta_pdf,0.5,0.2;
alpha ,beta_pdf,0.3,0.1; alpha ,beta_pdf,0.3,0.1;
rr ,gamma_pdf,2.5,1; rr ,gamma_pdf,2.5,1;
k , gamma_pdf,0.5,0.25; k , gamma_pdf,0.5,0.25;
tau ,gamma_pdf,0.5,0.2; tau ,gamma_pdf,0.5,0.2;
rho_q ,beta_pdf,0.4,0.2; rho_q ,beta_pdf,0.4,0.2;
rho_A ,beta_pdf,0.5,0.2; rho_A ,beta_pdf,0.5,0.2;
rho_ys ,beta_pdf,0.8,0.1; rho_ys ,beta_pdf,0.8,0.1;
rho_pies,beta_pdf,0.7,0.15; rho_pies,beta_pdf,0.7,0.15;
stderr e_R,inv_gamma_pdf,1.2533,0.6551; stderr e_R,inv_gamma_pdf,1.2533,0.6551;
stderr e_q,inv_gamma_pdf,2.5066,1.3103; stderr e_q,inv_gamma_pdf,2.5066,1.3103;
stderr e_A,inv_gamma_pdf,1.2533,0.6551; stderr e_A,inv_gamma_pdf,1.2533,0.6551;
stderr e_ys,inv_gamma_pdf,1.2533,0.6551; stderr e_ys,inv_gamma_pdf,1.2533,0.6551;
stderr e_pies,inv_gamma_pdf,1.88,0.9827; stderr e_pies,inv_gamma_pdf,1.88,0.9827;
end; end;
estimation(datafile=data_ca1,first_obs=8,nobs=79,mh_nblocks=10,prefilter=1,mh_jscale=0.5,mh_replic=0); estimation(datafile=data_ca1,first_obs=8,nobs=79,mh_nblocks=10,prefilter=1,mh_jscale=0.5,mh_replic=0);

View File

@ -1,33 +1,33 @@
periods 20000; periods 20000;
var c k a; var c k a;
varexo e; varexo e;
parameters alpha beta delta gamma rho; parameters alpha beta delta gamma rho;
beta = 0.95; beta = 0.95;
delta = 1; delta = 1;
alpha = 0.3; alpha = 0.3;
rho = 0; rho = 0;
gamma = 2; gamma = 2;
model; model;
exp(c) + exp(k) = (1-delta) * exp(k(-1)) + exp(a) * exp(k(-1))^alpha; exp(c) + exp(k) = (1-delta) * exp(k(-1)) + exp(a) * exp(k(-1))^alpha;
exp(c)^(-gamma) = beta * exp(c(+1))^(-gamma) * (exp(a(+1)) * alpha * exp(k)^(alpha-1) + 1 - delta); exp(c)^(-gamma) = beta * exp(c(+1))^(-gamma) * (exp(a(+1)) * alpha * exp(k)^(alpha-1) + 1 - delta);
a = rho * a(-1) + e; a = rho * a(-1) + e;
end; end;
initval; initval;
k=0; k=0;
c=0; c=0;
a=0; a=0;
e=0; e=0;
end; end;
Sigma_e_ = 1; Sigma_e_ = 1;
stoch_simul(nomoments,irf=0,nocorr,ar=0); stoch_simul(nomoments,irf=0,nocorr,ar=0);
global dr_ global dr_
dr_obj_ = dr_; dr_obj_ = dr_;
save sgu_ex1 dr_obj_; save sgu_ex1 dr_obj_;

View File

@ -1,97 +1,97 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54; psi1 = 1.54;
psi2 = 0.25; psi2 = 0.25;
psi3 = 0.25; psi3 = 0.25;
rho_R = 0.5; rho_R = 0.5;
alpha = 0.3; alpha = 0.3;
rr = 2.51; rr = 2.51;
k = 0.5; k = 0.5;
tau = 0.5; tau = 0.5;
rho_q = 0.4; rho_q = 0.4;
rho_A = 0.2; rho_A = 0.2;
rho_ys = 0.9; rho_ys = 0.9;
rho_pies = 0.7; rho_pies = 0.7;
model(linear); model(linear);
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s; pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R; R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q; dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys; y_s = rho_ys*y_s(-1)+e_ys;
pie_s = rho_pies*pie_s(-1)+e_pies; pie_s = rho_pies*pie_s(-1)+e_pies;
A = rho_A*A(-1)+e_A; A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A; y_obs = y-y(-1)+A;
pie_obs = 4*pie; pie_obs = 4*pie;
R_obs = 4*R; R_obs = 4*R;
end; end;
shocks; shocks;
var e_R = 1.25^2; var e_R = 1.25^2;
var e_q = 2.5^2; var e_q = 2.5^2;
var e_A = 1.89; var e_A = 1.89;
var e_ys = 1.89; var e_ys = 1.89;
var e_pies = 1.89; var e_pies = 1.89;
end; end;
varobs y_obs R_obs pie_obs dq de; varobs y_obs R_obs pie_obs dq de;
estimated_params; estimated_params;
psi1 , gamma_pdf,1.5,0.5; psi1 , gamma_pdf,1.5,0.5;
psi2 , gamma_pdf,0.25,0.125; psi2 , gamma_pdf,0.25,0.125;
psi3 , gamma_pdf,0.25,0.125; psi3 , gamma_pdf,0.25,0.125;
rho_R ,beta_pdf,0.5,0.2; rho_R ,beta_pdf,0.5,0.2;
alpha ,beta_pdf,0.3,0.1; alpha ,beta_pdf,0.3,0.1;
rr ,gamma_pdf,2.5,1; rr ,gamma_pdf,2.5,1;
k , gamma_pdf,0.5,0.25; k , gamma_pdf,0.5,0.25;
tau ,gamma_pdf,0.5,0.2; tau ,gamma_pdf,0.5,0.2;
rho_q ,beta_pdf,0.4,0.2; rho_q ,beta_pdf,0.4,0.2;
rho_A ,beta_pdf,0.5,0.2; rho_A ,beta_pdf,0.5,0.2;
rho_ys ,beta_pdf,0.8,0.1; rho_ys ,beta_pdf,0.8,0.1;
rho_pies,beta_pdf,0.7,0.15; rho_pies,beta_pdf,0.7,0.15;
stderr e_R,inv_gamma_pdf,1.2533,0.6551; stderr e_R,inv_gamma_pdf,1.2533,0.6551;
stderr e_q,inv_gamma_pdf,2.5066,1.3103; stderr e_q,inv_gamma_pdf,2.5066,1.3103;
stderr e_A,inv_gamma_pdf,1.2533,0.6551; stderr e_A,inv_gamma_pdf,1.2533,0.6551;
stderr e_ys,inv_gamma_pdf,1.2533,0.6551; stderr e_ys,inv_gamma_pdf,1.2533,0.6551;
stderr e_pies,inv_gamma_pdf,1.88,0.9827; stderr e_pies,inv_gamma_pdf,1.88,0.9827;
end; end;
// common syntax for win and unix, for local parallel runs (assuming quad-core): // common syntax for win and unix, for local parallel runs (assuming quad-core):
// all empty fields, except Local and NumCPU // all empty fields, except Local and NumCPU
options_.parallel=struct('Local', 1, 'PcName','','NumCPU', [0:3], 'user','','passwd','','RemoteDrive', '', 'RemoteFolder',''); options_.parallel=struct('Local', 1, 'PcName','','NumCPU', [0:3], 'user','','passwd','','RemoteDrive', '', 'RemoteFolder','');
// windows syntax for remote runs (Local=0): // windows syntax for remote runs (Local=0):
// win passwd has to be typed explicitly! // win passwd has to be typed explicitly!
// RemoteDrive has to be yped explicitly! // RemoteDrive has to be yped explicitly!
// for user, ALSO the group has to be specified, like ISIS\rattoma, i.e. user rattoma in group ISIS // for user, ALSO the group has to be specified, like ISIS\rattoma, i.e. user rattoma in group ISIS
// PcName is the name of the computed in the windows network, i.e. the output of hostname, or the full IP adress // PcName is the name of the computed in the windows network, i.e. the output of hostname, or the full IP adress
//options_.parallel=struct('Local', 0, 'PcName','iazz9000','NumCPU', [4:6], 'user','ISIS\rattoma','passwd','****', 'RemoteDrive', 'C', 'RemoteFolder','dynare_calcs\Remote'); //options_.parallel=struct('Local', 0, 'PcName','iazz9000','NumCPU', [4:6], 'user','ISIS\rattoma','passwd','****', 'RemoteDrive', 'C', 'RemoteFolder','dynare_calcs\Remote');
// example to use several remote PC's to build a grid on windows: // example to use several remote PC's to build a grid on windows:
//options_.parallel=struct('Local', 0, 'PcName','iazz9000','NumCPU', [0:3], 'user','ISIS\azziniv','passwd','****', 'RemoteDrive', 'C', 'RemoteFolder','dynare_calcs\Remote'); //options_.parallel=struct('Local', 0, 'PcName','iazz9000','NumCPU', [0:3], 'user','ISIS\azziniv','passwd','****', 'RemoteDrive', 'C', 'RemoteFolder','dynare_calcs\Remote');
//options_.parallel(2)=struct('Local', 0, 'PcName','paperino','NumCPU', [0:3], 'user','ISIS\azziniv','passwd','****', 'RemoteDrive', 'D', 'RemoteFolder','dynare_calcs\Remote'); //options_.parallel(2)=struct('Local', 0, 'PcName','paperino','NumCPU', [0:3], 'user','ISIS\azziniv','passwd','****', 'RemoteDrive', 'D', 'RemoteFolder','dynare_calcs\Remote');
//options_.parallel(3)=struct('Local', 0, 'PcName','didietro','NumCPU', [0:3], 'user','','passwd','','RemoteDrive', ppp(1), 'RemoteFolder',ppp(4:end)); //options_.parallel(3)=struct('Local', 0, 'PcName','didietro','NumCPU', [0:3], 'user','','passwd','','RemoteDrive', ppp(1), 'RemoteFolder',ppp(4:end));
//options_.parallel(4)=struct('Local', 0, 'PcName','uasalap29','NumCPU', [0:1], 'user','ISIS\rattoma','passwd','****', 'RemoteDrive', 'C', 'RemoteFolder','dynare_calcs\Remote'); //options_.parallel(4)=struct('Local', 0, 'PcName','uasalap29','NumCPU', [0:1], 'user','ISIS\rattoma','passwd','****', 'RemoteDrive', 'C', 'RemoteFolder','dynare_calcs\Remote');
//options_.parallel(5)=struct('Local', 0, 'PcName','brigitta','NumCPU', [0:3], 'user','ISIS\azziniv','passwd','****', 'RemoteDrive', 'C', 'RemoteFolder','dynare_calcs\Remote'); //options_.parallel(5)=struct('Local', 0, 'PcName','brigitta','NumCPU', [0:3], 'user','ISIS\azziniv','passwd','****', 'RemoteDrive', 'C', 'RemoteFolder','dynare_calcs\Remote');
// unix syntax for remote runs (Local=0): // unix syntax for remote runs (Local=0):
// no passwd and RemoteDrive needed! // no passwd and RemoteDrive needed!
// PcName: full IP address or address // PcName: full IP address or address
//options_.parallel=struct('Local', 0, 'PcName','paperino.jrc.it','NumCPU', [0:3], 'user','rattoma','passwd','', 'RemoteDrive', '', 'RemoteFolder','/home/rattoma/Remote'); //options_.parallel=struct('Local', 0, 'PcName','paperino.jrc.it','NumCPU', [0:3], 'user','rattoma','passwd','', 'RemoteDrive', '', 'RemoteFolder','/home/rattoma/Remote');
// example to combine local and remote runs (on unix): // example to combine local and remote runs (on unix):
//options_.parallel=struct('Local', 1, 'PcName','','NumCPU', [0:3], 'user','','passwd','','RemoteDrive', '', 'RemoteFolder',''); //options_.parallel=struct('Local', 1, 'PcName','','NumCPU', [0:3], 'user','','passwd','','RemoteDrive', '', 'RemoteFolder','');
//options_.parallel(2)=struct('Local', 0, 'PcName','paperino.jrc.it','NumCPU', [0:3], 'user','rattoma','passwd','', 'RemoteDrive', '', 'RemoteFolder','/home/rattoma/Remote'); //options_.parallel(2)=struct('Local', 0, 'PcName','paperino.jrc.it','NumCPU', [0:3], 'user','rattoma','passwd','', 'RemoteDrive', '', 'RemoteFolder','/home/rattoma/Remote');
// example to combine local and remote runs (on win): // example to combine local and remote runs (on win):
//options_.parallel=struct('Local', 1, 'PcName','','NumCPU', [0:3], 'user','','passwd','','RemoteDrive', '', 'RemoteFolder',''); //options_.parallel=struct('Local', 1, 'PcName','','NumCPU', [0:3], 'user','','passwd','','RemoteDrive', '', 'RemoteFolder','');
//options_.parallel(2)=struct('Local', 0, 'PcName','uasalap29','NumCPU', [0:1], 'user','ISIS\rattoma','passwd','****', 'RemoteDrive', 'C', 'RemoteFolder','dynare_calcs\Remote'); //options_.parallel(2)=struct('Local', 0, 'PcName','uasalap29','NumCPU', [0:1], 'user','ISIS\rattoma','passwd','****', 'RemoteDrive', 'C', 'RemoteFolder','dynare_calcs\Remote');
estimation(datafile=data_ca1,first_obs=8,nobs=79,mode_compute=0, mode_file=ls2003_mode, mh_nblocks=4,prefilter=1,mh_jscale=0.5,mh_replic=2000);//, load_mh_file); estimation(datafile=data_ca1,first_obs=8,nobs=79,mode_compute=0, mode_file=ls2003_mode, mh_nblocks=4,prefilter=1,mh_jscale=0.5,mh_replic=2000);//, load_mh_file);

View File

@ -1,51 +1,51 @@
var y1, y2, y3, x1, x2, x3; var y1, y2, y3, x1, x2, x3;
model; model;
x1 = 1.96; x1 = 1.96;
x2 = 1; x2 = 1;
x3 = 0.5; x3 = 0.5;
y1 = normcdf(x1(-1),0,1); y1 = normcdf(x1(-1),0,1);
y2 = normcdf(-x1,-x2,1); y2 = normcdf(-x1,-x2,1);
y3 = normcdf(x1/2,0,x3(+1)); y3 = normcdf(x1/2,0,x3(+1));
end; end;
initval; initval;
y1 = 0; y1 = 0;
y2 = 0; y2 = 0;
y3 = 0; y3 = 0;
x1 = 0; x1 = 0;
x2 = 0; x2 = 0;
x3 = 1; x3 = 1;
end; end;
steady; steady;
if abs(oo_.steady_state(1) - pnorm(1.96,0,1)) > 1e-12; if abs(oo_.steady_state(1) - pnorm(1.96,0,1)) > 1e-12;
error('Error 1 in t_normcdf') error('Error 1 in t_normcdf')
end; end;
if abs(oo_.steady_state(2) - pnorm(-1.96,-1,1)) > 1e-12; if abs(oo_.steady_state(2) - pnorm(-1.96,-1,1)) > 1e-12;
error('Error 2 in t_normcdf') error('Error 2 in t_normcdf')
end; end;
if abs(oo_.steady_state(3) - pnorm(1.96/2,0,1/2)) > 1e-12; if abs(oo_.steady_state(3) - pnorm(1.96/2,0,1/2)) > 1e-12;
error('Error 3 in t_normcdf') error('Error 3 in t_normcdf')
end; end;
z = [oo_.steady_state(4); oo_.steady_state; oo_.steady_state(6)]; z = [oo_.steady_state(4); oo_.steady_state; oo_.steady_state(6)];
[junk,JJ] = t_normcdf_dynamic(z,[]); [junk,JJ] = t_normcdf_dynamic(z,[]);
if abs(JJ(4,1) + dnorm(1.96,0,1)) > 1e-12; if abs(JJ(4,1) + dnorm(1.96,0,1)) > 1e-12;
error('Error 4 in t_normcdf') error('Error 4 in t_normcdf')
end; end;
if abs(JJ(5,5) - dnorm(-1.96,-1,1)) > 1e-12; if abs(JJ(5,5) - dnorm(-1.96,-1,1)) > 1e-12;
error('Error 5 in t_normcdf') error('Error 5 in t_normcdf')
end; end;
if abs(JJ(5,6) + dnorm(-1.96,-1,1)) > 1e-12; if abs(JJ(5,6) + dnorm(-1.96,-1,1)) > 1e-12;
error('Error 6 in t_normcdf') error('Error 6 in t_normcdf')
end; end;
if abs(JJ(6,5) + dnorm(1.96/2,0,1/2)/2) > 1e-12; if abs(JJ(6,5) + dnorm(1.96/2,0,1/2)/2) > 1e-12;
error('Error 7 in t_normcdf') error('Error 7 in t_normcdf')
end; end;
if abs(JJ(6,8) - (1/2)*((1.96/2)/(1/2)^2)*dnorm(1.96/2,0,1/2)) > 1e-12; if abs(JJ(6,8) - (1/2)*((1.96/2)/(1/2)^2)*dnorm(1.96/2,0,1/2)) > 1e-12;
error('Error 8 in t_normcdf') error('Error 8 in t_normcdf')
end; end;

View File

@ -1,90 +1,90 @@
var y a k c i h eoy eoc eoh oy oc oh; var y a k c i h eoy eoc eoh oy oc oh;
varexo e eeoy eeoc eeoh; varexo e eeoy eeoc eeoh;
parameters theta rho eta gam bet delta aa r11 r12 r13 r21 r22 r23 r31 r32 r33 scy shc shy; parameters theta rho eta gam bet delta aa r11 r12 r13 r21 r22 r23 r31 r32 r33 scy shc shy;
bet = 0.99; bet = 0.99;
delta = 0.025; delta = 0.025;
theta = 0.2; theta = 0.2;
rho = 0.9959; rho = 0.9959;
eta = 1.0051; eta = 1.0051;
gam = 0.0045; gam = 0.0045;
aa = 1.8; aa = 1.8;
r11 = 0.99; r11 = 0.99;
r12 = 0; r12 = 0;
r13 = 0; r13 = 0;
r21 = 0; r21 = 0;
r22 = 0.99; r22 = 0.99;
r23 = 0; r23 = 0;
r31 = 0; r31 = 0;
r32 = 0; r32 = 0;
r33 = 0.99; r33 = 0.99;
scy = 0.0040; scy = 0.0040;
shy = 0.0015; shy = 0.0015;
shc = 0.0010; shc = 0.0010;
model; model;
exp(y) = exp(a)*exp(k(-1))^theta*exp(h)^(1-theta); exp(y) = exp(a)*exp(k(-1))^theta*exp(h)^(1-theta);
a = (1-rho)*aa+rho*a(-1)+e; a = (1-rho)*aa+rho*a(-1)+e;
exp(y) = exp(c) + exp(i); exp(y) = exp(c) + exp(i);
eta*exp(k) = (1-delta)*exp(k(-1))+exp(i); eta*exp(k) = (1-delta)*exp(k(-1))+exp(i);
gam*exp(c)*exp(h) = (1-theta)*exp(y); gam*exp(c)*exp(h) = (1-theta)*exp(y);
eta/exp(c) = bet*(1/exp(c(+1)))*(theta*(exp(y(+1))/exp(k))+1-delta); eta/exp(c) = bet*(1/exp(c(+1)))*(theta*(exp(y(+1))/exp(k))+1-delta);
eoy = r11*eoy(-1) + r12*eoc(-1) + r13*eoh(-1) + eeoy; eoy = r11*eoy(-1) + r12*eoc(-1) + r13*eoh(-1) + eeoy;
eoc = r21*eoy(-1) + r22*eoc(-1) + r23*eoh(-1) + scy*eeoy+eeoc; eoc = r21*eoy(-1) + r22*eoc(-1) + r23*eoh(-1) + scy*eeoy+eeoc;
eoh = r31*eoy(-1) + r32*eoc(-1) + r33*eoh(-1) + shy*eeoy+shc*eeoc+eeoh; eoh = r31*eoy(-1) + r32*eoc(-1) + r33*eoh(-1) + shy*eeoy+shc*eeoc+eeoh;
oy = y + eoy; oy = y + eoy;
oc = c + eoc; oc = c + eoc;
oh = h + eoh; oh = h + eoh;
end; end;
initval; initval;
a = 1.7; a = 1.7;
y = 8; y = 8;
c = 8; c = 8;
k = 10; k = 10;
i = 5; i = 5;
h = 4; h = 4;
eoy = 0; eoy = 0;
eoc = 0; eoc = 0;
eoh = 0; eoh = 0;
oy = y; oy = y;
oc = c; oc = c;
oh = h; oh = h;
end; end;
steady; steady;
check; check;
estimated_params; estimated_params;
theta , 0.22, 0.1, 0.5; theta , 0.22, 0.1, 0.5;
rho , 0.99, 0.7, 0.9999; rho , 0.99, 0.7, 0.9999;
eta , 1.0051, 1, 1.03; eta , 1.0051, 1, 1.03;
gam , 0.0045, 0.001, 0.01; gam , 0.0045, 0.001, 0.01;
aa , 1.8, 0.1, 4; aa , 1.8, 0.1, 4;
r11 , 1.4187, -2, 2; r11 , 1.4187, -2, 2;
r12 , 0.2251, -2, 2; r12 , 0.2251, -2, 2;
r13 , -0.4441, -2, 2; r13 , -0.4441, -2, 2;
r21 , 0.0935, -2, 2; r21 , 0.0935, -2, 2;
r22 , 1.0236, -2, 2; r22 , 1.0236, -2, 2;
r23 , -0.0908, -2, 2; r23 , -0.0908, -2, 2;
r31 , 0.7775, -2, 2; r31 , 0.7775, -2, 2;
r32 , 0.3706, -2, 2; r32 , 0.3706, -2, 2;
r33 , 0.2398, -2, 2; r33 , 0.2398, -2, 2;
scy , 0.0040, -2, 2; scy , 0.0040, -2, 2;
shy , 0.0015, -2, 2; shy , 0.0015, -2, 2;
shc , 0.0010, -2, 2; shc , 0.0010, -2, 2;
stderr e , 0.0056, 0, 0.2; stderr e , 0.0056, 0, 0.2;
stderr eeoy , 0.0070, 0, 0.1; stderr eeoy , 0.0070, 0, 0.1;
stderr eeoc , 0.0069, 0, 0.1; stderr eeoc , 0.0069, 0, 0.1;
stderr eeoh , 0.0018, 0, 0.1; stderr eeoh , 0.0018, 0, 0.1;
end; end;
varobs oy oc oh; varobs oy oc oh;
observation_trends; observation_trends;
oy (log(eta)); oy (log(eta));
oc (log(eta)); oc (log(eta));
end; end;
estimation(datafile=idata,mode_compute=1,nograph); estimation(datafile=idata,mode_compute=1,nograph);

View File

@ -1,90 +1,90 @@
var y a k c i h eoy eoc eoh oy oc oh; var y a k c i h eoy eoc eoh oy oc oh;
varexo e eeoy eeoc eeoh; varexo e eeoy eeoc eeoh;
parameters theta rho eta gam bet delta aa r11 r12 r13 r21 r22 r23 r31 r32 r33 scy shc shy; parameters theta rho eta gam bet delta aa r11 r12 r13 r21 r22 r23 r31 r32 r33 scy shc shy;
bet = 0.99; bet = 0.99;
delta = 0.025; delta = 0.025;
theta = 0.2; theta = 0.2;
rho = 0.9959; rho = 0.9959;
eta = 1.0051; eta = 1.0051;
gam = 0.0045; gam = 0.0045;
aa = 1.8; aa = 1.8;
r11 = 0.99; r11 = 0.99;
r12 = 0; r12 = 0;
r13 = 0; r13 = 0;
r21 = 0; r21 = 0;
r22 = 0.99; r22 = 0.99;
r23 = 0; r23 = 0;
r31 = 0; r31 = 0;
r32 = 0; r32 = 0;
r33 = 0.99; r33 = 0.99;
scy = 0.0040; scy = 0.0040;
shy = 0.0015; shy = 0.0015;
shc = 0.0010; shc = 0.0010;
model; model;
exp(y) = exp(a)*exp(k(-1))^theta*exp(h)^(1-theta); exp(y) = exp(a)*exp(k(-1))^theta*exp(h)^(1-theta);
a = (1-rho)*aa+rho*a(-1)+e; a = (1-rho)*aa+rho*a(-1)+e;
exp(y) = exp(c) + exp(i); exp(y) = exp(c) + exp(i);
eta*exp(k) = (1-delta)*exp(k(-1))+exp(i); eta*exp(k) = (1-delta)*exp(k(-1))+exp(i);
gam*exp(c)*exp(h) = (1-theta)*exp(y); gam*exp(c)*exp(h) = (1-theta)*exp(y);
eta/exp(c) = bet*(1/exp(c(+1)))*(theta*(exp(y(+1))/exp(k))+1-delta); eta/exp(c) = bet*(1/exp(c(+1)))*(theta*(exp(y(+1))/exp(k))+1-delta);
eoy = r11*eoy(-1) + r12*eoc(-1) + r13*eoh(-1) + eeoy; eoy = r11*eoy(-1) + r12*eoc(-1) + r13*eoh(-1) + eeoy;
eoc = r21*eoy(-1) + r22*eoc(-1) + r23*eoh(-1) + scy*eeoy+eeoc; eoc = r21*eoy(-1) + r22*eoc(-1) + r23*eoh(-1) + scy*eeoy+eeoc;
eoh = r31*eoy(-1) + r32*eoc(-1) + r33*eoh(-1) + shy*eeoy+shc*eeoc+eeoh; eoh = r31*eoy(-1) + r32*eoc(-1) + r33*eoh(-1) + shy*eeoy+shc*eeoc+eeoh;
oy = y + eoy; oy = y + eoy;
oc = c + eoc; oc = c + eoc;
oh = h + eoh; oh = h + eoh;
end; end;
initval; initval;
a = 6; a = 6;
y = 8; y = 8;
c = 7; c = 7;
k = 10; k = 10;
i = 5; i = 5;
h = 4; h = 4;
eoy = 0; eoy = 0;
eoc = 0; eoc = 0;
eoh = 0; eoh = 0;
oy = y; oy = y;
oc = c; oc = c;
oh = h; oh = h;
end; end;
steady; steady;
check; check;
estimated_params; estimated_params;
theta , 0.22; theta , 0.22;
rho , 0.99; rho , 0.99;
eta , 1.0051; eta , 1.0051;
gam , 0.0045; gam , 0.0045;
aa , 1.8; aa , 1.8;
r11 , 1.4187; r11 , 1.4187;
r12 , 0.2251; r12 , 0.2251;
r13 , -0.4441; r13 , -0.4441;
r21 , 0.0935; r21 , 0.0935;
r22 , 1.0236; r22 , 1.0236;
r23 , -0.0908; r23 , -0.0908;
r31 , 0.7775; r31 , 0.7775;
r32 , 0.3706; r32 , 0.3706;
r33 , 0.2398; r33 , 0.2398;
scy , 0.0040; scy , 0.0040;
shy , 0.0015; shy , 0.0015;
shc , 0.0010; shc , 0.0010;
stderr e , 0.0055; stderr e , 0.0055;
stderr eeoy , 0.0072; stderr eeoy , 0.0072;
stderr eeoc , 0.0057; stderr eeoc , 0.0057;
stderr eeoh , 0; stderr eeoh , 0;
end; end;
varobs oy oc oh; varobs oy oc oh;
observation_trends; observation_trends;
oy (log(eta)); oy (log(eta));
oc (log(eta)); oc (log(eta));
end; end;
estimation(datafile=idata,nograph); estimation(datafile=idata,nograph);

View File

@ -1,47 +1,47 @@
periods 500; periods 500;
var dc, dd, v_c, v_d, x; var dc, dd, v_c, v_d, x;
varexo e_c, e_x, e_d; varexo e_c, e_x, e_d;
parameters DELTA THETA PSI MU_C MU_D RHO_X LAMBDA_DX; parameters DELTA THETA PSI MU_C MU_D RHO_X LAMBDA_DX;
DELTA=.99; DELTA=.99;
PSI=1.5; PSI=1.5;
THETA=(1-7.5)/(1-1/PSI); THETA=(1-7.5)/(1-1/PSI);
MU_C=0.0015; MU_C=0.0015;
MU_D=0.0015; MU_D=0.0015;
RHO_X=.979; RHO_X=.979;
LAMBDA_DX=3; LAMBDA_DX=3;
model; model;
v_c = DELTA^THETA * exp((-THETA/PSI)*dc(+1) + (THETA-1)*log((1+v_c(+1))*exp(dc(+1))/v_c) ) * (1+v_c(+1))*exp(dc(+1)); v_c = DELTA^THETA * exp((-THETA/PSI)*dc(+1) + (THETA-1)*log((1+v_c(+1))*exp(dc(+1))/v_c) ) * (1+v_c(+1))*exp(dc(+1));
v_d = DELTA^THETA * exp((-THETA/PSI)*dc(+1) + (THETA-1)*log((1+v_c(+1))*exp(dc(+1))/v_c) ) * (1+v_d(+1))*exp(dd(+1)); v_d = DELTA^THETA * exp((-THETA/PSI)*dc(+1) + (THETA-1)*log((1+v_c(+1))*exp(dc(+1))/v_c) ) * (1+v_d(+1))*exp(dd(+1));
dc = MU_C + x(-1) + e_c; dc = MU_C + x(-1) + e_c;
dd = MU_D + LAMBDA_DX*x(-1) + e_d; dd = MU_D + LAMBDA_DX*x(-1) + e_d;
x = RHO_X * x(-1) + e_x; x = RHO_X * x(-1) + e_x;
end; end;
initval; initval;
v_c=15; v_c=15;
v_d=15; v_d=15;
dc=MU_C; dc=MU_C;
dd=MU_D; dd=MU_D;
x=0; x=0;
e_c=0; e_c=0;
e_x=0; e_x=0;
e_d=0; e_d=0;
end; end;
shocks; shocks;
var e_c; var e_c;
stderr .0078; stderr .0078;
var e_x; var e_x;
stderr .0078*.044; stderr .0078*.044;
var e_d; var e_d;
stderr .0078*4.5; stderr .0078*4.5;
end; end;
steady(solve_algo=0); steady(solve_algo=0);
check; check;
stoch_simul(dr_algo=1, order=1, periods=1000, irf=30); stoch_simul(dr_algo=1, order=1, periods=1000, irf=30);
datasaver('simudata',[]); datasaver('simudata',[]);

View File

@ -1,58 +1,58 @@
var dc, dd, v_c, v_d, x; var dc, dd, v_c, v_d, x;
varexo e_c, e_x, e_d; varexo e_c, e_x, e_d;
parameters DELTA THETA PSI MU_C MU_D RHO_X LAMBDA_DX; parameters DELTA THETA PSI MU_C MU_D RHO_X LAMBDA_DX;
DELTA=.99; DELTA=.99;
PSI=1.5; PSI=1.5;
THETA=(1-7.5)/(1-1/PSI); THETA=(1-7.5)/(1-1/PSI);
MU_C=0.0015; MU_C=0.0015;
MU_D=0.0015; MU_D=0.0015;
RHO_X=.979; RHO_X=.979;
LAMBDA_DX=3; LAMBDA_DX=3;
model; model;
v_c = DELTA^THETA * exp((-THETA/PSI)*dc(+1) + (THETA-1)*log((1+v_c(+1))*exp(dc(+1))/v_c) ) * (1+v_c(+1))*exp(dc(+1)); v_c = DELTA^THETA * exp((-THETA/PSI)*dc(+1) + (THETA-1)*log((1+v_c(+1))*exp(dc(+1))/v_c) ) * (1+v_c(+1))*exp(dc(+1));
v_d = DELTA^THETA * exp((-THETA/PSI)*dc(+1) + (THETA-1)*log((1+v_c(+1))*exp(dc(+1))/v_c) ) * (1+v_d(+1))*exp(dd(+1)); v_d = DELTA^THETA * exp((-THETA/PSI)*dc(+1) + (THETA-1)*log((1+v_c(+1))*exp(dc(+1))/v_c) ) * (1+v_d(+1))*exp(dd(+1));
dc = MU_C + x(-1) + e_c; dc = MU_C + x(-1) + e_c;
dd = MU_D + LAMBDA_DX*x(-1) + e_d; dd = MU_D + LAMBDA_DX*x(-1) + e_d;
x = RHO_X * x(-1) + e_x; x = RHO_X * x(-1) + e_x;
end; end;
initval; initval;
v_c=15; v_c=15;
v_d=15; v_d=15;
dc=MU_C; dc=MU_C;
dd=MU_D; dd=MU_D;
x=0; x=0;
e_c=0; e_c=0;
e_x=0; e_x=0;
e_d=0; e_d=0;
end; end;
shocks; shocks;
var e_d; stderr .001; var e_d; stderr .001;
var e_c; stderr .001; var e_c; stderr .001;
var e_x; stderr .001; var e_x; stderr .001;
end; end;
steady; steady;
estimated_params; estimated_params;
DELTA, beta_pdf, 0.98,.005; DELTA, beta_pdf, 0.98,.005;
THETA,normal_pdf,-19.5, 0.0025; THETA,normal_pdf,-19.5, 0.0025;
PSI,normal_pdf,1.6, 0.1; PSI,normal_pdf,1.6, 0.1;
MU_C,normal_pdf,0.001, 0.001; MU_C,normal_pdf,0.001, 0.001;
MU_D,normal_pdf,0.001, 0.001; MU_D,normal_pdf,0.001, 0.001;
RHO_X,normal_pdf,.98, 0.005; RHO_X,normal_pdf,.98, 0.005;
LAMBDA_DX,normal_pdf,3, 0.05; LAMBDA_DX,normal_pdf,3, 0.05;
stderr e_d,inv_gamma_pdf,.0025, 30; stderr e_d,inv_gamma_pdf,.0025, 30;
stderr e_x,inv_gamma_pdf,.0003, 30; stderr e_x,inv_gamma_pdf,.0003, 30;
stderr e_c,inv_gamma_pdf,.01, 30; stderr e_c,inv_gamma_pdf,.01, 30;
end; end;
varobs v_d dd dc; varobs v_d dd dc;
estimation(datafile=simudata,mh_replic=1000,mh_jscale=.4,nodiagnostic); estimation(datafile=simudata,mh_replic=1000,mh_jscale=.4,nodiagnostic);

View File

@ -1,42 +1,42 @@
var x y; var x y;
varexo e_x e_u; varexo e_x e_u;
parameters rho sig_x sig_u mu_y; parameters rho sig_x sig_u mu_y;
rho = .98; rho = .98;
mu_y=.015; mu_y=.015;
sig_x=0.00025; sig_x=0.00025;
sig_u=.0078; sig_u=.0078;
model(linear); model(linear);
x=rho*x(-1) + sig_x*e_x; x=rho*x(-1) + sig_x*e_x;
y=mu_y + x(-1) + sig_u*e_u; y=mu_y + x(-1) + sig_u*e_u;
end; end;
initval; initval;
x=0; x=0;
y=mu_y; y=mu_y;
end; end;
steady; steady;
shocks; shocks;
var e_x; var e_x;
stderr 1; stderr 1;
var e_u; var e_u;
stderr 1; stderr 1;
end; end;
estimated_params; estimated_params;
rho, beta_pdf, .98, .01; rho, beta_pdf, .98, .01;
mu_y, uniform_pdf, .005, .0025; mu_y, uniform_pdf, .005, .0025;
sig_u, inv_gamma_pdf, .003, inf; sig_u, inv_gamma_pdf, .003, inf;
sig_x, inv_gamma_pdf, .003, inf; sig_x, inv_gamma_pdf, .003, inf;
// The syntax for to input the priors is the following: // The syntax for to input the priors is the following:
// variable name, prior distribution, parameters of distribution. // variable name, prior distribution, parameters of distribution.
end; end;
varobs y; varobs y;
estimation(datafile=data_consRicardoypg,first_obs=1,nobs=227,mh_replic=5000,mh_nblocks=1,mh_jscale=1); estimation(datafile=data_consRicardoypg,first_obs=1,nobs=227,mh_replic=5000,mh_nblocks=1,mh_jscale=1);

View File

@ -1,44 +1,44 @@
var x y; var x y;
varexo e_x e_u; varexo e_x e_u;
parameters rho sig_x sig_u mu_y; parameters rho sig_x sig_u mu_y;
rho = .98; rho = .98;
mu_y=.015; mu_y=.015;
sig_x=0.00025; sig_x=0.00025;
sig_u=.0078; sig_u=.0078;
model(linear); model(linear);
x=rho*x(-1) + sig_x*e_x; x=rho*x(-1) + sig_x*e_x;
y=mu_y + x(-1) + sig_u*e_u; y=mu_y + x(-1) + sig_u*e_u;
end; end;
initval; initval;
x=0; x=0;
y=mu_y; y=mu_y;
end; end;
steady; steady;
shocks; shocks;
var e_x; var e_x;
stderr 1; stderr 1;
var e_u; var e_u;
stderr 1; stderr 1;
end; end;
estimated_params; estimated_params;
// ML estimation setup // ML estimation setup
// parameter name, initial value, boundaries_low, ..._up; // parameter name, initial value, boundaries_low, ..._up;
rho, 0, -0.99, 0.999; // use this for unconstrained max likelihood rho, 0, -0.99, 0.999; // use this for unconstrained max likelihood
// rho, .98, .975, .999 ; // use this for long run risk model // rho, .98, .975, .999 ; // use this for long run risk model
// sig_x, .0004,.0001,.05 ; // use this for the long run risk model // sig_x, .0004,.0001,.05 ; // use this for the long run risk model
sig_x, .0005, .00000000001, .01; // use this for unconstrained max likelihood sig_x, .0005, .00000000001, .01; // use this for unconstrained max likelihood
sig_u, .007,.001, .1; sig_u, .007,.001, .1;
mu_y, .014, .0001, .04; mu_y, .014, .0001, .04;
end; end;
varobs y; varobs y;
estimation(datafile=data_consRicardoypg,first_obs=1,nobs=227,mh_replic=0,mode_compute=4,mode_check); estimation(datafile=data_consRicardoypg,first_obs=1,nobs=227,mh_replic=0,mode_compute=4,mode_check);

View File

@ -1,79 +1,79 @@
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent // This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
var c k; var c k;
varexo taui tauc tauk g; varexo taui tauc tauk g;
parameters bet gam del alpha A; parameters bet gam del alpha A;
bet=.95; bet=.95;
gam=2; gam=2;
del=.2; del=.2;
alpha=.33; alpha=.33;
A=1; A=1;
model; model;
k=A*k(-1)^alpha+(1-del)*k(-1)-c-g; k=A*k(-1)^alpha+(1-del)*k(-1)-c-g;
c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+ c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1)); ((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
end; end;
initval; initval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g = 0.2; g = 0.2;
tauc = 0; tauc = 0;
taui = 0; taui = 0;
tauk = 0; tauk = 0;
end; end;
steady; steady;
endval; endval;
k=1.5; k=1.5;
c=0.4; c=0.4;
g =.4; g =.4;
tauc =0; tauc =0;
taui =0; taui =0;
tauk =0; tauk =0;
end; end;
steady; steady;
shocks; shocks;
var g; var g;
periods 1:9; periods 1:9;
values 0.2; values 0.2;
end; end;
simul(periods=100); simul(periods=100);
co=ys0_(var_index('c')); co=ys0_(var_index('c'));
ko = ys0_(var_index('k')); ko = ys0_(var_index('k'));
go = ex_(1,1); go = ex_(1,1);
rbig0=1/bet; rbig0=1/bet;
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam)); rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
rq0=alpha*A*ko^(alpha-1); rq0=alpha*A*ko^(alpha-1);
rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1); rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1);
wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1); wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1);
wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1); wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1);
sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del); sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del);
sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del); sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del);
figure figure
subplot(2,3,1) subplot(2,3,1)
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ]) plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
title('k') title('k')
subplot(2,3,2) subplot(2,3,2)
plot([co*ones(100,1) y_(var_index('c'),2:101)' ]) plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
title('c') title('c')
subplot(2,3,3) subplot(2,3,3)
plot([rbig0*ones(100,1) rbig' ]) plot([rbig0*ones(100,1) rbig' ])
title('R') title('R')
subplot(2,3,4) subplot(2,3,4)
plot([wq0*ones(100,1) wq' ]) plot([wq0*ones(100,1) wq' ])
title('w/q') title('w/q')
subplot(2,3,5) subplot(2,3,5)
plot([sq0*ones(100,1) sq' ]) plot([sq0*ones(100,1) sq' ])
title('s/q') title('s/q')
subplot(2,3,6) subplot(2,3,6)
plot([rq0*ones(100,1) rq' ]) plot([rq0*ones(100,1) rq' ])
title('r/q') title('r/q')
print -depsc fig1131.ps print -depsc fig1131.ps

View File

@ -1,130 +1,130 @@
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent // This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
// This is a commented version of the program given in the handout. // This is a commented version of the program given in the handout.
// Note: y_ records the simulated endogenous variables in alphabetical order // Note: y_ records the simulated endogenous variables in alphabetical order
// ys0_ records the initial steady state // ys0_ records the initial steady state
// ys_ records the terminal steady state // ys_ records the terminal steady state
// We check that these line up at the end points // We check that these line up at the end points
// Note: y_ has ys0_ in first column, ys_ in last column, explaining why it is 102 long; // Note: y_ has ys0_ in first column, ys_ in last column, explaining why it is 102 long;
// The sample of size 100 is in between. // The sample of size 100 is in between.
// Warning: we align c, k, and the taxes to exploit the dynare syntax. See comments below. // Warning: we align c, k, and the taxes to exploit the dynare syntax. See comments below.
// So k in the program corresponds to k_{t+1} and the same timing holds for the taxes. // So k in the program corresponds to k_{t+1} and the same timing holds for the taxes.
//Declares the endogenous variables; //Declares the endogenous variables;
var c k; var c k;
//declares the exogenous variables // investment tax credit, consumption tax, capital tax, government spending //declares the exogenous variables // investment tax credit, consumption tax, capital tax, government spending
varexo taui tauc tauk g; varexo taui tauc tauk g;
parameters bet gam del alpha A; parameters bet gam del alpha A;
bet=.95; // discount factor bet=.95; // discount factor
gam=2; // CRRA parameter gam=2; // CRRA parameter
del=.2; // depreciation rate del=.2; // depreciation rate
alpha=.33; // capital's share alpha=.33; // capital's share
A=1; // productivity A=1; // productivity
// Alignment convention: // Alignment convention:
// g tauc taui tauk are now columns of ex_. Because of a bad design decision // g tauc taui tauk are now columns of ex_. Because of a bad design decision
// the date of ex_(1,:) doesn't necessarily match the date in y_. Whether they match depends // the date of ex_(1,:) doesn't necessarily match the date in y_. Whether they match depends
// on the number of lag periods in endogenous versus exogenous variables. // on the number of lag periods in endogenous versus exogenous variables.
// In this example they match because tauc(-1) and taui(-1) enter the model. // In this example they match because tauc(-1) and taui(-1) enter the model.
// These decisions and the timing conventions mean that // These decisions and the timing conventions mean that
// y_(:,1) records the initial steady state, while y_(:,102) records the terminal steady state values. // y_(:,1) records the initial steady state, while y_(:,102) records the terminal steady state values.
// For j > 2, y_(:,j) records [c(j-1) .. k(j-1) .. G(j-1)] where k(j-1) means // For j > 2, y_(:,j) records [c(j-1) .. k(j-1) .. G(j-1)] where k(j-1) means
// end of period capital in period j-1, which equals k(j) in chapter 11 notation. // end of period capital in period j-1, which equals k(j) in chapter 11 notation.
// Note that the jump in G occurs in y_(;,11), which confirms this timing. // Note that the jump in G occurs in y_(;,11), which confirms this timing.
// the jump occurs now in ex_(11,1) // the jump occurs now in ex_(11,1)
model; model;
// equation 11.3.8.a // equation 11.3.8.a
k=A*k(-1)^alpha+(1-del)*k(-1)-c-g; k=A*k(-1)^alpha+(1-del)*k(-1)-c-g;
// equation 11.3.8e + 11.3.8.g // equation 11.3.8e + 11.3.8.g
c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+ c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1)); ((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
end; end;
initval; initval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g = 0.2; g = 0.2;
tauc = 0; tauc = 0;
taui = 0; taui = 0;
tauk = 0; tauk = 0;
end; end;
steady; // put this in if you want to start from the initial steady state, comment it out to start from the indicated values steady; // put this in if you want to start from the initial steady state, comment it out to start from the indicated values
endval; // The following values determine the new steady state after the shocks. endval; // The following values determine the new steady state after the shocks.
k=1.5; k=1.5;
c=0.4; c=0.4;
g =.4; g =.4;
tauc =0; tauc =0;
taui =0; taui =0;
tauk =0; tauk =0;
end; end;
steady; // We use steady again and the enval provided are initial guesses for dynare to compute the ss. steady; // We use steady again and the enval provided are initial guesses for dynare to compute the ss.
// The following lines produce a g sequence with a once and for all jump in g // The following lines produce a g sequence with a once and for all jump in g
shocks; shocks;
// we use shocks to undo that for the first 9 periods and leave g at // we use shocks to undo that for the first 9 periods and leave g at
// it's initial value of 0 // it's initial value of 0
var g; var g;
periods 1:9; periods 1:9;
values 0.2; values 0.2;
end; end;
// now solve the model // now solve the model
simul(periods=100); simul(periods=100);
// Note: y_ records the simulated endogenous variables in alphabetical order // Note: y_ records the simulated endogenous variables in alphabetical order
// ys0_ records the initial steady state // ys0_ records the initial steady state
// ys_ records the terminal steady state // ys_ records the terminal steady state
// check that these line up at the end points // check that these line up at the end points
y_(:,1) -ys0_(:) y_(:,1) -ys0_(:)
y_(:,102) - ys_(:) y_(:,102) - ys_(:)
// Compute the initial steady state for consumption to later do the plots. // Compute the initial steady state for consumption to later do the plots.
co=ys0_(var_index('c')); co=ys0_(var_index('c'));
ko = ys0_(var_index('k')); ko = ys0_(var_index('k'));
// g is in ex_(:,1) since it is stored in alphabetical order // g is in ex_(:,1) since it is stored in alphabetical order
go = ex_(1,1) go = ex_(1,1)
// The following equation compute the other endogenous variables use in the plots below // The following equation compute the other endogenous variables use in the plots below
// Since they are function of capital and consumption, so we can compute them from the solved // Since they are function of capital and consumption, so we can compute them from the solved
// model above. // model above.
// These equations were taken from page 333 of RMT2 // These equations were taken from page 333 of RMT2
rbig0=1/bet; rbig0=1/bet;
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam)); rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
rq0=alpha*A*ko^(alpha-1); rq0=alpha*A*ko^(alpha-1);
rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1); rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1);
wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1); wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1);
wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1); wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1);
sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del); sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del);
sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del); sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del);
//Now we plot the responses of the endogenous variables to the shock. //Now we plot the responses of the endogenous variables to the shock.
figure figure
subplot(2,3,1) subplot(2,3,1)
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ]) // note the timing: we lag capital to correct for syntax plot([ko*ones(100,1) y_(var_index('k'),1:100)' ]) // note the timing: we lag capital to correct for syntax
title('k') title('k')
subplot(2,3,2) subplot(2,3,2)
plot([co*ones(100,1) y_(var_index('c'),2:101)' ]) plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
title('c') title('c')
subplot(2,3,3) subplot(2,3,3)
plot([rbig0*ones(100,1) rbig' ]) plot([rbig0*ones(100,1) rbig' ])
title('R') title('R')
subplot(2,3,4) subplot(2,3,4)
plot([wq0*ones(100,1) wq' ]) plot([wq0*ones(100,1) wq' ])
title('w/q') title('w/q')
subplot(2,3,5) subplot(2,3,5)
plot([sq0*ones(100,1) sq' ]) plot([sq0*ones(100,1) sq' ])
title('s/q') title('s/q')
subplot(2,3,6) subplot(2,3,6)
plot([rq0*ones(100,1) rq' ]) plot([rq0*ones(100,1) rq' ])
title('r/q') title('r/q')

View File

@ -1,79 +1,79 @@
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent // This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
var c k; var c k;
varexo taui tauc tauk g; varexo taui tauc tauk g;
parameters bet gam del alpha A; parameters bet gam del alpha A;
bet=.95; bet=.95;
gam=2; gam=2;
del=.2; del=.2;
alpha=.33; alpha=.33;
A=1; A=1;
model; model;
k=A*k(-1)^alpha+(1-del)*k(-1)-c-g; k=A*k(-1)^alpha+(1-del)*k(-1)-c-g;
c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+ c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1)); ((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
end; end;
initval; initval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g = 0.2; g = 0.2;
tauc = 0; tauc = 0;
taui = 0; taui = 0;
tauk = 0; tauk = 0;
end; end;
steady; steady;
endval; endval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g = 0.2; g = 0.2;
tauc =0.2; tauc =0.2;
taui =0; taui =0;
tauk =0; tauk =0;
end; end;
steady; steady;
shocks; shocks;
var tauc; var tauc;
periods 1:9; periods 1:9;
values 0; values 0;
end; end;
simul(periods=100); simul(periods=100);
co=ys0_(var_index('c')); co=ys0_(var_index('c'));
ko = ys0_(var_index('k')); ko = ys0_(var_index('k'));
go = ex_(1,1); go = ex_(1,1);
rbig0=1/bet; rbig0=1/bet;
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam)); rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
rq0=alpha*A*ko^(alpha-1); rq0=alpha*A*ko^(alpha-1);
rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1); rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1);
wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1); wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1);
wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1); wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1);
sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del); sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del);
sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del); sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del);
figure figure
subplot(2,3,1) subplot(2,3,1)
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ]) plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
title('k') title('k')
subplot(2,3,2) subplot(2,3,2)
plot([co*ones(100,1) y_(var_index('c'),2:101)' ]) plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
title('c') title('c')
subplot(2,3,3) subplot(2,3,3)
plot([rbig0*ones(100,1) rbig' ]) plot([rbig0*ones(100,1) rbig' ])
title('R') title('R')
subplot(2,3,4) subplot(2,3,4)
plot([wq0*ones(100,1) wq' ]) plot([wq0*ones(100,1) wq' ])
title('w/q') title('w/q')
subplot(2,3,5) subplot(2,3,5)
plot([sq0*ones(100,1) sq' ]) plot([sq0*ones(100,1) sq' ])
title('s/q') title('s/q')
subplot(2,3,6) subplot(2,3,6)
plot([rq0*ones(100,1) rq' ]) plot([rq0*ones(100,1) rq' ])
title('r/q') title('r/q')
print -depsc fig1132.ps print -depsc fig1132.ps

View File

@ -1,80 +1,80 @@
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent // This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
var c k; var c k;
varexo taui tauc tauk g; varexo taui tauc tauk g;
parameters bet gam del alpha A; parameters bet gam del alpha A;
bet=.95; bet=.95;
gam=2; gam=2;
del=.2; del=.2;
alpha=.33; alpha=.33;
A=1; A=1;
model; model;
k=A*k(-1)^alpha+(1-del)*k(-1)-c-g; k=A*k(-1)^alpha+(1-del)*k(-1)-c-g;
c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+ c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1)); ((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
end; end;
initval; initval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g = 0.2; g = 0.2;
tauc = 0; tauc = 0;
taui = 0; taui = 0;
tauk = 0; tauk = 0;
end; end;
steady; steady;
endval; endval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g =0.2; g =0.2;
tauc =0; tauc =0;
taui =0.20; taui =0.20;
tauk =0; tauk =0;
end; end;
steady; steady;
shocks; shocks;
var taui; var taui;
periods 1:9; periods 1:9;
values 0; values 0;
end; end;
simul(periods=100); simul(periods=100);
co=ys0_(var_index('c')); co=ys0_(var_index('c'));
ko = ys0_(var_index('k')); ko = ys0_(var_index('k'));
go = ex_(1,1); go = ex_(1,1);
rbig0=1/bet; rbig0=1/bet;
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam)); rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
rq0=alpha*A*ko^(alpha-1); rq0=alpha*A*ko^(alpha-1);
rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1); rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1);
wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1); wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1);
wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1); wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1);
sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del); sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del);
sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del); sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del);
figure figure
subplot(2,3,1) subplot(2,3,1)
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ]) plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
title('k') title('k')
subplot(2,3,2) subplot(2,3,2)
plot([co*ones(100,1) y_(var_index('c'),2:101)' ]) plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
title('c') title('c')
subplot(2,3,3) subplot(2,3,3)
plot([rbig0*ones(100,1) rbig' ]) plot([rbig0*ones(100,1) rbig' ])
title('R') title('R')
subplot(2,3,4) subplot(2,3,4)
plot([wq0*ones(100,1) wq' ]) plot([wq0*ones(100,1) wq' ])
title('w/q') title('w/q')
subplot(2,3,5) subplot(2,3,5)
plot([sq0*ones(100,1) sq' ]) plot([sq0*ones(100,1) sq' ])
title('s/q') title('s/q')
subplot(2,3,6) subplot(2,3,6)
plot([rq0*ones(100,1) rq' ]) plot([rq0*ones(100,1) rq' ])
title('r/q') title('r/q')
print -depsc fig1151.ps print -depsc fig1151.ps

View File

@ -1,80 +1,80 @@
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent // This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
var c k; var c k;
varexo taui tauc tauk g; varexo taui tauc tauk g;
parameters bet gam del alpha A; parameters bet gam del alpha A;
bet=.95; bet=.95;
gam=2; gam=2;
del=.2; del=.2;
alpha=.33; alpha=.33;
A=1; A=1;
model; model;
k=A*k(-1)^alpha+(1-del)*k(-1)-c-g; k=A*k(-1)^alpha+(1-del)*k(-1)-c-g;
c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+ c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1)); ((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
end; end;
initval; initval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g = 0.2; g = 0.2;
tauc = 0; tauc = 0;
taui = 0; taui = 0;
tauk = 0; tauk = 0;
end; end;
steady; steady;
endval; endval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g =0.2; g =0.2;
tauc =0; tauc =0;
taui =0; taui =0;
tauk = 0.2; tauk = 0.2;
end; end;
steady; steady;
shocks; shocks;
var tauk; var tauk;
periods 1:9; periods 1:9;
values 0; values 0;
end; end;
simul(periods=100); simul(periods=100);
co=ys0_(var_index('c')); co=ys0_(var_index('c'));
ko = ys0_(var_index('k')); ko = ys0_(var_index('k'));
go = ex_(1,1); go = ex_(1,1);
rbig0=1/bet; rbig0=1/bet;
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam)); rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
rq0=alpha*A*ko^(alpha-1); rq0=alpha*A*ko^(alpha-1);
rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1); rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1);
wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1); wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1);
wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1); wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1);
sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del); sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del);
sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del); sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del);
figure figure
subplot(2,3,1) subplot(2,3,1)
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ]) plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
title('k') title('k')
subplot(2,3,2) subplot(2,3,2)
plot([co*ones(100,1) y_(var_index('c'),2:101)' ]) plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
title('c') title('c')
subplot(2,3,3) subplot(2,3,3)
plot([rbig0*ones(100,1) rbig' ]) plot([rbig0*ones(100,1) rbig' ])
title('R') title('R')
subplot(2,3,4) subplot(2,3,4)
plot([wq0*ones(100,1) wq' ]) plot([wq0*ones(100,1) wq' ])
title('w/q') title('w/q')
subplot(2,3,5) subplot(2,3,5)
plot([sq0*ones(100,1) sq' ]) plot([sq0*ones(100,1) sq' ])
title('s/q') title('s/q')
subplot(2,3,6) subplot(2,3,6)
plot([rq0*ones(100,1) rq' ]) plot([rq0*ones(100,1) rq' ])
title('r/q') title('r/q')
print -depsc fig1152.ps print -depsc fig1152.ps

View File

@ -1,80 +1,80 @@
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent // This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
var c k; var c k;
varexo taui tauc tauk g; varexo taui tauc tauk g;
parameters bet gam del alpha A; parameters bet gam del alpha A;
bet=.95; bet=.95;
gam=2; gam=2;
del=.2; del=.2;
alpha=.33; alpha=.33;
A=1; A=1;
model; model;
k=A*k(-1)^alpha+(1-del)*k(-1)-c-g; k=A*k(-1)^alpha+(1-del)*k(-1)-c-g;
c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+ c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1)); ((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
end; end;
initval; initval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g = 0.2; g = 0.2;
tauc = 0; tauc = 0;
taui = 0; taui = 0;
tauk = 0; tauk = 0;
end; end;
steady; steady;
endval; endval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g = 0.2; g = 0.2;
tauc =0; tauc =0;
taui =0; taui =0;
tauk =0; tauk =0;
end; end;
steady; steady;
shocks; shocks;
var g; var g;
periods 10; periods 10;
values 0.4; values 0.4;
end; end;
simul(periods=100); simul(periods=100);
co=ys0_(var_index('c')); co=ys0_(var_index('c'));
ko = ys0_(var_index('k')); ko = ys0_(var_index('k'));
go = ex_(1,1); go = ex_(1,1);
rbig0=1/bet; rbig0=1/bet;
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam)); rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
rq0=alpha*A*ko^(alpha-1); rq0=alpha*A*ko^(alpha-1);
rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1); rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1);
wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1); wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1);
wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1); wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1);
sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del); sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del);
sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del); sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del);
figure figure
subplot(2,3,1) subplot(2,3,1)
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ]) plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
title('k') title('k')
subplot(2,3,2) subplot(2,3,2)
plot([co*ones(100,1) y_(var_index('c'),2:101)' ]) plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
title('c') title('c')
subplot(2,3,3) subplot(2,3,3)
plot([rbig0*ones(100,1) rbig' ]) plot([rbig0*ones(100,1) rbig' ])
title('R') title('R')
subplot(2,3,4) subplot(2,3,4)
plot([wq0*ones(100,1) wq' ]) plot([wq0*ones(100,1) wq' ])
title('w/q') title('w/q')
subplot(2,3,5) subplot(2,3,5)
plot([sq0*ones(100,1) sq' ]) plot([sq0*ones(100,1) sq' ])
title('s/q') title('s/q')
subplot(2,3,6) subplot(2,3,6)
plot([rq0*ones(100,1) rq' ]) plot([rq0*ones(100,1) rq' ])
title('r/q') title('r/q')
print -depsc fig1171.ps print -depsc fig1171.ps

View File

@ -1,80 +1,80 @@
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent // This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
var c k; var c k;
varexo taui tauc tauk g; varexo taui tauc tauk g;
parameters bet gam del alpha A; parameters bet gam del alpha A;
bet=.95; bet=.95;
gam=2; gam=2;
del=.2; del=.2;
alpha=.33; alpha=.33;
A=1; A=1;
model; model;
k=A*k(-1)^alpha+(1-del)*k(-1)-c-g; k=A*k(-1)^alpha+(1-del)*k(-1)-c-g;
c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+ c^(-gam)= bet*(c(+1)^(-gam))*((1+tauc(-1))/(1+tauc))*((1-taui)*(1-del)/(1-taui(-1))+
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1)); ((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
end; end;
initval; initval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g = 0.2; g = 0.2;
tauc = 0; tauc = 0;
taui = 0; taui = 0;
tauk = 0; tauk = 0;
end; end;
steady; steady;
endval; endval;
k=1.5; k=1.5;
c=0.6; c=0.6;
g =0.2; g =0.2;
tauc =0; tauc =0;
taui =0; taui =0;
tauk =0; tauk =0;
end; end;
steady; steady;
shocks; shocks;
var taui; var taui;
periods 10; periods 10;
values 0.2; values 0.2;
end; end;
simul(periods=100); simul(periods=100);
co=ys0_(var_index('c')); co=ys0_(var_index('c'));
ko = ys0_(var_index('k')); ko = ys0_(var_index('k'));
go = ex_(1,1); go = ex_(1,1);
rbig0=1/bet; rbig0=1/bet;
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam)); rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
rq0=alpha*A*ko^(alpha-1); rq0=alpha*A*ko^(alpha-1);
rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1); rq=alpha*A*y_(var_index('k'),1:100).^(alpha-1);
wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1); wq0=A*ko^alpha-ko*alpha*A*ko^(alpha-1);
wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1); wq=A*y_(var_index('k'),1:100).^alpha-y_(var_index('k'),1:100).*alpha*A.*y_(var_index('k'),1:100).^(alpha-1);
sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del); sq0=(1-ex_(1,4))*A*alpha*ko^(alpha-1)+(1-del);
sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del); sq=(1-ex_(1:100,4)')*A*alpha.*y_(var_index('k'),1:100).^(alpha-1)+(1-del);
figure figure
subplot(2,3,1) subplot(2,3,1)
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ]) plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
title('k') title('k')
subplot(2,3,2) subplot(2,3,2)
plot([co*ones(100,1) y_(var_index('c'),2:101)' ]) plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
title('c') title('c')
subplot(2,3,3) subplot(2,3,3)
plot([rbig0*ones(100,1) rbig' ]) plot([rbig0*ones(100,1) rbig' ])
title('R') title('R')
subplot(2,3,4) subplot(2,3,4)
plot([wq0*ones(100,1) wq' ]) plot([wq0*ones(100,1) wq' ])
title('w/q') title('w/q')
subplot(2,3,5) subplot(2,3,5)
plot([sq0*ones(100,1) sq' ]) plot([sq0*ones(100,1) sq' ])
title('s/q') title('s/q')
subplot(2,3,6) subplot(2,3,6)
plot([rq0*ones(100,1) rq' ]) plot([rq0*ones(100,1) rq' ])
title('r/q') title('r/q')
print -depsc fig1172.ps print -depsc fig1172.ps

View File

@ -1,41 +1,41 @@
periods 1000; periods 1000;
var c k lab z; var c k lab z;
varexo e; varexo e;
parameters bet the del alp tau rho s; parameters bet the del alp tau rho s;
bet = 0.987; bet = 0.987;
the = 0.357; the = 0.357;
del = 0.012; del = 0.012;
alp = 0.4; alp = 0.4;
tau = 2; tau = 2;
rho = 0.95; rho = 0.95;
s = 0.007; s = 0.007;
model; model;
(c^the*(1-lab)^(1-the))^(1-tau)/c=bet*((c(+1)^the*(1-lab(+1))^(1-the))^(1-tau)/c(+1))*(1+alp*exp(z(+1))*k^(alp-1)*lab(+1)^(1-alp)-del); (c^the*(1-lab)^(1-the))^(1-tau)/c=bet*((c(+1)^the*(1-lab(+1))^(1-the))^(1-tau)/c(+1))*(1+alp*exp(z(+1))*k^(alp-1)*lab(+1)^(1-alp)-del);
c=the/(1-the)*(1-alp)*exp(z)*k(-1)^alp*lab^(-alp)*(1-lab); c=the/(1-the)*(1-alp)*exp(z)*k(-1)^alp*lab^(-alp)*(1-lab);
k=exp(z)*k(-1)^alp*lab^(1-alp)-c+(1-del)*k(-1); k=exp(z)*k(-1)^alp*lab^(1-alp)-c+(1-del)*k(-1);
z=rho*z(-1)+s*e; z=rho*z(-1)+s*e;
end; end;
initval; initval;
k = 1; k = 1;
c = 1; c = 1;
lab = 0.3; lab = 0.3;
z = 0; z = 0;
e = 0; e = 0;
end; end;
shocks; shocks;
var e; var e;
stderr 1; stderr 1;
end; end;
steady; steady;
stoch_simul(dr_algo=0,periods=1000,irf=40); stoch_simul(dr_algo=0,periods=1000,irf=40);
datasaver('simudata',[]); datasaver('simudata',[]);

View File

@ -1,44 +1,44 @@
var c k lab z; var c k lab z;
varexo e; varexo e;
parameters bet del alp rho the tau s; parameters bet del alp rho the tau s;
bet = 0.987; bet = 0.987;
the = 0.357; the = 0.357;
del = 0.012; del = 0.012;
alp = 0.4; alp = 0.4;
tau = 2; tau = 2;
rho = 0.95; rho = 0.95;
s = 0.007; s = 0.007;
model; model;
(c^the*(1-lab)^(1-the))^(1-tau)/c=bet*((c(+1)^the*(1-lab(+1))^(1-the))^(1-tau)/c(+1))*(1+alp*exp(z(+1))*k^(alp-1)*lab(+1)^(1-alp)-del); (c^the*(1-lab)^(1-the))^(1-tau)/c=bet*((c(+1)^the*(1-lab(+1))^(1-the))^(1-tau)/c(+1))*(1+alp*exp(z(+1))*k^(alp-1)*lab(+1)^(1-alp)-del);
c=the/(1-the)*(1-alp)*exp(z)*k(-1)^alp*lab^(-alp)*(1-lab); c=the/(1-the)*(1-alp)*exp(z)*k(-1)^alp*lab^(-alp)*(1-lab);
k=exp(z)*k(-1)^alp*lab^(1-alp)-c+(1-del)*k(-1); k=exp(z)*k(-1)^alp*lab^(1-alp)-c+(1-del)*k(-1);
z=rho*z(-1)+s*e; z=rho*z(-1)+s*e;
end; end;
initval; initval;
k = 1; k = 1;
c = 1; c = 1;
lab = 0.3; lab = 0.3;
z = 0; z = 0;
e = 0; e = 0;
end; end;
shocks; shocks;
var e; var e;
stderr 1; stderr 1;
end; end;
estimated_params; estimated_params;
stderr e, inv_gamma_pdf, 0.95,30; stderr e, inv_gamma_pdf, 0.95,30;
rho, beta_pdf,0.93,0.02; rho, beta_pdf,0.93,0.02;
the, normal_pdf,0.3,0.05; the, normal_pdf,0.3,0.05;
tau, normal_pdf,2.1,0.3; tau, normal_pdf,2.1,0.3;
end; end;
varobs c; varobs c;
estimation(datafile=simudata,mh_replic=1000,mh_jscale=0.9,nodiagnostic); estimation(datafile=simudata,mh_replic=1000,mh_jscale=0.9,nodiagnostic);

View File

@ -1,62 +1,62 @@
// Estimates the Hansen Sargent and Tallarini model by maximum likelihood. // Estimates the Hansen Sargent and Tallarini model by maximum likelihood.
var s c h k i d dhat dbar mus muc muh gamma R; var s c h k i d dhat dbar mus muc muh gamma R;
varexo e_dhat e_dbar; varexo e_dhat e_dbar;
parameters lambda deltah deltak mud b bet phi1 phi2 cdbar alpha1 alpha2 cdhat; parameters lambda deltah deltak mud b bet phi1 phi2 cdbar alpha1 alpha2 cdhat;
bet=0.9971; bet=0.9971;
deltah=0.682; deltah=0.682;
lambda=2.443; lambda=2.443;
alpha1=0.813; alpha1=0.813;
alpha2=0.189; alpha2=0.189;
phi1=0.998; phi1=0.998;
phi2=0.704; phi2=0.704;
mud=13.710; mud=13.710;
cdhat=0.155; cdhat=0.155;
cdbar=0.108; cdbar=0.108;
b=32; b=32;
deltak=0.975; deltak=0.975;
model(linear); model(linear);
R=deltak+gamma; R=deltak+gamma;
R*bet=1; R*bet=1;
s=(1+lambda)*c-lambda*h(-1); s=(1+lambda)*c-lambda*h(-1);
h=deltah*h(-1)+(1-deltah)*c; h=deltah*h(-1)+(1-deltah)*c;
k=deltak*k(-1)+i; k=deltak*k(-1)+i;
c+i=gamma*k(-1)+d; c+i=gamma*k(-1)+d;
mus=b-s; mus=b-s;
muc=(1+lambda)*mus+(1-deltah)*muh; muc=(1+lambda)*mus+(1-deltah)*muh;
muh=bet*(deltah*muh(+1)-lambda*mus(+1)); muh=bet*(deltah*muh(+1)-lambda*mus(+1));
muc=bet*R*muc(+1); muc=bet*R*muc(+1);
d=mud+dbar+dhat; d=mud+dbar+dhat;
dbar=(phi1+phi2)*dbar(-1) - phi1*phi2*dbar(-2) + cdbar*e_dbar; dbar=(phi1+phi2)*dbar(-1) - phi1*phi2*dbar(-2) + cdbar*e_dbar;
dhat=(alpha1+alpha2)*dhat(-1) - alpha1*alpha2*dhat(-2) + cdhat*e_dhat; dhat=(alpha1+alpha2)*dhat(-1) - alpha1*alpha2*dhat(-2) + cdhat*e_dhat;
end; end;
shocks; shocks;
var e_dhat; var e_dhat;
stderr 1; stderr 1;
var e_dbar; var e_dbar;
stderr 1; stderr 1;
end; end;
stoch_simul(irf=0, periods=500); stoch_simul(irf=0, periods=500);
// save dataHST c i; // save dataHST c i;
estimated_params; estimated_params;
bet,uniform_pdf, .9499999999, 0.0288675134306; bet,uniform_pdf, .9499999999, 0.0288675134306;
deltah,uniform_pdf, 0.45, 0.202072594216; deltah,uniform_pdf, 0.45, 0.202072594216;
lambda,uniform_pdf, 25.05, 14.4048892163; lambda,uniform_pdf, 25.05, 14.4048892163;
alpha1,uniform_pdf, 0.8, 0.115470053809; alpha1,uniform_pdf, 0.8, 0.115470053809;
alpha2,uniform_pdf, 0.25, 0.144337567297; alpha2,uniform_pdf, 0.25, 0.144337567297;
phi1,uniform_pdf, 0.8, 0.115470053809; phi1,uniform_pdf, 0.8, 0.115470053809;
phi2,uniform_pdf, 0.5, 0.288675134595; phi2,uniform_pdf, 0.5, 0.288675134595;
mud,uniform_pdf, 24.5, 14.1450815951; mud,uniform_pdf, 24.5, 14.1450815951;
cdhat,uniform_pdf, 0.175, 0.0721687836487; cdhat,uniform_pdf, 0.175, 0.0721687836487;
cdbar,uniform_pdf, 0.175, 0.0721687836487; cdbar,uniform_pdf, 0.175, 0.0721687836487;
end; end;
varobs c i; varobs c i;
// estimation(datafile=dataHST,first_obs=1,nobs=500,mode_compute=4,MH_jscale=2); // estimation(datafile=dataHST,first_obs=1,nobs=500,mode_compute=4,MH_jscale=2);
estimation(datafile=dataHST,first_obs=1,nobs=500,mode_compute=4,mode_check,mh_replic=5000,mh_nblocks=1,mh_jscale=0.3); estimation(datafile=dataHST,first_obs=1,nobs=500,mode_compute=4,mode_check,mh_replic=5000,mh_nblocks=1,mh_jscale=0.3);

View File

@ -1,62 +1,62 @@
// Estimates the Hansen Sargent and Tallarini model by maximum likelihood. // Estimates the Hansen Sargent and Tallarini model by maximum likelihood.
var s c h k i d dhat dbar mus muc muh gamma R; var s c h k i d dhat dbar mus muc muh gamma R;
varexo e_dhat e_dbar; varexo e_dhat e_dbar;
parameters lambda deltah deltak mud b bet phi1 phi2 cdbar alpha1 alpha2 cdhat; parameters lambda deltah deltak mud b bet phi1 phi2 cdbar alpha1 alpha2 cdhat;
bet=0.9971; bet=0.9971;
deltah=0.682; deltah=0.682;
lambda=2.443; lambda=2.443;
alpha1=0.813; alpha1=0.813;
alpha2=0.189; alpha2=0.189;
phi1=0.998; phi1=0.998;
phi2=0.704; phi2=0.704;
mud=13.710; mud=13.710;
cdhat=0.155; cdhat=0.155;
cdbar=0.108; cdbar=0.108;
b=32; b=32;
deltak=0.975; deltak=0.975;
model(linear); model(linear);
R=deltak+gamma; R=deltak+gamma;
R*bet=1; R*bet=1;
s=(1+lambda)*c-lambda*h(-1); s=(1+lambda)*c-lambda*h(-1);
h=deltah*h(-1)+(1-deltah)*c; h=deltah*h(-1)+(1-deltah)*c;
k=deltak*k(-1)+i; k=deltak*k(-1)+i;
c+i=gamma*k(-1)+d; c+i=gamma*k(-1)+d;
mus=b-s; mus=b-s;
muc=(1+lambda)*mus+(1-deltah)*muh; muc=(1+lambda)*mus+(1-deltah)*muh;
muh=bet*(deltah*muh(+1)-lambda*mus(+1)); muh=bet*(deltah*muh(+1)-lambda*mus(+1));
muc=bet*R*muc(+1); muc=bet*R*muc(+1);
d=mud+dbar+dhat; d=mud+dbar+dhat;
dbar=(phi1+phi2)*dbar(-1) - phi1*phi2*dbar(-2) + cdbar*e_dbar; dbar=(phi1+phi2)*dbar(-1) - phi1*phi2*dbar(-2) + cdbar*e_dbar;
dhat=(alpha1+alpha2)*dhat(-1) - alpha1*alpha2*dhat(-2) + cdhat*e_dhat; dhat=(alpha1+alpha2)*dhat(-1) - alpha1*alpha2*dhat(-2) + cdhat*e_dhat;
end; end;
shocks; shocks;
var e_dhat; var e_dhat;
stderr 1; stderr 1;
var e_dbar; var e_dbar;
stderr 1; stderr 1;
end; end;
// stoch_simul(irf=0, periods=500); // stoch_simul(irf=0, periods=500);
// save dataHST c i; // save dataHST c i;
estimated_params; estimated_params;
bet, .91, .9, .99999; bet, .91, .9, .99999;
deltah, 0.4, 0.1, 0.8; deltah, 0.4, 0.1, 0.8;
lambda, 2, 0.1, 50; lambda, 2, 0.1, 50;
alpha1, 0.8, 0.6, 0.99999; alpha1, 0.8, 0.6, 0.99999;
alpha2, 0.2, 0.01, 0.5; alpha2, 0.2, 0.01, 0.5;
phi1, 0.8, 0.6, 0.99999; phi1, 0.8, 0.6, 0.99999;
phi2, 0.5, 0.3, 0.9; phi2, 0.5, 0.3, 0.9;
mud, 10, 1, 50; mud, 10, 1, 50;
cdhat, 0.1, 0.05, 0.2; cdhat, 0.1, 0.05, 0.2;
cdbar, 0.1, 0.05, 0.2; cdbar, 0.1, 0.05, 0.2;
end; end;
varobs c i; varobs c i;
estimation(datafile=dataHST,first_obs=1,nobs=500,mode_compute=4,mode_check); estimation(datafile=dataHST,first_obs=1,nobs=500,mode_compute=4,mode_check);

View File

@ -1,45 +1,45 @@
periods 200; periods 200;
var c1 c2 k1 k2 a1 a2 y1 y2; var c1 c2 k1 k2 a1 a2 y1 y2;
varexo e1 e2; varexo e1 e2;
parameters gamma delta alpha beta rho; parameters gamma delta alpha beta rho;
gamma=2; gamma=2;
delta=.05; delta=.05;
alpha=.4; alpha=.4;
beta=.98; beta=.98;
rho=.85; rho=.85;
model; model;
c1=c2; c1=c2;
exp(c1)^(-gamma) = beta*exp(c1(+1))^(-gamma)*(alpha*exp(a1(+1))*exp(k1)^(alpha-1)+1-delta); exp(c1)^(-gamma) = beta*exp(c1(+1))^(-gamma)*(alpha*exp(a1(+1))*exp(k1)^(alpha-1)+1-delta);
exp(c2)^(-gamma) = beta*exp(c2(+1))^(-gamma)*(alpha*exp(a2(+1))*exp(k2)^(alpha-1)+1-delta); exp(c2)^(-gamma) = beta*exp(c2(+1))^(-gamma)*(alpha*exp(a2(+1))*exp(k2)^(alpha-1)+1-delta);
exp(c1)+exp(c2)+exp(k1)-exp(k1(-1))*(1-delta)+exp(k2)-exp(k2(-1))*(1-delta) = exp(a1)*exp(k1(-1))^alpha+exp(a2)*exp(k2(-1))^alpha; exp(c1)+exp(c2)+exp(k1)-exp(k1(-1))*(1-delta)+exp(k2)-exp(k2(-1))*(1-delta) = exp(a1)*exp(k1(-1))^alpha+exp(a2)*exp(k2(-1))^alpha;
a1=rho*a1(-1)+e1; a1=rho*a1(-1)+e1;
a2=rho*a2(-1)+e2; a2=rho*a2(-1)+e2;
exp(y1)=exp(a1)*exp(k1(-1))^alpha; exp(y1)=exp(a1)*exp(k1(-1))^alpha;
exp(y2)=exp(a2)*exp(k2(-1))^alpha; exp(y2)=exp(a2)*exp(k2(-1))^alpha;
end; end;
initval; initval;
y1=1.1; y1=1.1;
y2=1.1; y2=1.1;
k1=2.8; k1=2.8;
k2=2.8; k2=2.8;
c1=.8; c1=.8;
c2=.8; c2=.8;
a1=0; a1=0;
a2=0; a2=0;
e1=0; e1=0;
e2=0; e2=0;
end; end;
shocks; shocks;
var e1; stderr .08; var e1; stderr .08;
var e2; stderr .08; var e2; stderr .08;
end; end;
steady; steady;
stoch_simul(dr_algo=0,periods=200); stoch_simul(dr_algo=0,periods=200);
datatomfile('simu2',[]); datatomfile('simu2',[]);

View File

@ -1,51 +1,51 @@
periods 200; periods 200;
var c1 c2 k1 k2 a1 a2 y1 y2; var c1 c2 k1 k2 a1 a2 y1 y2;
varexo e1 e2; varexo e1 e2;
parameters gamma delta alpha beta rho; parameters gamma delta alpha beta rho;
gamma=2; gamma=2;
delta=.05; delta=.05;
alpha=.4; alpha=.4;
beta=.98; beta=.98;
rho=.85; rho=.85;
model; model;
c1=c2; c1=c2;
exp(c1)^(-gamma) = beta*exp(c1(+1))^(-gamma)*(alpha*exp(a1(+1))*exp(k1)^(alpha-1)+1-delta); exp(c1)^(-gamma) = beta*exp(c1(+1))^(-gamma)*(alpha*exp(a1(+1))*exp(k1)^(alpha-1)+1-delta);
exp(c2)^(-gamma) = beta*exp(c2(+1))^(-gamma)*(alpha*exp(a2(+1))*exp(k2)^(alpha-1)+1-delta); exp(c2)^(-gamma) = beta*exp(c2(+1))^(-gamma)*(alpha*exp(a2(+1))*exp(k2)^(alpha-1)+1-delta);
exp(c1)+exp(c2)+exp(k1)-exp(k1(-1))*(1-delta)+exp(k2)-exp(k2(-1))*(1-delta) = exp(a1)*exp(k1(-1))^alpha+exp(a2)*exp(k2(-1))^alpha; exp(c1)+exp(c2)+exp(k1)-exp(k1(-1))*(1-delta)+exp(k2)-exp(k2(-1))*(1-delta) = exp(a1)*exp(k1(-1))^alpha+exp(a2)*exp(k2(-1))^alpha;
a1=rho*a1(-1)+e1; a1=rho*a1(-1)+e1;
a2=rho*a2(-1)+e2; a2=rho*a2(-1)+e2;
exp(y1)=exp(a1)*exp(k1(-1))^alpha; exp(y1)=exp(a1)*exp(k1(-1))^alpha;
exp(y2)=exp(a2)*exp(k2(-1))^alpha; exp(y2)=exp(a2)*exp(k2(-1))^alpha;
end; end;
initval; initval;
y1=1.1; y1=1.1;
y2=1.1; y2=1.1;
k1=2.8; k1=2.8;
k2=2.8; k2=2.8;
c1=.8; c1=.8;
c2=.8; c2=.8;
a1=0; a1=0;
a2=0; a2=0;
e1=0; e1=0;
e2=0; e2=0;
end; end;
shocks; shocks;
var e1; stderr .08; var e1; stderr .08;
var e2; stderr .08; var e2; stderr .08;
end; end;
steady; steady;
estimated_params; estimated_params;
alpha, normal_pdf, .35, .05; alpha, normal_pdf, .35, .05;
rho, normal_pdf, .8, .05; rho, normal_pdf, .8, .05;
stderr e1, inv_gamma_pdf, .09, 10; stderr e1, inv_gamma_pdf, .09, 10;
stderr e2, inv_gamma_pdf, .09, 10; stderr e2, inv_gamma_pdf, .09, 10;
end; end;
varobs y1 y2; varobs y1 y2;
estimation(datafile=simu2,mh_replic=1200,mh_jscale=.7,nodiagnostic); estimation(datafile=simu2,mh_replic=1200,mh_jscale=.7,nodiagnostic);

View File

@ -1,46 +1,46 @@
periods 5000; periods 5000;
var c k mu_c b d in; var c k mu_c b d in;
varexo e_d e_b; varexo e_d e_b;
parameters R rho rho_b mu_b mu_d; parameters R rho rho_b mu_b mu_d;
R=1.05; R=1.05;
//rho=0.9; //rho=0.9;
rho = 0; rho = 0;
mu_b=30; mu_b=30;
mu_d=5; mu_d=5;
rho_b = 0; rho_b = 0;
model(linear); model(linear);
c+k = R*k(-1) + d; c+k = R*k(-1) + d;
mu_c = b - c; mu_c = b - c;
mu_c=mu_c(+1); mu_c=mu_c(+1);
d= rho*d(-1)+ mu_d*(1-rho) + e_d; d= rho*d(-1)+ mu_d*(1-rho) + e_d;
b=(1-rho_b)*mu_b+rho_b*b(-1)+e_b; b=(1-rho_b)*mu_b+rho_b*b(-1)+e_b;
in = k - k(-1); in = k - k(-1);
end; end;
//With a unit root, there exists no steady state. Use the following trick. //With a unit root, there exists no steady state. Use the following trick.
//Supply ONE solution corresponding to the initial k that you named. //Supply ONE solution corresponding to the initial k that you named.
initval; initval;
d=mu_d; d=mu_d;
k=100; k=100;
c = (R-1)*k +d; c = (R-1)*k +d;
mu_c=mu_b-c; mu_c=mu_b-c;
b=mu_b; b=mu_b;
end; end;
shocks; shocks;
var e_d; var e_d;
stderr 1; stderr 1;
var e_b; var e_b;
stderr 1; stderr 1;
end; end;
steady; steady;
check; check;
stoch_simul(dr_algo=1, order=1, periods=500, irf=10); stoch_simul(dr_algo=1, order=1, periods=500, irf=10);
save data_hall c in; save data_hall c in;

View File

@ -1,54 +1,54 @@
// Estimates the hall model using Bayesian method. // Estimates the hall model using Bayesian method.
// hall1_estimate.mod estimates by maximum likelihood // hall1_estimate.mod estimates by maximum likelihood
periods 5000; periods 5000;
var c k mu_c b d in; var c k mu_c b d in;
varexo e_d e_b; varexo e_d e_b;
parameters R rho rho_b mu_b mu_d; parameters R rho rho_b mu_b mu_d;
R=1.05; R=1.05;
rho=0.9; rho=0.9;
mu_b=30; mu_b=30;
mu_d=5; mu_d=5;
rho_b = 0.5; rho_b = 0.5;
model(linear); model(linear);
c+k = R*k(-1) + d; c+k = R*k(-1) + d;
mu_c = b - c; mu_c = b - c;
mu_c=mu_c(+1); mu_c=mu_c(+1);
d= rho*d(-1)+ mu_d*(1-rho) + e_d; d= rho*d(-1)+ mu_d*(1-rho) + e_d;
b=(1-rho_b)*mu_b+rho_b*b(-1)+e_b; b=(1-rho_b)*mu_b+rho_b*b(-1)+e_b;
in = k - k(-1); in = k - k(-1);
end; end;
// Michel says that in a stationary linear model, this junk is irrelevant. // Michel says that in a stationary linear model, this junk is irrelevant.
// But with a unit root, there exists no steady state. Use the following trick. // But with a unit root, there exists no steady state. Use the following trick.
// Supply ONE solution corresponding to the initial k that you named. (Michel is a gneius!! Or so he thinks -- let's see // Supply ONE solution corresponding to the initial k that you named. (Michel is a gneius!! Or so he thinks -- let's see
// if this works.) // if this works.)
initval; initval;
d=mu_d; d=mu_d;
k=100; k=100;
c = (R-1)*k +d; c = (R-1)*k +d;
mu_c=mu_b-c; mu_c=mu_b-c;
b=mu_b; b=mu_b;
end; end;
shocks; shocks;
var e_d; var e_d;
stderr 0.05; stderr 0.05;
var e_b; var e_b;
stderr 0.05; stderr 0.05;
end; end;
estimated_params; estimated_params;
rho, beta_pdf, .1, 0.2; rho, beta_pdf, .1, 0.2;
R, normal_pdf, 1.02, 0.05; R, normal_pdf, 1.02, 0.05;
end; end;
varobs c in; varobs c in;
// declare the unit root variables for diffuse filter // declare the unit root variables for diffuse filter
unit_root_vars k; unit_root_vars k;
//estimation(datafile=data_hall,first_obs=101,nobs=200,mh_replic=1000,mh_nblocks=2,mh_jscale=2,mode_compute=0,mode_file=hall1_estimate2_mode); //estimation(datafile=data_hall,first_obs=101,nobs=200,mh_replic=1000,mh_nblocks=2,mh_jscale=2,mode_compute=0,mode_file=hall1_estimate2_mode);
estimation(datafile=data_hall,first_obs=101,nobs=200,mh_replic=1000,mh_nblocks=2,mh_jscale=2); estimation(datafile=data_hall,first_obs=101,nobs=200,mh_replic=1000,mh_nblocks=2,mh_jscale=2);

View File

@ -1,56 +1,56 @@
// Estimates the hall model using maximum likelihood. See hall1_estimateBayes.mod for Bayesian method // Estimates the hall model using maximum likelihood. See hall1_estimateBayes.mod for Bayesian method
periods 5000; periods 5000;
var c k mu_c b d in; var c k mu_c b d in;
varexo e_d e_b; varexo e_d e_b;
parameters R rho rho_b mu_b mu_d; parameters R rho rho_b mu_b mu_d;
R=1.05; R=1.05;
rho=0.9; rho=0.9;
mu_b=30; mu_b=30;
mu_d=5; mu_d=5;
rho_b = 0.5; rho_b = 0.5;
model(linear); model(linear);
c+k = R*k(-1) + d; c+k = R*k(-1) + d;
mu_c = b - c; mu_c = b - c;
mu_c=mu_c(+1); mu_c=mu_c(+1);
d= rho*d(-1)+ mu_d*(1-rho) + e_d; d= rho*d(-1)+ mu_d*(1-rho) + e_d;
b=(1-rho_b)*mu_b+rho_b*b(-1)+e_b; b=(1-rho_b)*mu_b+rho_b*b(-1)+e_b;
in = k - k(-1); in = k - k(-1);
end; end;
// Michel says that in a stationary linear model, this junk is irrelevant. // Michel says that in a stationary linear model, this junk is irrelevant.
// But with a unit root, there exists no steady state. Use the following trick. // But with a unit root, there exists no steady state. Use the following trick.
// Supply ONE solution corresponding to the initial k that you named. (Michel is a gneius!! Or so he thinks -- let's see // Supply ONE solution corresponding to the initial k that you named. (Michel is a gneius!! Or so he thinks -- let's see
// if this works.) // if this works.)
initval; initval;
d=mu_d; d=mu_d;
k=100; k=100;
c = (R-1)*k +d; c = (R-1)*k +d;
mu_c=mu_b-c; mu_c=mu_b-c;
b=mu_b; b=mu_b;
end; end;
shocks; shocks;
var e_d; var e_d;
stderr 0.05; stderr 0.05;
var e_b; var e_b;
stderr 0.05; stderr 0.05;
end; end;
estimated_params; estimated_params;
// ML estimation setup // ML estimation setup
// parameter name, initial value, boundaries_low, ..._up; // parameter name, initial value, boundaries_low, ..._up;
// now we use the optimum results from csminwel for starting up Marco's // now we use the optimum results from csminwel for starting up Marco's
rho, -0.0159, -0.9, 0.9; rho, -0.0159, -0.9, 0.9;
R, 1.0074, 0, 1.5; R, 1.0074, 0, 1.5;
end; end;
varobs c in; varobs c in;
// declare the unit root variables for diffuse filter // declare the unit root variables for diffuse filter
unit_root_vars k; unit_root_vars k;
estimation(datafile=data_hall,first_obs=101,nobs=200,mh_replic=0,mode_compute=4,mode_check); estimation(datafile=data_hall,first_obs=101,nobs=200,mh_replic=0,mode_compute=4,mode_check);
// Note: there is a problem when you try to use method 5. Tom, Jan 13, 2006 // Note: there is a problem when you try to use method 5. Tom, Jan 13, 2006

View File

@ -1,55 +1,55 @@
// Rosen schooling model // Rosen schooling model
// //
// The model is the one Sherwin Rosen showed Sargent in Sargent's Chicago office. // The model is the one Sherwin Rosen showed Sargent in Sargent's Chicago office.
// The equations are // The equations are
// //
// s_t = a0 + a1*P_t + e_st ; flow supply of new engineers // s_t = a0 + a1*P_t + e_st ; flow supply of new engineers
// //
// N_t = (1-delta)*N_{t-1} + s_{t-k} ; time to school engineers // N_t = (1-delta)*N_{t-1} + s_{t-k} ; time to school engineers
// //
// N_t = d0 - d1*W_t +e_dt ; demand for engineers // N_t = d0 - d1*W_t +e_dt ; demand for engineers
// //
// P_t = (1-delta)*bet P_(t+1) + beta^k*W_(t+k); present value of wages of an engineer // P_t = (1-delta)*bet P_(t+1) + beta^k*W_(t+k); present value of wages of an engineer
periods 500; periods 500;
var s N P W; var s N P W;
varexo e_s e_d; varexo e_s e_d;
parameters a0 a1 delta d0 d1 bet k; parameters a0 a1 delta d0 d1 bet k;
a0=10; a0=10;
a1=1; a1=1;
d0=1000; d0=1000;
d1=1; d1=1;
bet=.99; bet=.99;
delta=.02; delta=.02;
model(linear); model(linear);
s=a0+a1*P+e_s; // flow supply of new entrants s=a0+a1*P+e_s; // flow supply of new entrants
N=(1-delta)*N(-1) + s(-4); // evolution of the stock N=(1-delta)*N(-1) + s(-4); // evolution of the stock
N=d0-d1*W+e_d; // stock demand equation N=d0-d1*W+e_d; // stock demand equation
P=bet*(1-delta)*P(+1) + bet^4*(1-delta)^4*W(+4); // present value of wages P=bet*(1-delta)*P(+1) + bet^4*(1-delta)^4*W(+4); // present value of wages
end; end;
initval; initval;
s=0; s=0;
N=0; N=0;
P=0; P=0;
W=0; W=0;
end; end;
shocks; shocks;
var e_d; var e_d;
stderr 1; stderr 1;
var e_s; var e_s;
stderr 1; stderr 1;
end; end;
steady; steady;
check; check;
stoch_simul(dr_algo=1, order=1, periods=500, irf=10); stoch_simul(dr_algo=1, order=1, periods=500, irf=10);
//datasaver('simudata',[]); //datasaver('simudata',[]);
save data_rosen s N P W; save data_rosen s N P W;

View File

@ -1,63 +1,63 @@
// Estimates the Rosen schooling model by maximum likelihood // Estimates the Rosen schooling model by maximum likelihood
// Rosen schooling model // Rosen schooling model
// //
// The model is the one Sherwin Rosen showed Sargent in Sargent's Chicago office. // The model is the one Sherwin Rosen showed Sargent in Sargent's Chicago office.
// The equations are // The equations are
// //
// s_t = a0 + a1*P_t + e_st ; flow supply of new engineers // s_t = a0 + a1*P_t + e_st ; flow supply of new engineers
// //
// N_t = (1-delta)*N_{t-1} + s_{t-k} ; time to school engineers // N_t = (1-delta)*N_{t-1} + s_{t-k} ; time to school engineers
// //
// N_t = d0 - d1*W_t +e_dt ; demand for engineers // N_t = d0 - d1*W_t +e_dt ; demand for engineers
// //
// P_t = (1-delta)*bet P_(t+1) + W_(t+k); present value of wages of an engineer // P_t = (1-delta)*bet P_(t+1) + W_(t+k); present value of wages of an engineer
periods 500; periods 500;
var s N P W; var s N P W;
varexo e_s e_d; varexo e_s e_d;
parameters a0 a1 delta d0 d1 bet ; parameters a0 a1 delta d0 d1 bet ;
a0=10; a0=10;
a1=1; a1=1;
d0=1000; d0=1000;
d1=1; d1=1;
bet=.99; bet=.99;
delta=.02; delta=.02;
model(linear); model(linear);
s=a0+a1*P+e_s; // flow supply of new entrants s=a0+a1*P+e_s; // flow supply of new entrants
N=(1-delta)*N(-1) + s(-4); // evolution of the stock N=(1-delta)*N(-1) + s(-4); // evolution of the stock
N=d0-d1*W+e_d; // stock demand equation N=d0-d1*W+e_d; // stock demand equation
P=bet*(1-delta)*P(+1) + bet^4*(1-delta)^4*W(+4); // present value of wages P=bet*(1-delta)*P(+1) + bet^4*(1-delta)^4*W(+4); // present value of wages
end; end;
initval; initval;
s=0; s=0;
N=0; N=0;
P=0; P=0;
W=0; W=0;
end; end;
shocks; shocks;
var e_d; var e_d;
stderr 1; stderr 1;
var e_s; var e_s;
stderr 1; stderr 1;
end; end;
steady; steady;
estimated_params; estimated_params;
a1, gamma_pdf, .5, .5; a1, gamma_pdf, .5, .5;
d1, gamma_pdf, 2, .5; d1, gamma_pdf, 2, .5;
end; end;
varobs W N; varobs W N;
estimation(datafile=data_rosen,first_obs=101,nobs=200,mh_replic=5000,mh_nblocks=2,mh_jscale=2,mode_compute=0,mode_file=rosen_estimateML_mode); estimation(datafile=data_rosen,first_obs=101,nobs=200,mh_replic=5000,mh_nblocks=2,mh_jscale=2,mode_compute=0,mode_file=rosen_estimateML_mode);

View File

@ -1,65 +1,65 @@
// Estimates the Rosen schooling model by maximum likelihood // Estimates the Rosen schooling model by maximum likelihood
// Rosen schooling model // Rosen schooling model
// //
// The model is the one Sherwin Rosen showed Sargent in Sargent's Chicago office. // The model is the one Sherwin Rosen showed Sargent in Sargent's Chicago office.
// The equations are // The equations are
// //
// s_t = a0 + a1*P_t + e_st ; flow supply of new engineers // s_t = a0 + a1*P_t + e_st ; flow supply of new engineers
// //
// N_t = (1-delta)*N_{t-1} + s_{t-k} ; time to school engineers // N_t = (1-delta)*N_{t-1} + s_{t-k} ; time to school engineers
// //
// N_t = d0 - d1*W_t +e_dt ; demand for engineers // N_t = d0 - d1*W_t +e_dt ; demand for engineers
// //
// P_t = (1-delta)*bet P_(t+1) + W_(t+k); present value of wages of an engineer // P_t = (1-delta)*bet P_(t+1) + W_(t+k); present value of wages of an engineer
periods 500; periods 500;
var s N P W; var s N P W;
varexo e_s e_d; varexo e_s e_d;
parameters a0 a1 delta d0 d1 bet ; parameters a0 a1 delta d0 d1 bet ;
a0=10; a0=10;
a1=1; a1=1;
d0=1000; d0=1000;
d1=1; d1=1;
bet=.99; bet=.99;
delta=.02; delta=.02;
model(linear); model(linear);
s=a0+a1*P+e_s; // flow supply of new entrants s=a0+a1*P+e_s; // flow supply of new entrants
N=(1-delta)*N(-1) + s(-4); // evolution of the stock N=(1-delta)*N(-1) + s(-4); // evolution of the stock
N=d0-d1*W+e_d; // stock demand equation N=d0-d1*W+e_d; // stock demand equation
P=bet*(1-delta)*P(+1) + bet^4*(1-delta)^4*W(+4); // present value of wages P=bet*(1-delta)*P(+1) + bet^4*(1-delta)^4*W(+4); // present value of wages
end; end;
initval; initval;
s=0; s=0;
N=0; N=0;
P=0; P=0;
W=0; W=0;
end; end;
shocks; shocks;
var e_d; var e_d;
stderr 1; stderr 1;
var e_s; var e_s;
stderr 1; stderr 1;
end; end;
steady; steady;
estimated_params; estimated_params;
a1, .5, -10, 10; a1, .5, -10, 10;
d1, .5, -20, 40; // these are the ranges for the parameters d1, .5, -20, 40; // these are the ranges for the parameters
end; end;
varobs W N; varobs W N;
estimation(datafile=data_rosen,first_obs=101,nobs=200,mh_replic=0,mode_compute=4,mode_check); estimation(datafile=data_rosen,first_obs=101,nobs=200,mh_replic=0,mode_compute=4,mode_check);

View File

@ -1,41 +1,41 @@
// this program solves and simulates the model in // this program solves and simulates the model in
// "The Demand for Money during Hyperinflations under Rational Expectations: I" by T. Sargent, IER 1977 // "The Demand for Money during Hyperinflations under Rational Expectations: I" by T. Sargent, IER 1977
// this program mainly serves as the data generating process for the estimation of the model in sargent77ML.mod and sargent77Bayes.mod // this program mainly serves as the data generating process for the estimation of the model in sargent77ML.mod and sargent77Bayes.mod
// variables are defined as follows: // variables are defined as follows:
// x=p_t-p_{t-1}, p being the log of the price level // x=p_t-p_{t-1}, p being the log of the price level
// mu=m_t-m_{t-1}, m being the log of money supply // mu=m_t-m_{t-1}, m being the log of money supply
// note that in contrast to the paper eta and epsilon have variance 1 (they are multiplied by the standard deviations) // note that in contrast to the paper eta and epsilon have variance 1 (they are multiplied by the standard deviations)
var x mu a1 a2; var x mu a1 a2;
varexo epsilon eta; varexo epsilon eta;
parameters alpha lambda sig_eta sig_epsilon; parameters alpha lambda sig_eta sig_epsilon;
lambda=.5921; lambda=.5921;
alpha=-2.344; alpha=-2.344;
sig_eta= .001; sig_eta= .001;
sig_epsilon= .001; sig_epsilon= .001;
// the model equations are taken from equation (27) on page 69 of the paper // the model equations are taken from equation (27) on page 69 of the paper
model; model;
x=x(-1)-lambda*a1(-1)+(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta; x=x(-1)-lambda*a1(-1)+(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta;
mu=(1-lambda)*x(-1)+lambda*mu(-1)-lambda*a2(-1)+(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta; mu=(1-lambda)*x(-1)+lambda*mu(-1)-lambda*a2(-1)+(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta;
a1=(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta; a1=(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta;
a2=(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta; a2=(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta;
end; end;
steady; steady;
shocks; shocks;
var eta; var eta;
stderr 1; stderr 1;
var epsilon; var epsilon;
stderr 1; stderr 1;
end; end;
stoch_simul(dr_algo=1,drop=0, order=1, periods=33, irf=0); stoch_simul(dr_algo=1,drop=0, order=1, periods=33, irf=0);
save data_hyperinfl x mu; save data_hyperinfl x mu;

View File

@ -1,48 +1,48 @@
// this program estimates the model in // this program estimates the model in
// "The Demand for Money during Hyperinflations under Rational Expectations: I" by T. Sargent, IER 1977 using Bayesian techniques // "The Demand for Money during Hyperinflations under Rational Expectations: I" by T. Sargent, IER 1977 using Bayesian techniques
// variables are defined as follows: // variables are defined as follows:
// x=p_t-p_{t-1}, p being the log of the price level // x=p_t-p_{t-1}, p being the log of the price level
// mu=m_t-m_{t-1}, m being the log of money supply // mu=m_t-m_{t-1}, m being the log of money supply
// note that in contrast to the paper eta and epsilon have variance 1 (they are multiplied by the standard deviations) // note that in contrast to the paper eta and epsilon have variance 1 (they are multiplied by the standard deviations)
var x mu a1 a2; var x mu a1 a2;
varexo epsilon eta; varexo epsilon eta;
parameters alpha lambda sig_eta sig_epsilon; parameters alpha lambda sig_eta sig_epsilon;
lambda=.5921; lambda=.5921;
alpha=-2.344; alpha=-2.344;
sig_eta=.001; sig_eta=.001;
sig_epsilon=.001; sig_epsilon=.001;
model; model;
x=x(-1)-lambda*a1(-1)+(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta; x=x(-1)-lambda*a1(-1)+(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta;
mu=(1-lambda)*x(-1)+lambda*mu(-1)-lambda*a2(-1)+(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta; mu=(1-lambda)*x(-1)+lambda*mu(-1)-lambda*a2(-1)+(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta;
a1=(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta; a1=(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta;
a2=(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta; a2=(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta;
end; end;
steady; steady;
shocks; shocks;
var eta; var eta;
stderr 1; stderr 1;
var epsilon; var epsilon;
stderr 1; stderr 1;
end; end;
estimated_params; estimated_params;
// Bayesian setup // Bayesian setup
lambda, uniform_pdf, 0.68, .5; lambda, uniform_pdf, 0.68, .5;
alpha, uniform_pdf, -5, 2; alpha, uniform_pdf, -5, 2;
sig_eta, uniform_pdf, .5, 0.25; sig_eta, uniform_pdf, .5, 0.25;
sig_epsilon, uniform_pdf, .5, 0.25; sig_epsilon, uniform_pdf, .5, 0.25;
end; end;
varobs mu x; varobs mu x;
unit_root_vars x; unit_root_vars x;
estimation(datafile=cagan_data,first_obs=1,nobs=34,mh_replic=25000,mh_nblocks=1,mh_jscale=1,mode_compute=4); estimation(datafile=cagan_data,first_obs=1,nobs=34,mh_replic=25000,mh_nblocks=1,mh_jscale=1,mode_compute=4);

View File

@ -1,52 +1,52 @@
// this program estimates the model in // this program estimates the model in
// "The Demand for Money during Hyperinflations under Rational Expectations: I" by T. Sargent, IER 1977 using maximum likelihood // "The Demand for Money during Hyperinflations under Rational Expectations: I" by T. Sargent, IER 1977 using maximum likelihood
// variables are defined as follows: // variables are defined as follows:
// x=p_t-p_{t-1}, p being the log of the price level // x=p_t-p_{t-1}, p being the log of the price level
// mu=m_t-m_{t-1}, m being the log of money supply // mu=m_t-m_{t-1}, m being the log of money supply
// note that in contrast to the paper eta and epsilon have variance 1 (they are multiplied by the standard deviations) // note that in contrast to the paper eta and epsilon have variance 1 (they are multiplied by the standard deviations)
var x mu a1 a2; var x mu a1 a2;
varexo epsilon eta; varexo epsilon eta;
parameters alpha lambda sig_eta sig_epsilon; parameters alpha lambda sig_eta sig_epsilon;
lambda=.5921; lambda=.5921;
alpha=-2.344; alpha=-2.344;
sig_eta=.001; sig_eta=.001;
sig_epsilon=.001; sig_epsilon=.001;
model; model;
x=x(-1)-lambda*a1(-1)+(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta; x=x(-1)-lambda*a1(-1)+(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta;
mu=(1-lambda)*x(-1)+lambda*mu(-1)-lambda*a2(-1)+(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta; mu=(1-lambda)*x(-1)+lambda*mu(-1)-lambda*a2(-1)+(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta;
a1=(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta; a1=(1/(lambda+alpha*(1-lambda)))*sig_epsilon*epsilon-(1/(lambda+alpha*(1-lambda)))*sig_eta*eta;
a2=(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta; a2=(1+alpha*(1-lambda))/(lambda+alpha*(1-lambda))*sig_epsilon*epsilon-(1-lambda)/(lambda+alpha*(1-lambda))*sig_eta*eta;
end; end;
steady; steady;
shocks; shocks;
var eta; var eta;
stderr 1; stderr 1;
var epsilon; var epsilon;
stderr 1; stderr 1;
end; end;
estimated_params; estimated_params;
// ML estimation setup // ML estimation setup
// parameter name, initial value, boundaries_low, ..._up; // parameter name, initial value, boundaries_low, ..._up;
lambda, .5, 0.25, 0.75; lambda, .5, 0.25, 0.75;
alpha, -2, -8, -0.1; alpha, -2, -8, -0.1;
sig_eta, .0001, 0.0001, 0.3; sig_eta, .0001, 0.0001, 0.3;
sig_epsilon, .0001, 0.0001, 0.3; sig_epsilon, .0001, 0.0001, 0.3;
end; end;
varobs mu x; varobs mu x;
unit_root_vars x; unit_root_vars x;
estimation(datafile=cagan_data,first_obs=1,nobs=34,mh_replic=0,mode_compute=4,mode_check); estimation(datafile=cagan_data,first_obs=1,nobs=34,mh_replic=0,mode_compute=4,mode_check);

View File

@ -1,36 +1,36 @@
var c k; var c k;
varexo x; varexo x;
parameters alph gam delt bet aa; parameters alph gam delt bet aa;
alph=0.5; alph=0.5;
gam=0.5; gam=0.5;
delt=0.02; delt=0.02;
bet=0.05; bet=0.05;
aa=0.5; aa=0.5;
model; model;
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
end; end;
initval; initval;
x = 1; x = 1;
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1)); k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
c = aa*k^alph-delt*k; c = aa*k^alph-delt*k;
end; end;
steady; steady;
check; check;
shocks; shocks;
var x; var x;
periods 1; periods 1;
values 1.2; values 1.2;
end; end;
simul(periods=200); simul(periods=200);
rplot c; rplot c;
rplot k; rplot k;

View File

@ -1,37 +1,37 @@
// check shocks on several periods // check shocks on several periods
var c k; var c k;
varexo x; varexo x;
parameters alph gam delt bet aa; parameters alph gam delt bet aa;
alph=0.5; alph=0.5;
gam=0.5; gam=0.5;
delt=0.02; delt=0.02;
bet=0.05; bet=0.05;
aa=0.5; aa=0.5;
model; model;
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
end; end;
initval; initval;
x = 1; x = 1;
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1)); k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
c = aa*k^alph-delt*k +1 ; c = aa*k^alph-delt*k +1 ;
end; end;
steady; steady;
check; check;
shocks; shocks;
var x; var x;
periods 1 2 3 4; periods 1 2 3 4;
values 1.1 1.2 1.3 1.4; values 1.1 1.2 1.3 1.4;
end; end;
simul(periods=200); simul(periods=200);
rplot c; rplot c;
rplot k; rplot k;

View File

@ -1,34 +1,34 @@
/* Test for the initval_file() command. This file needs ramst_initval_file_data.m. It should give results similar to those of ramst.mod */ /* Test for the initval_file() command. This file needs ramst_initval_file_data.m. It should give results similar to those of ramst.mod */
var c k; var c k;
varexo x; varexo x;
parameters alph gam delt bet aa; parameters alph gam delt bet aa;
alph=0.5; alph=0.5;
gam=0.5; gam=0.5;
delt=0.02; delt=0.02;
bet=0.05; bet=0.05;
aa=0.5; aa=0.5;
model; model;
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
end; end;
initval; initval;
x = 1; x = 1;
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1)); k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
c = aa*k^alph-delt*k; c = aa*k^alph-delt*k;
end; end;
initval_file(filename = ramst_initval_file_data); initval_file(filename = ramst_initval_file_data);
steady; steady;
check; check;
simul(periods=200); simul(periods=200);
rplot c; rplot c;
rplot k; rplot k;

View File

@ -1,65 +1,65 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54; psi1 = 1.54;
psi2 = 0.25; psi2 = 0.25;
psi3 = 0.25; psi3 = 0.25;
rho_R = 0.5; rho_R = 0.5;
alpha = 0.3; alpha = 0.3;
rr = 2.51; rr = 2.51;
k = 0.5; k = 0.5;
tau = 0.5; tau = 0.5;
rho_q = 0.4; rho_q = 0.4;
rho_A = 0.2; rho_A = 0.2;
rho_ys = 0.9; rho_ys = 0.9;
rho_pies = 0.7; rho_pies = 0.7;
model(linear); model(linear);
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s; pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R; R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q; dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys; y_s = rho_ys*y_s(-1)+e_ys;
pie_s = rho_pies*pie_s(-1)+e_pies; pie_s = rho_pies*pie_s(-1)+e_pies;
A = rho_A*A(-1)+e_A; A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A; y_obs = y-y(-1)+A;
pie_obs = 4*pie; pie_obs = 4*pie;
R_obs = 4*R; R_obs = 4*R;
end; end;
shocks; shocks;
var e_R = 1.25^2; var e_R = 1.25^2;
var e_q = 2.5^2; var e_q = 2.5^2;
var e_A = 1.89; var e_A = 1.89;
var e_ys = 1.89; var e_ys = 1.89;
var e_pies = 1.89; var e_pies = 1.89;
end; end;
varobs y_obs R_obs pie_obs dq de; varobs y_obs R_obs pie_obs dq de;
estimated_params; estimated_params;
psi1 , gamma_pdf,1.5,0.5; psi1 , gamma_pdf,1.5,0.5;
psi2 , gamma_pdf,0.25,0.125; psi2 , gamma_pdf,0.25,0.125;
psi3 , gamma_pdf,0.25,0.125; psi3 , gamma_pdf,0.25,0.125;
rho_R ,beta_pdf,0.5,0.2; rho_R ,beta_pdf,0.5,0.2;
alpha ,beta_pdf,0.3,0.1; alpha ,beta_pdf,0.3,0.1;
rr ,gamma_pdf,2.5,1; rr ,gamma_pdf,2.5,1;
k , gamma_pdf,0.5,0.25; k , gamma_pdf,0.5,0.25;
tau ,gamma_pdf,0.5,0.2; tau ,gamma_pdf,0.5,0.2;
rho_q ,beta_pdf,0.4,0.2; rho_q ,beta_pdf,0.4,0.2;
rho_A ,beta_pdf,0.5,0.2; rho_A ,beta_pdf,0.5,0.2;
rho_ys ,beta_pdf,0.8,0.1; rho_ys ,beta_pdf,0.8,0.1;
rho_pies,beta_pdf,0.7,0.15; rho_pies,beta_pdf,0.7,0.15;
stderr e_R,inv_gamma_pdf,1.2533,0.6551; stderr e_R,inv_gamma_pdf,1.2533,0.6551;
stderr e_q,inv_gamma_pdf,2.5066,1.3103; stderr e_q,inv_gamma_pdf,2.5066,1.3103;
stderr e_A,inv_gamma_pdf,1.2533,0.6551; stderr e_A,inv_gamma_pdf,1.2533,0.6551;
stderr e_ys,inv_gamma_pdf,1.2533,0.6551; stderr e_ys,inv_gamma_pdf,1.2533,0.6551;
stderr e_pies,inv_gamma_pdf,1.88,0.9827; stderr e_pies,inv_gamma_pdf,1.88,0.9827;
end; end;
estimation(datafile=data_ca1,first_obs=8,nobs=[76 79],mh_nblocks=10,prefilter=1,mh_jscale=0.5,mh_replic=0,forecast=8); estimation(datafile=data_ca1,first_obs=8,nobs=[76 79],mh_nblocks=10,prefilter=1,mh_jscale=0.5,mh_replic=0,forecast=8);

View File

@ -1,65 +1,65 @@
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs; var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
varexo e_R e_q e_ys e_pies e_A; varexo e_R e_q e_ys e_pies e_A;
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies; parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
psi1 = 1.54; psi1 = 1.54;
psi2 = 0.25; psi2 = 0.25;
psi3 = 0.25; psi3 = 0.25;
rho_R = 0.5; rho_R = 0.5;
alpha = 0.3; alpha = 0.3;
rr = 2.51; rr = 2.51;
k = 0.5; k = 0.5;
tau = 0.5; tau = 0.5;
rho_q = 0.4; rho_q = 0.4;
rho_A = 0.2; rho_A = 0.2;
rho_ys = 0.9; rho_ys = 0.9;
rho_pies = 0.7; rho_pies = 0.7;
model(linear); model(linear);
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
pie = de+(1-alpha)*dq+pie_s; pie = de+(1-alpha)*dq+pie_s;
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R; R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
dq = rho_q*dq(-1)+e_q; dq = rho_q*dq(-1)+e_q;
y_s = rho_ys*y_s(-1)+e_ys; y_s = rho_ys*y_s(-1)+e_ys;
pie_s = rho_pies*pie_s(-1)+e_pies; pie_s = rho_pies*pie_s(-1)+e_pies;
A = rho_A*A(-1)+e_A; A = rho_A*A(-1)+e_A;
y_obs = y-y(-1)+A; y_obs = y-y(-1)+A;
pie_obs = 4*pie; pie_obs = 4*pie;
R_obs = 4*R; R_obs = 4*R;
end; end;
shocks; shocks;
var e_R = 1.25^2; var e_R = 1.25^2;
var e_q = 2.5^2; var e_q = 2.5^2;
var e_A = 1.89; var e_A = 1.89;
var e_ys = 1.89; var e_ys = 1.89;
var e_pies = 1.89; var e_pies = 1.89;
end; end;
varobs y_obs R_obs pie_obs dq de; varobs y_obs R_obs pie_obs dq de;
estimated_params; estimated_params;
psi1 , gamma_pdf,1.5,0.5; psi1 , gamma_pdf,1.5,0.5;
psi2 , gamma_pdf,0.25,0.125; psi2 , gamma_pdf,0.25,0.125;
psi3 , gamma_pdf,0.25,0.125; psi3 , gamma_pdf,0.25,0.125;
rho_R ,beta_pdf,0.5,0.2; rho_R ,beta_pdf,0.5,0.2;
alpha ,beta_pdf,0.3,0.1; alpha ,beta_pdf,0.3,0.1;
rr ,gamma_pdf,2.5,1; rr ,gamma_pdf,2.5,1;
k , gamma_pdf,0.5,0.25; k , gamma_pdf,0.5,0.25;
tau ,gamma_pdf,0.5,0.2; tau ,gamma_pdf,0.5,0.2;
rho_q ,beta_pdf,0.4,0.2; rho_q ,beta_pdf,0.4,0.2;
rho_A ,beta_pdf,0.5,0.2; rho_A ,beta_pdf,0.5,0.2;
rho_ys ,beta_pdf,0.8,0.1; rho_ys ,beta_pdf,0.8,0.1;
rho_pies,beta_pdf,0.7,0.15; rho_pies,beta_pdf,0.7,0.15;
stderr e_R,inv_gamma_pdf,1.2533,0.6551; stderr e_R,inv_gamma_pdf,1.2533,0.6551;
stderr e_q,inv_gamma_pdf,2.5066,1.3103; stderr e_q,inv_gamma_pdf,2.5066,1.3103;
stderr e_A,inv_gamma_pdf,1.2533,0.6551; stderr e_A,inv_gamma_pdf,1.2533,0.6551;
stderr e_ys,inv_gamma_pdf,1.2533,0.6551; stderr e_ys,inv_gamma_pdf,1.2533,0.6551;
stderr e_pies,inv_gamma_pdf,1.88,0.9827; stderr e_pies,inv_gamma_pdf,1.88,0.9827;
end; end;
estimation(datafile=data_ca1,first_obs=8,nobs=[76 79],mh_nblocks=1,prefilter=1,mh_jscale=0.5,mh_replic=2000,forecast=8) y_obs R_obs pie_obs dq de;; estimation(datafile=data_ca1,first_obs=8,nobs=[76 79],mh_nblocks=1,prefilter=1,mh_jscale=0.5,mh_replic=2000,forecast=8) y_obs R_obs pie_obs dq de;;

View File

@ -1,36 +1,36 @@
var c k; var c k;
varexo x; varexo x;
parameters alph gam delt bet aa; parameters alph gam delt bet aa;
alph=0.5; alph=0.5;
gam=0.5; gam=0.5;
delt=0.02; delt=0.02;
bet=0.05; bet=0.05;
aa=0.5; aa=0.5;
model; model;
c + k - aa*x*k(-1)^alph - (1-delt)*k(-1); c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
end; end;
initval; initval;
x = 1; x = 1;
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1)); k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
c = aa*k^alph-delt*k +1 ; c = aa*k^alph-delt*k +1 ;
end; end;
steady; steady;
check; check;
shocks; shocks;
var x; var x;
periods 1; periods 1;
values 1.2; values 1.2;
end; end;
simul(periods=200); simul(periods=200);
rplot c; rplot c;
rplot k; rplot k;

View File

@ -1,37 +1,37 @@
var c k a; var c k a;
varexo e; varexo e;
parameters alpha beta delta gamma rho; parameters alpha beta delta gamma rho;
beta = 0.95; beta = 0.95;
delta = 1; delta = 1;
alpha = 0.3; alpha = 0.3;
rho = 0; rho = 0;
gamma = 2; gamma = 2;
model; model;
exp(c) + exp(k) = (1-delta) * exp(k(-1)) + exp(a) * exp(k(-1))^alpha; exp(c) + exp(k) = (1-delta) * exp(k(-1)) + exp(a) * exp(k(-1))^alpha;
exp(c)^(-gamma) = beta * exp(c(+1))^(-gamma) * (exp(a(+1)) * alpha * exp(k)^(alpha-1) + 1 - delta); exp(c)^(-gamma) = beta * exp(c(+1))^(-gamma) * (exp(a(+1)) * alpha * exp(k)^(alpha-1) + 1 - delta);
a = rho * a(-1) + e; a = rho * a(-1) + e;
end; end;
initval; initval;
k=0; k=0;
c=0; c=0;
a=0; a=0;
e=0; e=0;
end; end;
Sigma_e_ = 1; Sigma_e_ = 1;
stoch_simul(nomoments,nocorr,ar=0,irf=0); stoch_simul(nomoments,nocorr,ar=0,irf=0);
global dr_ global dr_
load objectives/sgu_ex1; load objectives/sgu_ex1;
test(oo_.dr.ghx,dr_obj_.ghx,1); test(oo_.dr.ghx,dr_obj_.ghx,1);
test(oo_.dr.ghu,dr_obj_.ghu,2); test(oo_.dr.ghu,dr_obj_.ghu,2);
test(oo_.dr.ghxx,dr_obj_.ghxx,3); test(oo_.dr.ghxx,dr_obj_.ghxx,3);
test(oo_.dr.ghxu,dr_obj_.ghxu,4); test(oo_.dr.ghxu,dr_obj_.ghxu,4);
test(oo_.dr.ghuu,dr_obj_.ghuu,5); test(oo_.dr.ghuu,dr_obj_.ghuu,5);
disp('TESTS OK'); disp('TESTS OK');