New += and *= syntaxes in “endval(learnt_in=…)” blocks

fix-tolerance-parameters
Sébastien Villemot 2022-05-03 17:46:59 +02:00
parent 5b49662a94
commit 63a116fb28
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
4 changed files with 40 additions and 12 deletions

View File

@ -3915,6 +3915,7 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
end;
This syntax means that:
- from the perspective of period 1, ``x`` is expected to be equal to 1 in
periods 1 and 2, to 1.2 in periods 3 and 4, and to 1.4 in period 5;
- from the perspective of periods 2 (and 3), ``x`` is expected to be
@ -3925,23 +3926,40 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
.. block:: endval(learnt_in=INTEGER) ;
|br| The ``endval(learnt_in=INTEGER)`` can be used to specify temporary
shocks that are learnt in a specific period.
|br| The ``endval(learnt_in=INTEGER)`` can be used to specify terminal
conditions that are learnt in a specific period.
Note that an ``endval(learnt_in=1)`` block is equivalent to a regular
:bck:`endval` block.
It is possible to express the terminal condition by specifying the level of
the exogenous variable (using an equal symbol, as in a regular
:bck:`endval` blocks without the ``learnt_in`` option). But it is also
possible to express the terminal condition as an addition to the value
expected from the perspective of the previous previous period (using the
``+=`` operator), or as a multiplicative factor over that previously
expected value (using the ``*=`` operator).
*Example*
::
endval(learnt_in = 2);
endval(learnt_in = 3);
x = 1.1;
y += 0.1;
z *= 2;
end;
This syntax means that, in period 2, the agents learn that the terminal
condition for ``x`` will be 1.1. This value will be the realized one,
unless there is another ``endval(learnt_in=p)`` block with ``p>2``.
This syntax means that, in period 3, the agents learn that:
- the terminal condition for ``x`` will be 1.1;
- the terminal condition for ``y`` will be 0.1 above the terminal
condition for ``y`` that was expected from the perspective of period 2;
- the terminal condition for ``z`` will be 2 times the terminal condition
for ``z`` that was expected from the perspective of period 2.
Those values will be the realized ones, unless there is another
``endval(learnt_in=p)`` block with ``p>3``.
.. command:: perfect_foresight_with_expectation_errors_setup ;
perfect_foresight_with_expectation_errors_setup (OPTIONS...);

View File

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

@ -1 +1 @@
Subproject commit 8c07fb5e4310b2ec2988dc62256e1cf0971c05dd
Subproject commit 3a820fffa2f7291be5732c33bde552526eab1602

View File

@ -50,7 +50,7 @@ shocks(learnt_in = 3);
end;
endval(learnt_in = 3);
x = 1.2;
x += 0.1;
end;
// Dummy block, that will be overwritten by the next one
@ -67,7 +67,7 @@ shocks(learnt_in = 6, overwrite);
end;
endval(learnt_in = 6);
x = 1.1;
x *= 0.75;
end;
perfect_foresight_with_expectation_errors_setup(periods = 7);
@ -106,7 +106,7 @@ oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
// 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_steady_state = 1.1+0.1;
oo_.exo_simul(end, 1) = oo_.exo_steady_state;
oo_.steady_state = evaluate_steady_state(oo_.steady_state, M_, options_, oo_, true);
oo_.endo_simul(:, end) = oo_.steady_state;
@ -122,7 +122,7 @@ oo_.exo_simul = [ saved_exo; oo_.exo_simul ];
// 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_steady_state = (1.1+0.1)*0.75;
oo_.exo_simul(end, 1) = oo_.exo_steady_state;
oo_.steady_state = evaluate_steady_state(oo_.steady_state, M_, options_, oo_, true);
oo_.endo_simul(:, end) = oo_.steady_state;