From 187f543a055e33c1608033caab1da4933732703d Mon Sep 17 00:00:00 2001 From: michel Date: Tue, 4 Dec 2007 15:46:49 +0000 Subject: [PATCH] adding examples from Practicing Dynare git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1471 ac1d8469-bf42-47a9-8791-bf33cf982152 --- .../practicing/AssetPricingApproximation.mod | 47 +++++++ tests/practicing/AssetPricingEstimate.mod | 58 ++++++++ tests/practicing/BansalYaronBayes.mod | 42 ++++++ tests/practicing/BansalYaronML.mod | 44 ++++++ tests/practicing/Fig1131.mod | 79 +++++++++++ tests/practicing/Fig1131commented.mod | 130 ++++++++++++++++++ tests/practicing/Fig1132.mod | 79 +++++++++++ tests/practicing/Fig1151.mod | 80 +++++++++++ tests/practicing/Fig1152.mod | 80 +++++++++++ tests/practicing/Fig1171.mod | 80 +++++++++++ tests/practicing/Fig1172.mod | 80 +++++++++++ tests/practicing/GrowthApproximate.mod | 41 ++++++ tests/practicing/GrowthEstimate.mod | 44 ++++++ tests/practicing/HSTBayes.mod | 62 +++++++++ tests/practicing/HSTML.mod | 62 +++++++++ tests/practicing/TwocountryApprox.mod | 45 ++++++ tests/practicing/TwocountryEst.mod | 51 +++++++ tests/practicing/cagan_data.mat | Bin 0 -> 801 bytes tests/practicing/dataHST.mat | Bin 0 -> 7771 bytes tests/practicing/data_consRicardoypg.mat | Bin 0 -> 1959 bytes tests/practicing/datasaver.m | 44 ++++++ tests/practicing/hall1.mod | 46 +++++++ tests/practicing/hall1estimateBayes.mod | 54 ++++++++ tests/practicing/hall1estimateML.mod | 56 ++++++++ tests/practicing/rosen.mod | 55 ++++++++ tests/practicing/rosenestimateBayes.mod | 63 +++++++++ tests/practicing/rosenestimateML.mod | 65 +++++++++ tests/practicing/sargent77.mod | 41 ++++++ tests/practicing/sargent77Bayes.mod | 48 +++++++ tests/practicing/sargent77ML.mod | 52 +++++++ 30 files changed, 1628 insertions(+) create mode 100644 tests/practicing/AssetPricingApproximation.mod create mode 100644 tests/practicing/AssetPricingEstimate.mod create mode 100644 tests/practicing/BansalYaronBayes.mod create mode 100644 tests/practicing/BansalYaronML.mod create mode 100644 tests/practicing/Fig1131.mod create mode 100644 tests/practicing/Fig1131commented.mod create mode 100644 tests/practicing/Fig1132.mod create mode 100644 tests/practicing/Fig1151.mod create mode 100644 tests/practicing/Fig1152.mod create mode 100644 tests/practicing/Fig1171.mod create mode 100644 tests/practicing/Fig1172.mod create mode 100644 tests/practicing/GrowthApproximate.mod create mode 100644 tests/practicing/GrowthEstimate.mod create mode 100644 tests/practicing/HSTBayes.mod create mode 100644 tests/practicing/HSTML.mod create mode 100644 tests/practicing/TwocountryApprox.mod create mode 100644 tests/practicing/TwocountryEst.mod create mode 100644 tests/practicing/cagan_data.mat create mode 100644 tests/practicing/dataHST.mat create mode 100644 tests/practicing/data_consRicardoypg.mat create mode 100644 tests/practicing/datasaver.m create mode 100644 tests/practicing/hall1.mod create mode 100644 tests/practicing/hall1estimateBayes.mod create mode 100644 tests/practicing/hall1estimateML.mod create mode 100644 tests/practicing/rosen.mod create mode 100644 tests/practicing/rosenestimateBayes.mod create mode 100644 tests/practicing/rosenestimateML.mod create mode 100644 tests/practicing/sargent77.mod create mode 100644 tests/practicing/sargent77Bayes.mod create mode 100644 tests/practicing/sargent77ML.mod diff --git a/tests/practicing/AssetPricingApproximation.mod b/tests/practicing/AssetPricingApproximation.mod new file mode 100644 index 000000000..ae762083b --- /dev/null +++ b/tests/practicing/AssetPricingApproximation.mod @@ -0,0 +1,47 @@ +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',[]); \ No newline at end of file diff --git a/tests/practicing/AssetPricingEstimate.mod b/tests/practicing/AssetPricingEstimate.mod new file mode 100644 index 000000000..99db53dc8 --- /dev/null +++ b/tests/practicing/AssetPricingEstimate.mod @@ -0,0 +1,58 @@ +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); \ No newline at end of file diff --git a/tests/practicing/BansalYaronBayes.mod b/tests/practicing/BansalYaronBayes.mod new file mode 100644 index 000000000..2c55da483 --- /dev/null +++ b/tests/practicing/BansalYaronBayes.mod @@ -0,0 +1,42 @@ +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); \ No newline at end of file diff --git a/tests/practicing/BansalYaronML.mod b/tests/practicing/BansalYaronML.mod new file mode 100644 index 000000000..3e49ab1ce --- /dev/null +++ b/tests/practicing/BansalYaronML.mod @@ -0,0 +1,44 @@ + +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); \ No newline at end of file diff --git a/tests/practicing/Fig1131.mod b/tests/practicing/Fig1131.mod new file mode 100644 index 000000000..161a1a69f --- /dev/null +++ b/tests/practicing/Fig1131.mod @@ -0,0 +1,79 @@ +// 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 diff --git a/tests/practicing/Fig1131commented.mod b/tests/practicing/Fig1131commented.mod new file mode 100644 index 000000000..dafb29f57 --- /dev/null +++ b/tests/practicing/Fig1131commented.mod @@ -0,0 +1,130 @@ +// 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') diff --git a/tests/practicing/Fig1132.mod b/tests/practicing/Fig1132.mod new file mode 100644 index 000000000..c291403b5 --- /dev/null +++ b/tests/practicing/Fig1132.mod @@ -0,0 +1,79 @@ +// 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 diff --git a/tests/practicing/Fig1151.mod b/tests/practicing/Fig1151.mod new file mode 100644 index 000000000..bfcc6fd49 --- /dev/null +++ b/tests/practicing/Fig1151.mod @@ -0,0 +1,80 @@ +// 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 + diff --git a/tests/practicing/Fig1152.mod b/tests/practicing/Fig1152.mod new file mode 100644 index 000000000..da14b0779 --- /dev/null +++ b/tests/practicing/Fig1152.mod @@ -0,0 +1,80 @@ +// 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 + diff --git a/tests/practicing/Fig1171.mod b/tests/practicing/Fig1171.mod new file mode 100644 index 000000000..353ddcee0 --- /dev/null +++ b/tests/practicing/Fig1171.mod @@ -0,0 +1,80 @@ +// 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 + diff --git a/tests/practicing/Fig1172.mod b/tests/practicing/Fig1172.mod new file mode 100644 index 000000000..969b71f74 --- /dev/null +++ b/tests/practicing/Fig1172.mod @@ -0,0 +1,80 @@ +// 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 + diff --git a/tests/practicing/GrowthApproximate.mod b/tests/practicing/GrowthApproximate.mod new file mode 100644 index 000000000..a33f62bcd --- /dev/null +++ b/tests/practicing/GrowthApproximate.mod @@ -0,0 +1,41 @@ + + +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',[]); diff --git a/tests/practicing/GrowthEstimate.mod b/tests/practicing/GrowthEstimate.mod new file mode 100644 index 000000000..9ef1f4a3b --- /dev/null +++ b/tests/practicing/GrowthEstimate.mod @@ -0,0 +1,44 @@ + +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); diff --git a/tests/practicing/HSTBayes.mod b/tests/practicing/HSTBayes.mod new file mode 100644 index 000000000..0efb6d742 --- /dev/null +++ b/tests/practicing/HSTBayes.mod @@ -0,0 +1,62 @@ +// 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); diff --git a/tests/practicing/HSTML.mod b/tests/practicing/HSTML.mod new file mode 100644 index 000000000..52f7febfb --- /dev/null +++ b/tests/practicing/HSTML.mod @@ -0,0 +1,62 @@ +// 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); + diff --git a/tests/practicing/TwocountryApprox.mod b/tests/practicing/TwocountryApprox.mod new file mode 100644 index 000000000..024cd4d79 --- /dev/null +++ b/tests/practicing/TwocountryApprox.mod @@ -0,0 +1,45 @@ +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',[]); \ No newline at end of file diff --git a/tests/practicing/TwocountryEst.mod b/tests/practicing/TwocountryEst.mod new file mode 100644 index 000000000..bc5a41f4c --- /dev/null +++ b/tests/practicing/TwocountryEst.mod @@ -0,0 +1,51 @@ +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); \ No newline at end of file diff --git a/tests/practicing/cagan_data.mat b/tests/practicing/cagan_data.mat new file mode 100644 index 0000000000000000000000000000000000000000..0d27da163c26c5a996e548287c3a6dd4c699bb11 GIT binary patch literal 801 zcmeZu4DoSvQZUssQ1EpO(M`+DN!3vZ$Vn_o%P-2cQV4Jk_w>_Ia4t$sEJ;mK$j`G< z@XgOt@G8wyFfdUtw6roYvNAMOFfuSOS0EWMFnap(GcYi?Gcqt#%z2!gkWi42l90fB zNrp#2iX~!UjjBQ#OR`$qogg+gKZR%p4TZOlXDZ4R7X07%Je^#dougizaQc&@^3$xp*L-po zj6SpO*7+OD%y(aZI^*xcUF_3ecjeuVpQBM%>i5d^ciS@A>JV4{oB9v>cD^mGT=sX~ zuKwkb{&P0||7P8H{?mcvYKE>=Q|m#&>4i5q-P*Vm&T<}Ma%c>et>1GfE&fLRf}~@| z|L*pC>p$mTMeg>SOaJb^({hcwY|icZwc4xH!X91v$7iOitbDBd_j51H|669(*X^G% zfA+-wAFY2s=RaARcE^6>|DDs1H!fE9d-MLnN}fllaoO>cZ|rb>e`n&~_n++c#0zdo z{69DQzudel_wxQPi2Chv^X%o{;a7fMKbvB?(f-c&{0xr6jeq&&p5|=+v*F6WZlBh~ zcl&gI_nzm}E%&zBY@eI>itT)7`}gXYJ7KqqO6S||PCD^NT5J28yIN(b?Hgpaif?=O z{`JP4$^XmC-n4dp{QgGx+4=py4=%a4&#iHH-nzSX)e8?^mF+xx!n;_uf7 ut()}v@!!e6m+So2e0pNb`G4+jmj3x$=l{lDWZs*9`X7$TF}!J*I1K<)0FIFW literal 0 HcmV?d00001 diff --git a/tests/practicing/dataHST.mat b/tests/practicing/dataHST.mat new file mode 100644 index 0000000000000000000000000000000000000000..107ce6fbcbbe85cfab742a06b5dcd92b34a64913 GIT binary patch literal 7771 zcmb7|WkVAT!$ws?x;u4_wfA7s(d1c%;Z{7^yym{lB%cq4dsBN$; zQzG94#`Nb8iaU80Y%x72LC>CNh^-3%<@<})1KdDFF zpD?nn&Yuvkuc9!&#ip6I`!-n5ddp%yClk{mD;pF4_brCT*Wp(&^;ZEZybpxMCh(Ye zpjxg{0lQG2(eb8+gD}+#HOw&k@w5&dw}rDeQSXNca)~VFN;FwaK{eLoq#0gbciu8$ zc%#DD3nYV#M4!gBUx$QMWpBci@sT@IjI7Q89Z4gH8#u^_rEh}^xHKmd@f=eLE}k;o ztcOuLb6Bf-E~|c02$S@K#_c#s`LoPWE%!Z^QkCS}A*(3P4aPfm6|FM+w+C9zj3w%e z+8)(F|K1qmUb@4c&%Sc|CO7J7=tuYS9&7j?j$_FdjU*Z!v{(K1-a?l`RqtY|!GTT| zeme~56^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*k$aLw9j+52SiP6h*B3~bhAdLt5puA>bF_Bw^)6z}cyh41 z-UavSEe1Zt1*7ZA$c~B`CRViXG`noigZr$X(U*n{WHJh}mA^~G$)8l5*Qg|-X+-Y_ z`Dhw4n+@|XUP}PA?Bk`GQ+}BA47TbkPR5)llzjG0Jo-kLw|aC6A=5}7)}yAOsa~=7 z^%6eb%@1veU7d&sXUQ7RgV88`u3n(j8iiednXJY~9!zBu^}oIkgOnz!phpUjY#6~9 zFBQW6)D|;#6(3{Gx3Z>r;dnkikZgJ|3Xd0g-zW(ZV|mG^>AVfmURw9DptR2)|my6l=t^Kc$)&woBLiJrhFgR#VV8)zLUalkU3y4X9rFnSH*}wbts0Nar=}Ln#V6q~ zeNIlk8-p)~Wv&4)mcaI(rj8U09+JBUFiBW9nc($=94s8zp{5mfolFnB-#7=PWsz`Dw{R0nE zzVgX+ZSI7)A-A}Ej~y%(A#}kqKm2u&T>s<3-@6RI^2%)%Vtvj8Y_6~{xTE30Gpobk tyKU^!+{46BvY4psVxd{t%_jeq3w{jI8BntoV3%F${Y$r_@ozk9Rt{ggsEGgo literal 0 HcmV?d00001 diff --git a/tests/practicing/datasaver.m b/tests/practicing/datasaver.m new file mode 100644 index 000000000..dcee78ca4 --- /dev/null +++ b/tests/practicing/datasaver.m @@ -0,0 +1,44 @@ +% Copyright (C) 2001 Michel Juillard +% +function dynatype (s,var_list) +% DYNATYPE : DYNATYPE ( [ 'filename' ] ) +% This optional command saves the simulation +% results in a text file. The name of each +% variable preceeds the corresponding results. +% This command must follow SIMUL. + +global lgy_ lgx_ y_ endo_nbr + +%fid=fopen([s,'.m'],'w') ; +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 ; diff --git a/tests/practicing/hall1.mod b/tests/practicing/hall1.mod new file mode 100644 index 000000000..974fbca7e --- /dev/null +++ b/tests/practicing/hall1.mod @@ -0,0 +1,46 @@ +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 c in; \ No newline at end of file diff --git a/tests/practicing/hall1estimateBayes.mod b/tests/practicing/hall1estimateBayes.mod new file mode 100644 index 000000000..0fe590dab --- /dev/null +++ b/tests/practicing/hall1estimateBayes.mod @@ -0,0 +1,54 @@ +// 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); diff --git a/tests/practicing/hall1estimateML.mod b/tests/practicing/hall1estimateML.mod new file mode 100644 index 000000000..7eb498871 --- /dev/null +++ b/tests/practicing/hall1estimateML.mod @@ -0,0 +1,56 @@ +// 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 \ No newline at end of file diff --git a/tests/practicing/rosen.mod b/tests/practicing/rosen.mod new file mode 100644 index 000000000..ed71d8940 --- /dev/null +++ b/tests/practicing/rosen.mod @@ -0,0 +1,55 @@ +// 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 s N P W; + diff --git a/tests/practicing/rosenestimateBayes.mod b/tests/practicing/rosenestimateBayes.mod new file mode 100644 index 000000000..e93ab59da --- /dev/null +++ b/tests/practicing/rosenestimateBayes.mod @@ -0,0 +1,63 @@ +// 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); + + diff --git a/tests/practicing/rosenestimateML.mod b/tests/practicing/rosenestimateML.mod new file mode 100644 index 000000000..f9768f20e --- /dev/null +++ b/tests/practicing/rosenestimateML.mod @@ -0,0 +1,65 @@ +// 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); + + + + diff --git a/tests/practicing/sargent77.mod b/tests/practicing/sargent77.mod new file mode 100644 index 000000000..f2983fdf4 --- /dev/null +++ b/tests/practicing/sargent77.mod @@ -0,0 +1,41 @@ +// 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 x mu; \ No newline at end of file diff --git a/tests/practicing/sargent77Bayes.mod b/tests/practicing/sargent77Bayes.mod new file mode 100644 index 000000000..39492e09a --- /dev/null +++ b/tests/practicing/sargent77Bayes.mod @@ -0,0 +1,48 @@ +// 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); diff --git a/tests/practicing/sargent77ML.mod b/tests/practicing/sargent77ML.mod new file mode 100644 index 000000000..2a5ad6d36 --- /dev/null +++ b/tests/practicing/sargent77ML.mod @@ -0,0 +1,52 @@ +// 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); \ No newline at end of file