test suite: remove practicing directory. closes #1500
parent
a9ce9cc118
commit
85d00ad267
|
@ -1,47 +0,0 @@
|
|||
periods 500;
|
||||
var dc, dd, v_c, v_d, x;
|
||||
varexo e_c, e_x, e_d;
|
||||
|
||||
parameters DELTA THETA PSI MU_C MU_D RHO_X LAMBDA_DX;
|
||||
|
||||
DELTA=.99;
|
||||
PSI=1.5;
|
||||
THETA=(1-7.5)/(1-1/PSI);
|
||||
MU_C=0.0015;
|
||||
MU_D=0.0015;
|
||||
RHO_X=.979;
|
||||
LAMBDA_DX=3;
|
||||
|
||||
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_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;
|
||||
dd = MU_D + LAMBDA_DX*x(-1) + e_d;
|
||||
x = RHO_X * x(-1) + e_x;
|
||||
end;
|
||||
|
||||
initval;
|
||||
v_c=15;
|
||||
v_d=15;
|
||||
dc=MU_C;
|
||||
dd=MU_D;
|
||||
x=0;
|
||||
e_c=0;
|
||||
e_x=0;
|
||||
e_d=0;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_c;
|
||||
stderr .0078;
|
||||
var e_x;
|
||||
stderr .0078*.044;
|
||||
var e_d;
|
||||
stderr .0078*4.5;
|
||||
end;
|
||||
|
||||
steady(solve_algo=0);
|
||||
check;
|
||||
|
||||
stoch_simul(dr_algo=1, order=1, periods=1000, irf=30);
|
||||
datasaver('simudata',[]);
|
|
@ -1,58 +0,0 @@
|
|||
var dc, dd, v_c, v_d, x;
|
||||
varexo e_c, e_x, e_d;
|
||||
|
||||
parameters DELTA THETA PSI MU_C MU_D RHO_X LAMBDA_DX;
|
||||
|
||||
DELTA=.99;
|
||||
PSI=1.5;
|
||||
THETA=(1-7.5)/(1-1/PSI);
|
||||
MU_C=0.0015;
|
||||
MU_D=0.0015;
|
||||
RHO_X=.979;
|
||||
LAMBDA_DX=3;
|
||||
|
||||
|
||||
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_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;
|
||||
dd = MU_D + LAMBDA_DX*x(-1) + e_d;
|
||||
x = RHO_X * x(-1) + e_x;
|
||||
end;
|
||||
|
||||
initval;
|
||||
v_c=15;
|
||||
v_d=15;
|
||||
dc=MU_C;
|
||||
dd=MU_D;
|
||||
x=0;
|
||||
e_c=0;
|
||||
e_x=0;
|
||||
e_d=0;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_d; stderr .001;
|
||||
var e_c; stderr .001;
|
||||
var e_x; stderr .001;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
estimated_params;
|
||||
DELTA, beta_pdf, 0.98,.005;
|
||||
THETA,normal_pdf,-19.5, 0.0025;
|
||||
PSI,normal_pdf,1.6, 0.1;
|
||||
MU_C,normal_pdf,0.001, 0.001;
|
||||
MU_D,normal_pdf,0.001, 0.001;
|
||||
RHO_X,normal_pdf,.98, 0.005;
|
||||
LAMBDA_DX,normal_pdf,3, 0.05;
|
||||
stderr e_d,inv_gamma_pdf,.0025, 30;
|
||||
stderr e_x,inv_gamma_pdf,.0003, 30;
|
||||
stderr e_c,inv_gamma_pdf,.01, 30;
|
||||
end;
|
||||
|
||||
|
||||
varobs v_d dd dc;
|
||||
|
||||
estimation(datafile=simudata,mh_replic=1000,mh_jscale=.4,nodiagnostic);
|
|
@ -1,42 +0,0 @@
|
|||
var x y;
|
||||
varexo e_x e_u;
|
||||
|
||||
parameters rho sig_x sig_u mu_y;
|
||||
|
||||
rho = .98;
|
||||
mu_y=.015;
|
||||
sig_x=0.00025;
|
||||
sig_u=.0078;
|
||||
|
||||
model(linear);
|
||||
x=rho*x(-1) + sig_x*e_x;
|
||||
y=mu_y + x(-1) + sig_u*e_u;
|
||||
end;
|
||||
|
||||
initval;
|
||||
x=0;
|
||||
y=mu_y;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
var e_x;
|
||||
stderr 1;
|
||||
var e_u;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
estimated_params;
|
||||
|
||||
rho, beta_pdf, .98, .01;
|
||||
mu_y, uniform_pdf, .005, .0025;
|
||||
sig_u, inv_gamma_pdf, .003, inf;
|
||||
sig_x, inv_gamma_pdf, .003, inf;
|
||||
// The syntax for to input the priors is the following:
|
||||
// variable name, prior distribution, parameters of distribution.
|
||||
|
||||
end;
|
||||
|
||||
varobs y;
|
||||
estimation(datafile=data_consRicardoypg,first_obs=1,nobs=227,mh_replic=5000,mh_nblocks=1,mh_jscale=1);
|
|
@ -1,44 +0,0 @@
|
|||
|
||||
var x y;
|
||||
varexo e_x e_u;
|
||||
|
||||
parameters rho sig_x sig_u mu_y;
|
||||
|
||||
rho = .98;
|
||||
mu_y=.015;
|
||||
sig_x=0.00025;
|
||||
sig_u=.0078;
|
||||
|
||||
model(linear);
|
||||
x=rho*x(-1) + sig_x*e_x;
|
||||
y=mu_y + x(-1) + sig_u*e_u;
|
||||
end;
|
||||
|
||||
initval;
|
||||
x=0;
|
||||
y=mu_y;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
var e_x;
|
||||
stderr 1;
|
||||
var e_u;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
estimated_params;
|
||||
// ML estimation setup
|
||||
// parameter name, initial value, boundaries_low, ..._up;
|
||||
rho, 0, -0.99, 0.999; // use this for unconstrained max likelihood
|
||||
// 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, .0005, .00000000001, .01; // use this for unconstrained max likelihood
|
||||
sig_u, .007,.001, .1;
|
||||
mu_y, .014, .0001, .04;
|
||||
|
||||
end;
|
||||
|
||||
varobs y;
|
||||
estimation(datafile=data_consRicardoypg,first_obs=1,nobs=227,mh_replic=0,mode_compute=4,mode_check);
|
|
@ -1,79 +0,0 @@
|
|||
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
|
||||
|
||||
var c k;
|
||||
varexo taui tauc tauk g;
|
||||
parameters bet gam del alpha A;
|
||||
bet=.95;
|
||||
gam=2;
|
||||
del=.2;
|
||||
alpha=.33;
|
||||
A=1;
|
||||
|
||||
model;
|
||||
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))+
|
||||
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
|
||||
end;
|
||||
|
||||
initval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g = 0.2;
|
||||
tauc = 0;
|
||||
taui = 0;
|
||||
tauk = 0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
endval;
|
||||
k=1.5;
|
||||
c=0.4;
|
||||
g =.4;
|
||||
tauc =0;
|
||||
taui =0;
|
||||
tauk =0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
var g;
|
||||
periods 1:9;
|
||||
values 0.2;
|
||||
end;
|
||||
|
||||
simul(periods=100);
|
||||
|
||||
co=ys0_(var_index('c'));
|
||||
ko = ys0_(var_index('k'));
|
||||
go = ex_(1,1);
|
||||
|
||||
rbig0=1/bet;
|
||||
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
|
||||
rq0=alpha*A*ko^(alpha-1);
|
||||
rq=alpha*A*y_(var_index('k'),1:100).^(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);
|
||||
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);
|
||||
|
||||
figure
|
||||
subplot(2,3,1)
|
||||
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
|
||||
title('k')
|
||||
subplot(2,3,2)
|
||||
plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
|
||||
title('c')
|
||||
subplot(2,3,3)
|
||||
plot([rbig0*ones(100,1) rbig' ])
|
||||
title('R')
|
||||
subplot(2,3,4)
|
||||
plot([wq0*ones(100,1) wq' ])
|
||||
title('w/q')
|
||||
subplot(2,3,5)
|
||||
plot([sq0*ones(100,1) sq' ])
|
||||
title('s/q')
|
||||
subplot(2,3,6)
|
||||
plot([rq0*ones(100,1) rq' ])
|
||||
title('r/q')
|
||||
|
||||
print -depsc fig1131.ps
|
|
@ -1,130 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Note: y_ records the simulated endogenous variables in alphabetical order
|
||||
// ys0_ records the initial steady state
|
||||
// ys_ records the terminal steady state
|
||||
// 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;
|
||||
// The sample of size 100 is in between.
|
||||
|
||||
// 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.
|
||||
|
||||
//Declares the endogenous variables;
|
||||
var c k;
|
||||
//declares the exogenous variables // investment tax credit, consumption tax, capital tax, government spending
|
||||
varexo taui tauc tauk g;
|
||||
|
||||
parameters bet gam del alpha A;
|
||||
|
||||
bet=.95; // discount factor
|
||||
gam=2; // CRRA parameter
|
||||
del=.2; // depreciation rate
|
||||
alpha=.33; // capital's share
|
||||
A=1; // productivity
|
||||
|
||||
// Alignment convention:
|
||||
// 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
|
||||
// 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.
|
||||
|
||||
// These decisions and the timing conventions mean that
|
||||
// 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
|
||||
// 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.
|
||||
// the jump occurs now in ex_(11,1)
|
||||
|
||||
model;
|
||||
// equation 11.3.8.a
|
||||
k=A*k(-1)^alpha+(1-del)*k(-1)-c-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))+
|
||||
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
|
||||
end;
|
||||
|
||||
initval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g = 0.2;
|
||||
tauc = 0;
|
||||
taui = 0;
|
||||
tauk = 0;
|
||||
end;
|
||||
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.
|
||||
k=1.5;
|
||||
c=0.4;
|
||||
g =.4;
|
||||
tauc =0;
|
||||
taui =0;
|
||||
tauk =0;
|
||||
end;
|
||||
|
||||
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
|
||||
shocks;
|
||||
// we use shocks to undo that for the first 9 periods and leave g at
|
||||
// it's initial value of 0
|
||||
|
||||
var g;
|
||||
periods 1:9;
|
||||
values 0.2;
|
||||
end;
|
||||
|
||||
|
||||
// now solve the model
|
||||
simul(periods=100);
|
||||
|
||||
// Note: y_ records the simulated endogenous variables in alphabetical order
|
||||
// ys0_ records the initial steady state
|
||||
// ys_ records the terminal steady state
|
||||
// check that these line up at the end points
|
||||
y_(:,1) -ys0_(:)
|
||||
y_(:,102) - ys_(:)
|
||||
|
||||
// Compute the initial steady state for consumption to later do the plots.
|
||||
co=ys0_(var_index('c'));
|
||||
ko = ys0_(var_index('k'));
|
||||
// g is in ex_(:,1) since it is stored in alphabetical order
|
||||
go = ex_(1,1)
|
||||
|
||||
// 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
|
||||
// model above.
|
||||
|
||||
// These equations were taken from page 333 of RMT2
|
||||
rbig0=1/bet;
|
||||
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
|
||||
rq0=alpha*A*ko^(alpha-1);
|
||||
rq=alpha*A*y_(var_index('k'),1:100).^(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);
|
||||
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);
|
||||
|
||||
//Now we plot the responses of the endogenous variables to the shock.
|
||||
|
||||
figure
|
||||
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
|
||||
title('k')
|
||||
subplot(2,3,2)
|
||||
plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
|
||||
title('c')
|
||||
subplot(2,3,3)
|
||||
plot([rbig0*ones(100,1) rbig' ])
|
||||
title('R')
|
||||
subplot(2,3,4)
|
||||
plot([wq0*ones(100,1) wq' ])
|
||||
title('w/q')
|
||||
subplot(2,3,5)
|
||||
plot([sq0*ones(100,1) sq' ])
|
||||
title('s/q')
|
||||
subplot(2,3,6)
|
||||
plot([rq0*ones(100,1) rq' ])
|
||||
title('r/q')
|
|
@ -1,79 +0,0 @@
|
|||
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
|
||||
|
||||
var c k;
|
||||
varexo taui tauc tauk g;
|
||||
parameters bet gam del alpha A;
|
||||
bet=.95;
|
||||
gam=2;
|
||||
del=.2;
|
||||
alpha=.33;
|
||||
A=1;
|
||||
|
||||
model;
|
||||
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))+
|
||||
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
|
||||
end;
|
||||
|
||||
initval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g = 0.2;
|
||||
tauc = 0;
|
||||
taui = 0;
|
||||
tauk = 0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
endval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g = 0.2;
|
||||
tauc =0.2;
|
||||
taui =0;
|
||||
tauk =0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
var tauc;
|
||||
periods 1:9;
|
||||
values 0;
|
||||
end;
|
||||
|
||||
simul(periods=100);
|
||||
|
||||
co=ys0_(var_index('c'));
|
||||
ko = ys0_(var_index('k'));
|
||||
go = ex_(1,1);
|
||||
|
||||
rbig0=1/bet;
|
||||
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
|
||||
rq0=alpha*A*ko^(alpha-1);
|
||||
rq=alpha*A*y_(var_index('k'),1:100).^(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);
|
||||
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);
|
||||
|
||||
figure
|
||||
subplot(2,3,1)
|
||||
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
|
||||
title('k')
|
||||
subplot(2,3,2)
|
||||
plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
|
||||
title('c')
|
||||
subplot(2,3,3)
|
||||
plot([rbig0*ones(100,1) rbig' ])
|
||||
title('R')
|
||||
subplot(2,3,4)
|
||||
plot([wq0*ones(100,1) wq' ])
|
||||
title('w/q')
|
||||
subplot(2,3,5)
|
||||
plot([sq0*ones(100,1) sq' ])
|
||||
title('s/q')
|
||||
subplot(2,3,6)
|
||||
plot([rq0*ones(100,1) rq' ])
|
||||
title('r/q')
|
||||
|
||||
print -depsc fig1132.ps
|
|
@ -1,80 +0,0 @@
|
|||
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
|
||||
|
||||
var c k;
|
||||
varexo taui tauc tauk g;
|
||||
parameters bet gam del alpha A;
|
||||
bet=.95;
|
||||
gam=2;
|
||||
del=.2;
|
||||
alpha=.33;
|
||||
A=1;
|
||||
|
||||
model;
|
||||
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))+
|
||||
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
|
||||
end;
|
||||
|
||||
initval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g = 0.2;
|
||||
tauc = 0;
|
||||
taui = 0;
|
||||
tauk = 0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
endval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g =0.2;
|
||||
tauc =0;
|
||||
taui =0.20;
|
||||
tauk =0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
var taui;
|
||||
periods 1:9;
|
||||
values 0;
|
||||
end;
|
||||
|
||||
simul(periods=100);
|
||||
|
||||
co=ys0_(var_index('c'));
|
||||
ko = ys0_(var_index('k'));
|
||||
go = ex_(1,1);
|
||||
|
||||
rbig0=1/bet;
|
||||
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
|
||||
rq0=alpha*A*ko^(alpha-1);
|
||||
rq=alpha*A*y_(var_index('k'),1:100).^(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);
|
||||
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);
|
||||
|
||||
figure
|
||||
subplot(2,3,1)
|
||||
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
|
||||
title('k')
|
||||
subplot(2,3,2)
|
||||
plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
|
||||
title('c')
|
||||
subplot(2,3,3)
|
||||
plot([rbig0*ones(100,1) rbig' ])
|
||||
title('R')
|
||||
subplot(2,3,4)
|
||||
plot([wq0*ones(100,1) wq' ])
|
||||
title('w/q')
|
||||
subplot(2,3,5)
|
||||
plot([sq0*ones(100,1) sq' ])
|
||||
title('s/q')
|
||||
subplot(2,3,6)
|
||||
plot([rq0*ones(100,1) rq' ])
|
||||
title('r/q')
|
||||
|
||||
print -depsc fig1151.ps
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
|
||||
|
||||
var c k;
|
||||
varexo taui tauc tauk g;
|
||||
parameters bet gam del alpha A;
|
||||
bet=.95;
|
||||
gam=2;
|
||||
del=.2;
|
||||
alpha=.33;
|
||||
A=1;
|
||||
|
||||
model;
|
||||
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))+
|
||||
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
|
||||
end;
|
||||
|
||||
initval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g = 0.2;
|
||||
tauc = 0;
|
||||
taui = 0;
|
||||
tauk = 0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
endval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g =0.2;
|
||||
tauc =0;
|
||||
taui =0;
|
||||
tauk = 0.2;
|
||||
end;
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
var tauk;
|
||||
periods 1:9;
|
||||
values 0;
|
||||
end;
|
||||
|
||||
simul(periods=100);
|
||||
|
||||
co=ys0_(var_index('c'));
|
||||
ko = ys0_(var_index('k'));
|
||||
go = ex_(1,1);
|
||||
|
||||
rbig0=1/bet;
|
||||
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
|
||||
rq0=alpha*A*ko^(alpha-1);
|
||||
rq=alpha*A*y_(var_index('k'),1:100).^(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);
|
||||
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);
|
||||
|
||||
figure
|
||||
subplot(2,3,1)
|
||||
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
|
||||
title('k')
|
||||
subplot(2,3,2)
|
||||
plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
|
||||
title('c')
|
||||
subplot(2,3,3)
|
||||
plot([rbig0*ones(100,1) rbig' ])
|
||||
title('R')
|
||||
subplot(2,3,4)
|
||||
plot([wq0*ones(100,1) wq' ])
|
||||
title('w/q')
|
||||
subplot(2,3,5)
|
||||
plot([sq0*ones(100,1) sq' ])
|
||||
title('s/q')
|
||||
subplot(2,3,6)
|
||||
plot([rq0*ones(100,1) rq' ])
|
||||
title('r/q')
|
||||
|
||||
print -depsc fig1152.ps
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
|
||||
|
||||
var c k;
|
||||
varexo taui tauc tauk g;
|
||||
parameters bet gam del alpha A;
|
||||
bet=.95;
|
||||
gam=2;
|
||||
del=.2;
|
||||
alpha=.33;
|
||||
A=1;
|
||||
|
||||
model;
|
||||
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))+
|
||||
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
|
||||
end;
|
||||
|
||||
initval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g = 0.2;
|
||||
tauc = 0;
|
||||
taui = 0;
|
||||
tauk = 0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
endval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g = 0.2;
|
||||
tauc =0;
|
||||
taui =0;
|
||||
tauk =0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
var g;
|
||||
periods 10;
|
||||
values 0.4;
|
||||
end;
|
||||
|
||||
simul(periods=100);
|
||||
|
||||
co=ys0_(var_index('c'));
|
||||
ko = ys0_(var_index('k'));
|
||||
go = ex_(1,1);
|
||||
|
||||
rbig0=1/bet;
|
||||
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
|
||||
rq0=alpha*A*ko^(alpha-1);
|
||||
rq=alpha*A*y_(var_index('k'),1:100).^(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);
|
||||
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);
|
||||
|
||||
figure
|
||||
subplot(2,3,1)
|
||||
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
|
||||
title('k')
|
||||
subplot(2,3,2)
|
||||
plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
|
||||
title('c')
|
||||
subplot(2,3,3)
|
||||
plot([rbig0*ones(100,1) rbig' ])
|
||||
title('R')
|
||||
subplot(2,3,4)
|
||||
plot([wq0*ones(100,1) wq' ])
|
||||
title('w/q')
|
||||
subplot(2,3,5)
|
||||
plot([sq0*ones(100,1) sq' ])
|
||||
title('s/q')
|
||||
subplot(2,3,6)
|
||||
plot([rq0*ones(100,1) rq' ])
|
||||
title('r/q')
|
||||
|
||||
print -depsc fig1171.ps
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
// This program replicates figure 11.3.1 from chapter 11 of RMT2 by Ljungqvist and Sargent
|
||||
|
||||
var c k;
|
||||
varexo taui tauc tauk g;
|
||||
parameters bet gam del alpha A;
|
||||
bet=.95;
|
||||
gam=2;
|
||||
del=.2;
|
||||
alpha=.33;
|
||||
A=1;
|
||||
|
||||
model;
|
||||
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))+
|
||||
((1-tauk)/(1-taui(-1)))*alpha*A*k(-1)^(alpha-1));
|
||||
end;
|
||||
|
||||
initval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g = 0.2;
|
||||
tauc = 0;
|
||||
taui = 0;
|
||||
tauk = 0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
endval;
|
||||
k=1.5;
|
||||
c=0.6;
|
||||
g =0.2;
|
||||
tauc =0;
|
||||
taui =0;
|
||||
tauk =0;
|
||||
end;
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
var taui;
|
||||
periods 10;
|
||||
values 0.2;
|
||||
end;
|
||||
|
||||
simul(periods=100);
|
||||
|
||||
co=ys0_(var_index('c'));
|
||||
ko = ys0_(var_index('k'));
|
||||
go = ex_(1,1);
|
||||
|
||||
rbig0=1/bet;
|
||||
rbig=y_(var_index('c'),2:101).^(-gam)./(bet*y_(var_index('c'),3:102).^(-gam));
|
||||
rq0=alpha*A*ko^(alpha-1);
|
||||
rq=alpha*A*y_(var_index('k'),1:100).^(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);
|
||||
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);
|
||||
|
||||
figure
|
||||
subplot(2,3,1)
|
||||
plot([ko*ones(100,1) y_(var_index('k'),1:100)' ])
|
||||
title('k')
|
||||
subplot(2,3,2)
|
||||
plot([co*ones(100,1) y_(var_index('c'),2:101)' ])
|
||||
title('c')
|
||||
subplot(2,3,3)
|
||||
plot([rbig0*ones(100,1) rbig' ])
|
||||
title('R')
|
||||
subplot(2,3,4)
|
||||
plot([wq0*ones(100,1) wq' ])
|
||||
title('w/q')
|
||||
subplot(2,3,5)
|
||||
plot([sq0*ones(100,1) sq' ])
|
||||
title('s/q')
|
||||
subplot(2,3,6)
|
||||
plot([rq0*ones(100,1) rq' ])
|
||||
title('r/q')
|
||||
|
||||
print -depsc fig1172.ps
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
|
||||
|
||||
periods 1000;
|
||||
|
||||
var c k lab z;
|
||||
varexo e;
|
||||
|
||||
parameters bet the del alp tau rho s;
|
||||
|
||||
bet = 0.987;
|
||||
the = 0.357;
|
||||
del = 0.012;
|
||||
alp = 0.4;
|
||||
tau = 2;
|
||||
rho = 0.95;
|
||||
s = 0.007;
|
||||
|
||||
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-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);
|
||||
z=rho*z(-1)+s*e;
|
||||
end;
|
||||
|
||||
initval;
|
||||
k = 1;
|
||||
c = 1;
|
||||
lab = 0.3;
|
||||
z = 0;
|
||||
e = 0;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
stoch_simul(dr_algo=0,periods=1000,irf=40);
|
||||
datasaver('simudata',[]);
|
|
@ -1,44 +0,0 @@
|
|||
|
||||
var c k lab z;
|
||||
varexo e;
|
||||
|
||||
parameters bet del alp rho the tau s;
|
||||
|
||||
bet = 0.987;
|
||||
the = 0.357;
|
||||
del = 0.012;
|
||||
alp = 0.4;
|
||||
tau = 2;
|
||||
rho = 0.95;
|
||||
s = 0.007;
|
||||
|
||||
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-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);
|
||||
z=rho*z(-1)+s*e;
|
||||
end;
|
||||
|
||||
initval;
|
||||
k = 1;
|
||||
c = 1;
|
||||
lab = 0.3;
|
||||
z = 0;
|
||||
e = 0;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
estimated_params;
|
||||
stderr e, inv_gamma_pdf, 0.95,30;
|
||||
rho, beta_pdf,0.93,0.02;
|
||||
the, normal_pdf,0.3,0.05;
|
||||
tau, normal_pdf,2.1,0.3;
|
||||
end;
|
||||
|
||||
varobs c;
|
||||
|
||||
estimation(datafile=simudata,mh_replic=1000,mh_jscale=0.9,nodiagnostic);
|
|
@ -1,62 +0,0 @@
|
|||
// Estimates the Hansen Sargent and Tallarini model by maximum likelihood.
|
||||
|
||||
var s c h k i d dhat dbar mus muc muh gamma R;
|
||||
varexo e_dhat e_dbar;
|
||||
|
||||
parameters lambda deltah deltak mud b bet phi1 phi2 cdbar alpha1 alpha2 cdhat;
|
||||
bet=0.9971;
|
||||
deltah=0.682;
|
||||
lambda=2.443;
|
||||
alpha1=0.813;
|
||||
alpha2=0.189;
|
||||
phi1=0.998;
|
||||
phi2=0.704;
|
||||
mud=13.710;
|
||||
cdhat=0.155;
|
||||
cdbar=0.108;
|
||||
b=32;
|
||||
deltak=0.975;
|
||||
|
||||
model(linear);
|
||||
R=deltak+gamma;
|
||||
R*bet=1;
|
||||
s=(1+lambda)*c-lambda*h(-1);
|
||||
h=deltah*h(-1)+(1-deltah)*c;
|
||||
k=deltak*k(-1)+i;
|
||||
c+i=gamma*k(-1)+d;
|
||||
mus=b-s;
|
||||
muc=(1+lambda)*mus+(1-deltah)*muh;
|
||||
muh=bet*(deltah*muh(+1)-lambda*mus(+1));
|
||||
muc=bet*R*muc(+1);
|
||||
d=mud+dbar+dhat;
|
||||
dbar=(phi1+phi2)*dbar(-1) - phi1*phi2*dbar(-2) + cdbar*e_dbar;
|
||||
dhat=(alpha1+alpha2)*dhat(-1) - alpha1*alpha2*dhat(-2) + cdhat*e_dhat;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_dhat;
|
||||
stderr 1;
|
||||
var e_dbar;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
stoch_simul(irf=0, periods=500);
|
||||
// save dataHST c i;
|
||||
|
||||
estimated_params;
|
||||
bet,uniform_pdf, .9499999999, 0.0288675134306;
|
||||
deltah,uniform_pdf, 0.45, 0.202072594216;
|
||||
lambda,uniform_pdf, 25.05, 14.4048892163;
|
||||
alpha1,uniform_pdf, 0.8, 0.115470053809;
|
||||
alpha2,uniform_pdf, 0.25, 0.144337567297;
|
||||
phi1,uniform_pdf, 0.8, 0.115470053809;
|
||||
phi2,uniform_pdf, 0.5, 0.288675134595;
|
||||
mud,uniform_pdf, 24.5, 14.1450815951;
|
||||
cdhat,uniform_pdf, 0.175, 0.0721687836487;
|
||||
cdbar,uniform_pdf, 0.175, 0.0721687836487;
|
||||
|
||||
end;
|
||||
|
||||
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,mode_check,mh_replic=5000,mh_nblocks=1,mh_jscale=0.3);
|
|
@ -1,62 +0,0 @@
|
|||
// Estimates the Hansen Sargent and Tallarini model by maximum likelihood.
|
||||
|
||||
var s c h k i d dhat dbar mus muc muh gamma R;
|
||||
varexo e_dhat e_dbar;
|
||||
|
||||
parameters lambda deltah deltak mud b bet phi1 phi2 cdbar alpha1 alpha2 cdhat;
|
||||
bet=0.9971;
|
||||
deltah=0.682;
|
||||
lambda=2.443;
|
||||
alpha1=0.813;
|
||||
alpha2=0.189;
|
||||
phi1=0.998;
|
||||
phi2=0.704;
|
||||
mud=13.710;
|
||||
cdhat=0.155;
|
||||
cdbar=0.108;
|
||||
b=32;
|
||||
deltak=0.975;
|
||||
|
||||
model(linear);
|
||||
R=deltak+gamma;
|
||||
R*bet=1;
|
||||
s=(1+lambda)*c-lambda*h(-1);
|
||||
h=deltah*h(-1)+(1-deltah)*c;
|
||||
k=deltak*k(-1)+i;
|
||||
c+i=gamma*k(-1)+d;
|
||||
mus=b-s;
|
||||
muc=(1+lambda)*mus+(1-deltah)*muh;
|
||||
muh=bet*(deltah*muh(+1)-lambda*mus(+1));
|
||||
muc=bet*R*muc(+1);
|
||||
d=mud+dbar+dhat;
|
||||
dbar=(phi1+phi2)*dbar(-1) - phi1*phi2*dbar(-2) + cdbar*e_dbar;
|
||||
dhat=(alpha1+alpha2)*dhat(-1) - alpha1*alpha2*dhat(-2) + cdhat*e_dhat;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_dhat;
|
||||
stderr 1;
|
||||
var e_dbar;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
// stoch_simul(irf=0, periods=500);
|
||||
// save dataHST c i;
|
||||
|
||||
estimated_params;
|
||||
bet, .91, .9, .99999;
|
||||
deltah, 0.4, 0.1, 0.8;
|
||||
lambda, 2, 0.1, 50;
|
||||
alpha1, 0.8, 0.6, 0.99999;
|
||||
alpha2, 0.2, 0.01, 0.5;
|
||||
phi1, 0.8, 0.6, 0.99999;
|
||||
phi2, 0.5, 0.3, 0.9;
|
||||
mud, 10, 1, 50;
|
||||
cdhat, 0.1, 0.05, 0.2;
|
||||
cdbar, 0.1, 0.05, 0.2;
|
||||
|
||||
end;
|
||||
|
||||
varobs c i;
|
||||
estimation(datafile=dataHST,first_obs=1,nobs=500,mode_compute=4,mode_check);
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
periods 200;
|
||||
var c1 c2 k1 k2 a1 a2 y1 y2;
|
||||
varexo e1 e2;
|
||||
|
||||
parameters gamma delta alpha beta rho;
|
||||
|
||||
gamma=2;
|
||||
delta=.05;
|
||||
alpha=.4;
|
||||
beta=.98;
|
||||
rho=.85;
|
||||
|
||||
model;
|
||||
c1=c2;
|
||||
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(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;
|
||||
a2=rho*a2(-1)+e2;
|
||||
exp(y1)=exp(a1)*exp(k1(-1))^alpha;
|
||||
exp(y2)=exp(a2)*exp(k2(-1))^alpha;
|
||||
end;
|
||||
|
||||
initval;
|
||||
y1=1.1;
|
||||
y2=1.1;
|
||||
k1=2.8;
|
||||
k2=2.8;
|
||||
c1=.8;
|
||||
c2=.8;
|
||||
a1=0;
|
||||
a2=0;
|
||||
e1=0;
|
||||
e2=0;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e1; stderr .08;
|
||||
var e2; stderr .08;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
stoch_simul(dr_algo=0,periods=200);
|
||||
datatomfile('simu2',[]);
|
|
@ -1,51 +0,0 @@
|
|||
periods 200;
|
||||
var c1 c2 k1 k2 a1 a2 y1 y2;
|
||||
varexo e1 e2;
|
||||
|
||||
parameters gamma delta alpha beta rho;
|
||||
|
||||
gamma=2;
|
||||
delta=.05;
|
||||
alpha=.4;
|
||||
beta=.98;
|
||||
rho=.85;
|
||||
|
||||
model;
|
||||
c1=c2;
|
||||
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(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;
|
||||
a2=rho*a2(-1)+e2;
|
||||
exp(y1)=exp(a1)*exp(k1(-1))^alpha;
|
||||
exp(y2)=exp(a2)*exp(k2(-1))^alpha;
|
||||
end;
|
||||
|
||||
initval;
|
||||
y1=1.1;
|
||||
y2=1.1;
|
||||
k1=2.8;
|
||||
k2=2.8;
|
||||
c1=.8;
|
||||
c2=.8;
|
||||
a1=0;
|
||||
a2=0;
|
||||
e1=0;
|
||||
e2=0;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e1; stderr .08;
|
||||
var e2; stderr .08;
|
||||
end;
|
||||
|
||||
steady;
|
||||
estimated_params;
|
||||
alpha, normal_pdf, .35, .05;
|
||||
rho, normal_pdf, .8, .05;
|
||||
stderr e1, inv_gamma_pdf, .09, 10;
|
||||
stderr e2, inv_gamma_pdf, .09, 10;
|
||||
end;
|
||||
|
||||
varobs y1 y2;
|
||||
estimation(datafile=simu2,mh_replic=1200,mh_jscale=.7,nodiagnostic);
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,58 +0,0 @@
|
|||
function datasaver (s,var_list)
|
||||
% datasaver saves variables simulated by Dynare
|
||||
% INPUT
|
||||
% s: a string containing the name of the destination *.m file
|
||||
% var_list: a character matrix containting the name of the variables
|
||||
% to be saved (optional, default: all endogenous variables)
|
||||
% OUTPUT
|
||||
% none
|
||||
% This is part of the examples included in F. Barillas, R. Colacito,
|
||||
% S. Kitao, C. Matthes, T. Sargent and Y. Shin (2007) "Practicing
|
||||
% Dynare".
|
||||
|
||||
% Modified by M. Juillard to make it also compatible with Dynare
|
||||
% version 4 (12/4/07)
|
||||
|
||||
|
||||
global lgy_ lgx_ y_ endo_nbr M_ oo_
|
||||
|
||||
% test and adapt for Dynare version 4
|
||||
if isempty(lgy_)
|
||||
lgy_ = M_.endo_names;
|
||||
lgx_ + M_.exo_names;
|
||||
y_ = oo_.endo_simul;
|
||||
endo_nbr = M_.endo_nbr;
|
||||
end
|
||||
|
||||
sm=[s,'.m'];
|
||||
fid=fopen(sm,'w') ;
|
||||
|
||||
n = size(var_list,1);
|
||||
if n == 0
|
||||
n = endo_nbr;
|
||||
ivar = [1:n]';
|
||||
var_list = lgy_;
|
||||
else
|
||||
ivar=zeros(n,1);
|
||||
for i=1:n
|
||||
i_tmp = strmatch(var_list(i,:),lgy_,'exact');
|
||||
if isempty(i_tmp)
|
||||
error (['One of the specified variables does not exist']) ;
|
||||
else
|
||||
ivar(i) = i_tmp;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
for i = 1:n
|
||||
fprintf(fid,[lgy_(ivar(i),:), '=['],'\n') ;
|
||||
fprintf(fid,'\n') ;
|
||||
fprintf(fid,'%15.8g\n',y_(ivar(i),:)') ;
|
||||
fprintf(fid,'\n') ;
|
||||
fprintf(fid,'];\n') ;
|
||||
fprintf(fid,'\n') ;
|
||||
end
|
||||
fclose(fid) ;
|
||||
|
||||
return ;
|
|
@ -1,46 +0,0 @@
|
|||
periods 5000;
|
||||
|
||||
var c k mu_c b d in;
|
||||
varexo e_d e_b;
|
||||
|
||||
parameters R rho rho_b mu_b mu_d;
|
||||
R=1.05;
|
||||
//rho=0.9;
|
||||
rho = 0;
|
||||
mu_b=30;
|
||||
mu_d=5;
|
||||
rho_b = 0;
|
||||
|
||||
model(linear);
|
||||
|
||||
c+k = R*k(-1) + d;
|
||||
mu_c = b - c;
|
||||
mu_c=mu_c(+1);
|
||||
d= rho*d(-1)+ mu_d*(1-rho) + e_d;
|
||||
b=(1-rho_b)*mu_b+rho_b*b(-1)+e_b;
|
||||
in = k - k(-1);
|
||||
end;
|
||||
|
||||
//With a unit root, there exists no steady state. Use the following trick.
|
||||
//Supply ONE solution corresponding to the initial k that you named.
|
||||
|
||||
initval;
|
||||
d=mu_d;
|
||||
k=100;
|
||||
c = (R-1)*k +d;
|
||||
mu_c=mu_b-c;
|
||||
b=mu_b;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_d;
|
||||
stderr 1;
|
||||
var e_b;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
steady;
|
||||
check;
|
||||
|
||||
stoch_simul(dr_algo=1, order=1, periods=500, irf=10);
|
||||
save data_hall.mat c in;
|
|
@ -1,54 +0,0 @@
|
|||
// Estimates the hall model using Bayesian method.
|
||||
// hall1_estimate.mod estimates by maximum likelihood
|
||||
|
||||
periods 5000;
|
||||
|
||||
var c k mu_c b d in;
|
||||
varexo e_d e_b;
|
||||
|
||||
parameters R rho rho_b mu_b mu_d;
|
||||
R=1.05;
|
||||
rho=0.9;
|
||||
mu_b=30;
|
||||
mu_d=5;
|
||||
rho_b = 0.5;
|
||||
|
||||
model(linear);
|
||||
|
||||
c+k = R*k(-1) + d;
|
||||
mu_c = b - c;
|
||||
mu_c=mu_c(+1);
|
||||
d= rho*d(-1)+ mu_d*(1-rho) + e_d;
|
||||
b=(1-rho_b)*mu_b+rho_b*b(-1)+e_b;
|
||||
in = k - k(-1);
|
||||
end;
|
||||
// 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.
|
||||
// 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.)
|
||||
|
||||
initval;
|
||||
d=mu_d;
|
||||
k=100;
|
||||
c = (R-1)*k +d;
|
||||
mu_c=mu_b-c;
|
||||
b=mu_b;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_d;
|
||||
stderr 0.05;
|
||||
var e_b;
|
||||
stderr 0.05;
|
||||
end;
|
||||
|
||||
estimated_params;
|
||||
rho, beta_pdf, .1, 0.2;
|
||||
R, normal_pdf, 1.02, 0.05;
|
||||
end;
|
||||
|
||||
varobs c in;
|
||||
// declare the unit root variables for diffuse filter
|
||||
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);
|
|
@ -1,56 +0,0 @@
|
|||
// Estimates the hall model using maximum likelihood. See hall1_estimateBayes.mod for Bayesian method
|
||||
|
||||
periods 5000;
|
||||
|
||||
var c k mu_c b d in;
|
||||
varexo e_d e_b;
|
||||
|
||||
parameters R rho rho_b mu_b mu_d;
|
||||
R=1.05;
|
||||
rho=0.9;
|
||||
mu_b=30;
|
||||
mu_d=5;
|
||||
rho_b = 0.5;
|
||||
|
||||
model(linear);
|
||||
|
||||
c+k = R*k(-1) + d;
|
||||
mu_c = b - c;
|
||||
mu_c=mu_c(+1);
|
||||
d= rho*d(-1)+ mu_d*(1-rho) + e_d;
|
||||
b=(1-rho_b)*mu_b+rho_b*b(-1)+e_b;
|
||||
in = k - k(-1);
|
||||
end;
|
||||
// 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.
|
||||
// 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.)
|
||||
|
||||
initval;
|
||||
d=mu_d;
|
||||
k=100;
|
||||
c = (R-1)*k +d;
|
||||
mu_c=mu_b-c;
|
||||
b=mu_b;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_d;
|
||||
stderr 0.05;
|
||||
var e_b;
|
||||
stderr 0.05;
|
||||
end;
|
||||
|
||||
estimated_params;
|
||||
// ML estimation setup
|
||||
// parameter name, initial value, boundaries_low, ..._up;
|
||||
// now we use the optimum results from csminwel for starting up Marco's
|
||||
rho, -0.0159, -0.9, 0.9;
|
||||
R, 1.0074, 0, 1.5;
|
||||
end;
|
||||
|
||||
varobs c in;
|
||||
// declare the unit root variables for diffuse filter
|
||||
unit_root_vars k;
|
||||
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
|
|
@ -1,55 +0,0 @@
|
|||
// Rosen schooling model
|
||||
//
|
||||
// The model is the one Sherwin Rosen showed Sargent in Sargent's Chicago office.
|
||||
// The equations are
|
||||
//
|
||||
// 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 = 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
|
||||
|
||||
|
||||
periods 500;
|
||||
var s N P W;
|
||||
varexo e_s e_d;
|
||||
|
||||
|
||||
parameters a0 a1 delta d0 d1 bet k;
|
||||
a0=10;
|
||||
a1=1;
|
||||
d0=1000;
|
||||
d1=1;
|
||||
bet=.99;
|
||||
delta=.02;
|
||||
|
||||
model(linear);
|
||||
s=a0+a1*P+e_s; // flow supply of new entrants
|
||||
N=(1-delta)*N(-1) + s(-4); // evolution of the stock
|
||||
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
|
||||
end;
|
||||
|
||||
initval;
|
||||
s=0;
|
||||
N=0;
|
||||
P=0;
|
||||
W=0;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_d;
|
||||
stderr 1;
|
||||
var e_s;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
steady;
|
||||
check;
|
||||
|
||||
stoch_simul(dr_algo=1, order=1, periods=500, irf=10);
|
||||
//datasaver('simudata',[]);
|
||||
save data_rosen.mat s N P W;
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
// Estimates the Rosen schooling model by maximum likelihood
|
||||
|
||||
// Rosen schooling model
|
||||
//
|
||||
// The model is the one Sherwin Rosen showed Sargent in Sargent's Chicago office.
|
||||
// The equations are
|
||||
//
|
||||
// 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 = 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
|
||||
|
||||
|
||||
periods 500;
|
||||
var s N P W;
|
||||
varexo e_s e_d;
|
||||
|
||||
|
||||
|
||||
parameters a0 a1 delta d0 d1 bet ;
|
||||
a0=10;
|
||||
a1=1;
|
||||
d0=1000;
|
||||
d1=1;
|
||||
bet=.99;
|
||||
delta=.02;
|
||||
|
||||
model(linear);
|
||||
|
||||
s=a0+a1*P+e_s; // flow supply of new entrants
|
||||
N=(1-delta)*N(-1) + s(-4); // evolution of the stock
|
||||
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
|
||||
end;
|
||||
|
||||
initval;
|
||||
s=0;
|
||||
N=0;
|
||||
P=0;
|
||||
W=0;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_d;
|
||||
stderr 1;
|
||||
var e_s;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
estimated_params;
|
||||
a1, gamma_pdf, .5, .5;
|
||||
d1, gamma_pdf, 2, .5;
|
||||
end;
|
||||
|
||||
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);
|
||||
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
// Estimates the Rosen schooling model by maximum likelihood
|
||||
|
||||
// Rosen schooling model
|
||||
//
|
||||
// The model is the one Sherwin Rosen showed Sargent in Sargent's Chicago office.
|
||||
// The equations are
|
||||
//
|
||||
// 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 = 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
|
||||
|
||||
|
||||
periods 500;
|
||||
var s N P W;
|
||||
varexo e_s e_d;
|
||||
|
||||
|
||||
|
||||
parameters a0 a1 delta d0 d1 bet ;
|
||||
a0=10;
|
||||
a1=1;
|
||||
d0=1000;
|
||||
d1=1;
|
||||
bet=.99;
|
||||
delta=.02;
|
||||
|
||||
model(linear);
|
||||
|
||||
s=a0+a1*P+e_s; // flow supply of new entrants
|
||||
N=(1-delta)*N(-1) + s(-4); // evolution of the stock
|
||||
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
|
||||
end;
|
||||
|
||||
initval;
|
||||
s=0;
|
||||
N=0;
|
||||
P=0;
|
||||
W=0;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_d;
|
||||
stderr 1;
|
||||
var e_s;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
estimated_params;
|
||||
a1, .5, -10, 10;
|
||||
d1, .5, -20, 40; // these are the ranges for the parameters
|
||||
end;
|
||||
|
||||
varobs W N;
|
||||
estimation(datafile=data_rosen,first_obs=101,nobs=200,mh_replic=0,mode_compute=4,mode_check);
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
// this program solves and simulates the model in
|
||||
// "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
|
||||
// variables are defined as follows:
|
||||
// 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
|
||||
// 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;
|
||||
varexo epsilon eta;
|
||||
parameters alpha lambda sig_eta sig_epsilon;
|
||||
lambda=.5921;
|
||||
alpha=-2.344;
|
||||
sig_eta= .001;
|
||||
sig_epsilon= .001;
|
||||
|
||||
|
||||
// the model equations are taken from equation (27) on page 69 of the paper
|
||||
|
||||
model;
|
||||
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;
|
||||
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;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
|
||||
var eta;
|
||||
stderr 1;
|
||||
var epsilon;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
stoch_simul(dr_algo=1,drop=0, order=1, periods=33, irf=0);
|
||||
|
||||
save data_hyperinfl.mat x mu;
|
|
@ -1,48 +0,0 @@
|
|||
// this program estimates the model in
|
||||
// "The Demand for Money during Hyperinflations under Rational Expectations: I" by T. Sargent, IER 1977 using Bayesian techniques
|
||||
// variables are defined as follows:
|
||||
// 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
|
||||
// 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;
|
||||
varexo epsilon eta;
|
||||
parameters alpha lambda sig_eta sig_epsilon;
|
||||
lambda=.5921;
|
||||
alpha=-2.344;
|
||||
sig_eta=.001;
|
||||
sig_epsilon=.001;
|
||||
|
||||
model;
|
||||
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;
|
||||
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;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
|
||||
var eta;
|
||||
stderr 1;
|
||||
var epsilon;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
estimated_params;
|
||||
// Bayesian setup
|
||||
lambda, uniform_pdf, 0.68, .5;
|
||||
alpha, uniform_pdf, -5, 2;
|
||||
sig_eta, uniform_pdf, .5, 0.25;
|
||||
sig_epsilon, uniform_pdf, .5, 0.25;
|
||||
end;
|
||||
|
||||
|
||||
varobs mu 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);
|
|
@ -1,52 +0,0 @@
|
|||
// this program estimates the model in
|
||||
// "The Demand for Money during Hyperinflations under Rational Expectations: I" by T. Sargent, IER 1977 using maximum likelihood
|
||||
// variables are defined as follows:
|
||||
// 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
|
||||
// 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;
|
||||
varexo epsilon eta;
|
||||
parameters alpha lambda sig_eta sig_epsilon;
|
||||
lambda=.5921;
|
||||
alpha=-2.344;
|
||||
sig_eta=.001;
|
||||
sig_epsilon=.001;
|
||||
|
||||
model;
|
||||
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;
|
||||
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;
|
||||
end;
|
||||
|
||||
steady;
|
||||
|
||||
shocks;
|
||||
|
||||
var eta;
|
||||
stderr 1;
|
||||
var epsilon;
|
||||
stderr 1;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
estimated_params;
|
||||
// ML estimation setup
|
||||
// parameter name, initial value, boundaries_low, ..._up;
|
||||
lambda, .5, 0.25, 0.75;
|
||||
alpha, -2, -8, -0.1;
|
||||
sig_eta, .0001, 0.0001, 0.3;
|
||||
sig_epsilon, .0001, 0.0001, 0.3;
|
||||
end;
|
||||
|
||||
varobs mu x;
|
||||
unit_root_vars x;
|
||||
estimation(datafile=cagan_data,first_obs=1,nobs=34,mh_replic=0,mode_compute=4,mode_check);
|
Loading…
Reference in New Issue