From 2aa6565c186f7995a2b64c8b4514a55d219382c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Ry=C3=BBk=29?= Date: Wed, 31 Aug 2022 13:37:00 +0200 Subject: [PATCH] Add test for lmmcp in extended path. --- tests/Makefile.am | 3 +++ tests/ep/rbcii-calibration.inc | 10 ++++++++++ tests/ep/rbcii.mod | 21 +++++---------------- tests/ep/rbcii_MCP.mod | 21 ++++++++++++++------- 4 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 tests/ep/rbcii-calibration.inc diff --git a/tests/Makefile.am b/tests/Makefile.am index 552e137fe..32de1b95d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -983,6 +983,9 @@ model-inversion/nk-2/invert.o.trs: model-inversion/nk-2/simulate.o.trs model-inversion/nk-2/z_check_inversion.m.trs: model-inversion/nk-2/invert.m.trs model-inversion/nk-2/z_check_inversion.o.trs: model-inversion/nk-2/invert.o.trs +ep/rbcii_MCP.m.trs: ep/rbcii.m.trs +ep/rbcii_MCP.o.trs: ep/rbcii.o.trs + observation_trends_and_prefiltering/MCMC: m/observation_trends_and_prefiltering/MCMC o/observation_trends_and_prefiltering/MCMC m/observation_trends_and_prefiltering/MCMC: $(patsubst %.mod, %.m.trs, $(filter observation_trends_and_prefiltering/MCMC/%.mod, $(MODFILES))) o/observation_trends_and_prefiltering/MCMC: $(patsubst %.mod, %.o.trs, $(filter observation_trends_and_prefiltering/MCMC/%.mod, $(MODFILES))) diff --git a/tests/ep/rbcii-calibration.inc b/tests/ep/rbcii-calibration.inc new file mode 100644 index 000000000..05ceb2622 --- /dev/null +++ b/tests/ep/rbcii-calibration.inc @@ -0,0 +1,10 @@ +Astar = 1.000 ; +beta = 0.990 ; +theta = 0.357 ; +tau = 2.000 ; +alpha = 0.450 ; +psi = -0.200 ; +delta = 0.020 ; +rho = 0.800 ; +effstar = 1.000 ; +sigma = 0.100 ; diff --git a/tests/ep/rbcii.mod b/tests/ep/rbcii.mod index 6e5383949..cf8c6a5e4 100644 --- a/tests/ep/rbcii.mod +++ b/tests/ep/rbcii.mod @@ -6,19 +6,7 @@ varexo EfficiencyInnovation; parameters beta, theta, tau, alpha, psi, delta, rho, effstar, sigma; -/* -** Calibration -*/ - -beta = 0.990; -theta = 0.357; -tau = 2.000; -alpha = 0.450; -psi = -0.200; -delta = 0.020; -rho = 0.800; -effstar = 1.000; -sigma = 0.100; +@#include "rbcii-calibration.inc" model(use_dll); @@ -63,11 +51,12 @@ end; steady(nocheck); options_.ep.stochastic.order = 0; - - ts = extended_path([], 20, [], options_, M_, oo_); +!* + ts = extended_path([], 200, [], options_, M_, oo_); + ts.save('rbcii-sim-data'); options_.ep.stochastic.order = 1; - ts1_4 = extended_path([], 20, [], options_, M_, oo_); + ts1_4 = extended_path([], 200, [], options_, M_, oo_); @#else diff --git a/tests/ep/rbcii_MCP.mod b/tests/ep/rbcii_MCP.mod index 2351e7485..f3fca41d2 100644 --- a/tests/ep/rbcii_MCP.mod +++ b/tests/ep/rbcii_MCP.mod @@ -1,15 +1,14 @@ % RBC model with irreversible investment constraint, implemented using MCP tag. var k, y, L, c, A, a, mu, i; + varexo epsilon; + parameters beta, theta, tau, alpha, psi, delta, rho, Astar; -beta = 0.9900; theta = 0.3570; -tau = 2.0000; alpha = 0.4500; -psi = -0.1000; delta = 0.0200; -rho = 0.8000; Astar = 1.0000; +@#include "rbcii-calibration.inc" -model; +model(use_dll); a = rho*a(-1) + epsilon; A = Astar*exp(a); y = A*(alpha*k(-1)^psi+(1-alpha)*L^psi)^(1/psi); @@ -51,8 +50,16 @@ shocks; stderr 0.10; end; -extended_path(periods=50,lmmcp); +extended_path(periods=200,lmmcp); if any(oo_.endo_simul(strmatch('i',M_.endo_names,'exact'),:)<-1e-6) - error('lmmcp tag did not work') + error('lmmcp tag did not work.') end + +ds = dseries('rbcii-sim-data.mat'); + +if any(abs(transpose(oo_.endo_simul(strmatch('i',M_.endo_names,'exact'),:))-ds.Investment.data)>1e-6) + error('Simulation with lmmcp returns different results.') +end + +delete rbcii-sim-data.mat