New “add” and “multiply” keywords in “shocks(learnt_in=…)” block

fix-tolerance-parameters
Sébastien Villemot 2022-04-26 15:22:15 +02:00
parent 7dda3c7985
commit a600336c92
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
4 changed files with 26 additions and 16 deletions

View File

@ -98,7 +98,18 @@ else
idx = find([M_.learnt_shocks.learnt_in] == p);
for i = 1:length(idx)
j = idx(i);
oo_.pfwee.shocks_info(M_.learnt_shocks(j).exo_id, M_.learnt_shocks(j).periods, p) = M_.learnt_shocks(j).value;
exo_id = M_.learnt_shocks(j).exo_id;
prds = M_.learnt_shocks(j).periods;
switch M_.learnt_shocks(j).type
case 'level'
oo_.pfwee.shocks_info(exo_id, prds, p) = M_.learnt_shocks(j).value;
case 'add'
oo_.pfwee.shocks_info(exo_id, prds, p) = oo_.pfwee.shocks_info(exo_id, prds, p) + M_.learnt_shocks(j).value;
case 'multiply'
oo_.pfwee.shocks_info(exo_id, prds, p) = oo_.pfwee.shocks_info(exo_id, prds, p) .* M_.learnt_shocks(j).value;
otherwise
error('Unknown type in M_.learnt_shocks')
end
end
end
end

@ -1 +1 @@
Subproject commit dbe14ecfd4bb04ea24880e7715e855332f8b1a8d
Subproject commit 76a16a69a85e4505680c745ddd11e2de23db56cc

View File

@ -87,7 +87,7 @@
;; closed by a semicolon
(defvar dynare-statements-like
'("stderr" "values" "scales" "restriction" "exclusion" "upper_cholesky" "lower_cholesky"
"bind" "relax" "error_bind" "error_relax")
"bind" "relax" "error_bind" "error_relax" "add" "multiply")
"Dynare statements-like keywords.")
;; Those keywords that makes the lexer enter the DYNARE_BLOCK start condition

View File

@ -27,18 +27,16 @@ steady;
check;
// Describe the same scenario as in pfwee.csv, but using the Dynare syntax
shocks;
var x;
periods 1;
periods 1:2;
values 1.2;
end;
shocks(learnt_in = 2);
var x;
periods 2;
values 1.3;
add 0.1;
end;
endval(learnt_in = 2);
@ -47,8 +45,8 @@ end;
shocks(learnt_in = 3);
var x;
periods 3;
values 1.4;
periods 3 7;
values 1.4 1.5;
end;
endval(learnt_in = 3);
@ -65,7 +63,7 @@ end;
shocks(learnt_in = 6, overwrite);
var x;
periods 6:7;
values 1.1;
multiply 0.8;
end;
endval(learnt_in = 6);
@ -86,8 +84,8 @@ pfwee2 = oo_.endo_simul;
perfect_foresight_setup;
// Information arriving in period 1 (temp shock now)
oo_.exo_simul(2,1) = 1.2;
// Information arriving in period 1 (temp shock now and tomorrow)
oo_.exo_simul(2:3,1) = 1.2;
perfect_foresight_solver;
// Information arriving in period 2 (temp shock now + permanent shock in future)
@ -105,8 +103,9 @@ perfect_foresight_solver;
oo_.endo_simul = [ saved_endo oo_.endo_simul ];
oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
// Information arriving in period 3 (temp shock now + permanent shock in future)
// Information arriving in period 3 (temp shocks + permanent shock in future)
oo_.exo_simul(4,1) = 1.4;
oo_.exo_simul(8,1) = 1.5;
oo_.exo_steady_state = 1.2;
oo_.exo_simul(end, 1) = oo_.exo_steady_state;
oo_.steady_state = evaluate_steady_state(oo_.steady_state, M_, options_, oo_, true);
@ -120,9 +119,9 @@ perfect_foresight_solver;
oo_.endo_simul = [ saved_endo oo_.endo_simul ];
oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
// Information arriving in period 6 (permanent shock arriving now)
oo_.exo_simul(7,1) = 1.1;
oo_.exo_simul(8,1) = 1.1;
// Information arriving in period 6 (temp shocks + permanent shock)
oo_.exo_simul(7,1) = 1*0.8;
oo_.exo_simul(8,1) = 1.5*0.8;
oo_.exo_steady_state = 1.1;
oo_.exo_simul(end, 1) = oo_.exo_steady_state;
oo_.steady_state = evaluate_steady_state(oo_.steady_state, M_, options_, oo_, true);