diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 4fe506aeb97c1c1a60c41fe98ef157f9b6f97952..0c41bd2b557aef421805b0ca6a69bcbf454b7891 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -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...); diff --git a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m index 4664d627d15e1a31dc7a7d526658f144803b242a..2e7ad0b599ec1edce32361d8a2cd2817f030b3fa 100644 --- a/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m +++ b/matlab/perfect-foresight-models/perfect_foresight_with_expectation_errors_setup.m @@ -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); diff --git a/preprocessor b/preprocessor index 8c07fb5e4310b2ec2988dc62256e1cf0971c05dd..3a820fffa2f7291be5732c33bde552526eab1602 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 8c07fb5e4310b2ec2988dc62256e1cf0971c05dd +Subproject commit 3a820fffa2f7291be5732c33bde552526eab1602 diff --git a/tests/deterministic_simulations/pfwee_learnt_in.mod b/tests/deterministic_simulations/pfwee_learnt_in.mod index 878beb00b7c6b859cc0de7ac76010c354fbdf427..5c7e396ddb5157ada410bbdcc9ea5091baa8dc40 100644 --- a/tests/deterministic_simulations/pfwee_learnt_in.mod +++ b/tests/deterministic_simulations/pfwee_learnt_in.mod @@ -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;