From 614b79cf72849ece17bce501ccb35e3e3b4188c4 Mon Sep 17 00:00:00 2001 From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152> Date: Wed, 16 Dec 2009 13:41:22 +0000 Subject: [PATCH] Updated and enhanced tests for block and bytecode options git-svn-id: https://www.dynare.org/svn/dynare/trunk@3245 ac1d8469-bf42-47a9-8791-bf33cf982152 --- tests/Makefile.am | 6 + .../{ferhat => block_bytecode}/MARK3_endo.dat | 0 .../{ferhat => block_bytecode}/MARK3_exo.dat | 0 tests/block_bytecode/fs2000_bicgstab.mod | 7 ++ tests/block_bytecode/fs2000_bytecode.mod | 7 ++ tests/block_bytecode/fs2000_common.mod | 91 ++++++++++++++ tests/block_bytecode/fs2000_gmres.mod | 7 ++ tests/block_bytecode/fs2000_lu.mod | 7 ++ tests/block_bytecode/fs2000_optpath.mod | 7 ++ tests/block_bytecode/fs2000_simk.mod | 4 + tests/{ferhat => block_bytecode}/ireland.mod | 59 +-------- tests/{ferhat => block_bytecode}/ls2003.mod | 34 +---- tests/{ferhat => block_bytecode}/mod1.mod | 0 tests/{ferhat => block_bytecode}/multimod.mod | 0 tests/{ferhat => block_bytecode}/ramst.mod | 0 tests/{ferhat => block_bytecode}/ramst_a.mod | 4 +- tests/ferhat/fs2000.mod | 118 ------------------ 17 files changed, 143 insertions(+), 208 deletions(-) rename tests/{ferhat => block_bytecode}/MARK3_endo.dat (100%) rename tests/{ferhat => block_bytecode}/MARK3_exo.dat (100%) create mode 100644 tests/block_bytecode/fs2000_bicgstab.mod create mode 100644 tests/block_bytecode/fs2000_bytecode.mod create mode 100644 tests/block_bytecode/fs2000_common.mod create mode 100644 tests/block_bytecode/fs2000_gmres.mod create mode 100644 tests/block_bytecode/fs2000_lu.mod create mode 100644 tests/block_bytecode/fs2000_optpath.mod create mode 100644 tests/block_bytecode/fs2000_simk.mod rename tests/{ferhat => block_bytecode}/ireland.mod (58%) rename tests/{ferhat => block_bytecode}/ls2003.mod (62%) rename tests/{ferhat => block_bytecode}/mod1.mod (100%) rename tests/{ferhat => block_bytecode}/multimod.mod (100%) rename tests/{ferhat => block_bytecode}/ramst.mod (100%) rename tests/{ferhat => block_bytecode}/ramst_a.mod (83%) delete mode 100644 tests/ferhat/fs2000.mod diff --git a/tests/Makefile.am b/tests/Makefile.am index dc215e0c1b..26b1e11046 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,12 @@ OCTAVE_MODS = \ ramst_initval_file.mod \ example1_varexo_det.mod \ predetermined_variables.mod \ + block_bytecode/fs2000_simk.mod \ + block_bytecode/fs2000_lu.mod \ + block_bytecode/fs2000_bytecode.mod \ + block_bytecode/ramst.mod \ + block_bytecode/ireland.mod \ + block_bytecode/ls2003.mod \ k_order_perturbation/fs2000k2a.mod \ k_order_perturbation/fs2000k2.mod \ k_order_perturbation/fs2000k_1.mod \ diff --git a/tests/ferhat/MARK3_endo.dat b/tests/block_bytecode/MARK3_endo.dat similarity index 100% rename from tests/ferhat/MARK3_endo.dat rename to tests/block_bytecode/MARK3_endo.dat diff --git a/tests/ferhat/MARK3_exo.dat b/tests/block_bytecode/MARK3_exo.dat similarity index 100% rename from tests/ferhat/MARK3_exo.dat rename to tests/block_bytecode/MARK3_exo.dat diff --git a/tests/block_bytecode/fs2000_bicgstab.mod b/tests/block_bytecode/fs2000_bicgstab.mod new file mode 100644 index 0000000000..3a39594ed7 --- /dev/null +++ b/tests/block_bytecode/fs2000_bicgstab.mod @@ -0,0 +1,7 @@ +// Tests option block + stack_solve_algo = 3 + solve_algo = 1 +// Must be launched after fs2000_simk.mod + +@#define block_bytecode = 1 +@#define solve_algo = 1 +@#define stack_solve_algo = 3 +@#include "fs2000_common.mod" diff --git a/tests/block_bytecode/fs2000_bytecode.mod b/tests/block_bytecode/fs2000_bytecode.mod new file mode 100644 index 0000000000..880d715e5f --- /dev/null +++ b/tests/block_bytecode/fs2000_bytecode.mod @@ -0,0 +1,7 @@ +// Tests option block+bytecode +// Must be launched after fs2000_simk.mod + +@#define block_bytecode = 2 +@#define solve_algo = 5 +@#define stack_solve_algo = 5 +@#include "fs2000_common.mod" diff --git a/tests/block_bytecode/fs2000_common.mod b/tests/block_bytecode/fs2000_common.mod new file mode 100644 index 0000000000..0d86c7d468 --- /dev/null +++ b/tests/block_bytecode/fs2000_common.mod @@ -0,0 +1,91 @@ +var m P c e W R k d n l gy_obs gp_obs y dA; +varexo e_a e_m; + +parameters alp bet gam mst rho psi del; + +alp = 0.33; +bet = 0.99; +gam = 0.003; +mst = 1.011; +rho = 0.7; +psi = 0.787; +del = 0.02; + +@#if block_bytecode == 2 +model(block, bytecode); +@#else +@# if block_bytecode == 1 +model(block); +@# else +model; +@# endif +@#endif + +/*0*/ exp(gam+e_a) = dA ; +/*1*/ log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; +/*2*/ -P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0; +/*3*/ l/n = W; +/*4*/ -(psi/(1-psi))*(c*P/(1-n))+l/n = 0; +/*5*/ R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W; +/*6*/ 1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0; +/*7*/ c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1); +/*8*/ P*c = m; +/*9*/ m-1+d = l; +/*10*/ e = exp(e_a); +/*11*/ k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)) = y ; +/*12*/ gy_obs = dA*y/y(-1); +/*13*/ gp_obs = (P/P(-1))*m(-1)/dA; +end; + +initval; +k = 6; +m = mst; +P = 2.25; +c = 0.45; +e = 1; +W = 4; +R = 1.02; +d = 0.85; +n = 0.19; +l = 0.86; +y = 0.6; +gy_obs = exp(gam); +gp_obs = exp(-gam); +dA = exp(gam); +e_a=0; +e_m=0; +end; + +shocks; +var e_a; stderr 0.014; +var e_m; stderr 0.005; +end; + +options_.maxit_=10; +steady(solve_algo = @{solve_algo}); + +@#if block_bytecode > 0 +model_info; +@#endif + +shocks; +var e_a; +periods 1; +values 0.16; +end; + +simul(periods=200, stack_solve_algo = @{stack_solve_algo}); + +@#if block_bytecode > 0 +if ~exist('fs2000_simk_results.mat','file'); + error('fs2000_simk must be run first'); +end; + +oo1 = load('fs2000_simk_results','oo_'); + +err = max(max(abs(oo_.endo_simul - oo1.oo_.endo_simul))) +disp(['Max error in simulation: ' num2str(err)]) +if err > 1e-4 + error('Error above the threshold') +end; +@#endif diff --git a/tests/block_bytecode/fs2000_gmres.mod b/tests/block_bytecode/fs2000_gmres.mod new file mode 100644 index 0000000000..e45caee150 --- /dev/null +++ b/tests/block_bytecode/fs2000_gmres.mod @@ -0,0 +1,7 @@ +// Tests option block + stack_solve_algo = 2 + solve_algo = 3 +// Must be launched after fs2000_simk.mod + +@#define block_bytecode = 1 +@#define solve_algo = 3 +@#define stack_solve_algo = 2 +@#include "fs2000_common.mod" diff --git a/tests/block_bytecode/fs2000_lu.mod b/tests/block_bytecode/fs2000_lu.mod new file mode 100644 index 0000000000..08e61cf0ba --- /dev/null +++ b/tests/block_bytecode/fs2000_lu.mod @@ -0,0 +1,7 @@ +// Tests option block + stack_solve_algo = 1 + solve_algo = 2 +// Must be launched after fs2000_simk.mod + +@#define block_bytecode = 1 +@#define solve_algo = 2 +@#define stack_solve_algo = 1 +@#include "fs2000_common.mod" diff --git a/tests/block_bytecode/fs2000_optpath.mod b/tests/block_bytecode/fs2000_optpath.mod new file mode 100644 index 0000000000..5b691611f6 --- /dev/null +++ b/tests/block_bytecode/fs2000_optpath.mod @@ -0,0 +1,7 @@ +// Tests option block + stack_solve_algo = 4 + solve_algo = 4 +// Must be launched after fs2000_simk.mod + +@#define block_bytecode = 1 +@#define solve_algo = 4 +@#define stack_solve_algo = 4 +@#include "fs2000_common.mod" diff --git a/tests/block_bytecode/fs2000_simk.mod b/tests/block_bytecode/fs2000_simk.mod new file mode 100644 index 0000000000..9f2aa75181 --- /dev/null +++ b/tests/block_bytecode/fs2000_simk.mod @@ -0,0 +1,4 @@ +@#define block_bytecode = 0 +@#define solve_algo = 2 +@#define stack_solve_algo = 0 +@#include "fs2000_common.mod" diff --git a/tests/ferhat/ireland.mod b/tests/block_bytecode/ireland.mod similarity index 58% rename from tests/ferhat/ireland.mod rename to tests/block_bytecode/ireland.mod index b5ca4100c7..654b451fd2 100644 --- a/tests/ferhat/ireland.mod +++ b/tests/block_bytecode/ireland.mod @@ -23,10 +23,7 @@ scy = 0.0040; shy = 0.0015; shc = 0.0010; -//model(block, bytecode, cutoff=0); model(block,cutoff=0); -//model(block); -//model; exp(y) = exp(a)*exp(k(-1))^theta*exp(h)^(1-theta); a = (1-rho)*aa+rho*a(-1)+e; exp(y) = exp(c) + exp(i); @@ -42,19 +39,6 @@ oh = h + eoh; end; initval; -/*a = 1.7; -y = 8; -c = 8; -k = 10; -i = 5; -h = 4; -eoy = 0; -eoc = 0; -eoh = 0; -oy = y; -oc = c; -oh = h; -*/ e=0; eeoy=0; eeoc=0; @@ -79,55 +63,18 @@ options_.dynatol=1e-12; options_.maxit_=5; options_.slowc=1; steady(solve_algo=2); -//steady; -options_.dynatol=4e-5; - -//check; +options_.dynatol=4e-5; shocks; var e; periods 1; values 0.02; end; + options_.maxit_=20; model_info; -simul(periods=2000, method=LU/*GMRES*//*bicgstab*/); +simul(periods=2000, stack_solve_algo = 1); rplot y; rplot k; - - -/*estimated_params; -theta , 0.22, 0.1, 0.5; -rho , 0.99, 0.7, 0.9999; -eta , 1.0051, 1, 1.03; -gam , 0.0045, 0.001, 0.01; -aa , 1.8, 0.1, 4; -r11 , 1.4187, -2, 2; -r12 , 0.2251, -2, 2; -r13 , -0.4441, -2, 2; -r21 , 0.0935, -2, 2; -r22 , 1.0236, -2, 2; -r23 , -0.0908, -2, 2; -r31 , 0.7775, -2, 2; -r32 , 0.3706, -2, 2; -r33 , 0.2398, -2, 2; -scy , 0.0040, -2, 2; -shy , 0.0015, -2, 2; -shc , 0.0010, -2, 2; -stderr e , 0.0056, 0, 0.2; -stderr eeoy , 0.0070, 0, 0.1; -stderr eeoc , 0.0069, 0, 0.1; -stderr eeoh , 0.0018, 0, 0.1; -end; - -varobs oy oc oh; - -observation_trends; -oy (log(eta)); -oc (log(eta)); -end; - -estimation(datafile=idata,mode_compute=1,nograph); -*/ diff --git a/tests/ferhat/ls2003.mod b/tests/block_bytecode/ls2003.mod similarity index 62% rename from tests/ferhat/ls2003.mod rename to tests/block_bytecode/ls2003.mod index 8dd2eb7bec..8a0b5f01ea 100644 --- a/tests/ferhat/ls2003.mod +++ b/tests/block_bytecode/ls2003.mod @@ -18,8 +18,6 @@ rho_pies = 0.7; model(block, bytecode, cutoff=0); -//model(sparse); -//model; y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1); pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s; pie = de+(1-alpha)*dq+pie_s; @@ -54,34 +52,8 @@ var e_ys = 1.89; var e_pies = 1.89; end; -/*varobs y_obs R_obs pie_obs dq de; - -estimated_params; -psi1 , gamma_pdf,1.5,0.5; -psi2 , gamma_pdf,0.25,0.125; -psi3 , gamma_pdf,0.25,0.125; -rho_R ,beta_pdf,0.5,0.2; -alpha ,beta_pdf,0.3,0.1; -rr ,gamma_pdf,2.5,1; -k , gamma_pdf,0.5,0.25; -tau ,gamma_pdf,0.5,0.2; -rho_q ,beta_pdf,0.4,0.2; -rho_A ,beta_pdf,0.5,0.2; -rho_ys ,beta_pdf,0.8,0.1; -rho_pies,beta_pdf,0.7,0.15; -stderr e_R,inv_gamma_pdf,1.2533,0.6551; -stderr e_q,inv_gamma_pdf,2.5066,1.3103; -stderr e_A,inv_gamma_pdf,1.2533,0.6551; -stderr e_ys,inv_gamma_pdf,1.2533,0.6551; -stderr e_pies,inv_gamma_pdf,1.88,0.9827; -end; - -estimation(datafile=data_ca1,first_obs=8,nobs=79,mh_nblocks=10,prefilter=1,mh_jscale=0.5,mh_replic=0,nograph); -*/ - - options_.maxit_=100; -steady; +steady(solve_algo = 5); model_info; //check; @@ -92,12 +64,10 @@ periods 1; values 0.5; end; -//simul(periods=200,method=bicgstab); -simul(periods=20, markowitz=0); +simul(periods=20, markowitz=0, stack_solve_algo = 5); rplot vv; rplot ww; rplot A; rplot pie; -//stoch_simul(periods=200,order=1); diff --git a/tests/ferhat/mod1.mod b/tests/block_bytecode/mod1.mod similarity index 100% rename from tests/ferhat/mod1.mod rename to tests/block_bytecode/mod1.mod diff --git a/tests/ferhat/multimod.mod b/tests/block_bytecode/multimod.mod similarity index 100% rename from tests/ferhat/multimod.mod rename to tests/block_bytecode/multimod.mod diff --git a/tests/ferhat/ramst.mod b/tests/block_bytecode/ramst.mod similarity index 100% rename from tests/ferhat/ramst.mod rename to tests/block_bytecode/ramst.mod diff --git a/tests/ferhat/ramst_a.mod b/tests/block_bytecode/ramst_a.mod similarity index 83% rename from tests/ferhat/ramst_a.mod rename to tests/block_bytecode/ramst_a.mod index 57c8923add..21ad4bd24c 100644 --- a/tests/ferhat/ramst_a.mod +++ b/tests/block_bytecode/ramst_a.mod @@ -23,7 +23,7 @@ end; steady; -check; +//check; shocks; var x; @@ -31,7 +31,7 @@ periods 1 2 3 4; values 1.1 1.2 1.3 1.4; end; -simul(periods=200); +simul(periods=200, stack_solve_algo = 2); rplot c; rplot k; diff --git a/tests/ferhat/fs2000.mod b/tests/ferhat/fs2000.mod deleted file mode 100644 index ac78d80523..0000000000 --- a/tests/ferhat/fs2000.mod +++ /dev/null @@ -1,118 +0,0 @@ -// This file replicates the estimation of the CIA model from -// Frank Schorfheide (2000) "Loss function-based evaluation of DSGE models" -// Journal of Applied Econometrics, 15, 645-670. -// the data are the ones provided on Schorfheide's web site with the programs. -// http://www.econ.upenn.edu/~schorf/programs/dsgesel.ZIP -// You need to have fsdat.m in the same directory as this file. -// This file replicates: -// -the posterior mode as computed by Frank's Gauss programs -// -the parameter mean posterior estimates reported in the paper -// -the model probability (harmonic mean) reported in the paper -// This file was tested with dyn_mat_test_0218.zip -// the smooth shocks are probably stil buggy -// -// The equations are taken from J. Nason and T. Cogley (1994) -// "Testing the implications of long-run neutrality for monetary business -// cycle models" Journal of Applied Econometrics, 9, S37-S70. -// Note that there is an initial minus sign missing in equation (A1), p. S63. -// -// Michel Juillard, February 2004 -@#define bytecode = 1 -@#define block = 1 -var m P c e W R k d n l gy_obs gp_obs y dA; -varexo e_a e_m; - -parameters alp bet gam mst rho psi del; - -alp = 0.33; -bet = 0.99; -gam = 0.003; -mst = 1.011; -rho = 0.7; -psi = 0.787; -del = 0.02; - -@#if block == 1 - @#if bytecode == 1 - model(block, bytecode); - @#else - model(block); - @#endif -@#else - model; -@#endif -/*0*/ exp(gam+e_a) = dA ; -/*1*/ log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m; -/*2*/ -P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0; -/*3*/ l/n = W; -/*4*/ -(psi/(1-psi))*(c*P/(1-n))+l/n = 0; -/*5*/ R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W; -/*6*/ 1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0; -/*7*/ c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1); -/*8*/ P*c = m; -/*9*/ m-1+d = l; -/*10*/ e = exp(e_a); -/*11*/ k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a)) = y ; -/*12*/ gy_obs = dA*y/y(-1); -/*13*/ gp_obs = (P/P(-1))*m(-1)/dA; -end; - -initval; -k = 6; -m = mst; -P = 2.25; -c = 0.45; -e = 1; -W = 4; -R = 1.02; -d = 0.85; -n = 0.19; -l = 0.86; -y = 0.6; -gy_obs = exp(gam); -gp_obs = exp(-gam); -dA = exp(gam); -e_a=0; -e_m=0; -end; - -shocks; -var e_a; stderr 0.014; -var e_m; stderr 0.005; -end; - - - -options_.maxit_=10; -@#if bytecode == 1 - steady(solve_algo = 5); -@#else - steady(solve_algo = 4); -@#endif - -model_info; - - -@#if block == 0 - check; -@#endif - -shocks; -var e_a; -periods 1; -values 0.16; -end; - -@#if block == 1 - @#if bytecode == 1 - simul(periods=200, stack_solve_algo = 5); - @#else - simul(periods=200, stack_solve_algo = 1); - @#endif -@#else - simul(periods=200, stack_solve_algo = 0); -@#endif - -rplot y; -rplot k; -rplot c; -- GitLab