New option “from_initval_to_endval” to “homotopy_setup” block

kalman-mex
Sébastien Villemot 2023-10-06 17:45:14 -04:00
parent 6b44e08daa
commit 2e3fbfc040
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
6 changed files with 51 additions and 4 deletions

View File

@ -3101,6 +3101,7 @@ After computation, the steady state is available in the following variable:
been computed with ``steady``, it will first try to compute it.
.. block:: homotopy_setup ;
homotopy_setup(from_initval_to_endval) ;
This block is used to declare initial and final values when using
a homotopy method. It is used in conjunction with the option
@ -3129,12 +3130,26 @@ After computation, the steady state is available in the following variable:
Here only the final value is specified for a given
parameter/exogenous; the initial value is taken from the
preceeding ``initval`` block.
preceeding ``initval`` block (or from the preceeding ``endval`` block if
there is one before the ``homotopy_setup`` block).
A necessary condition for a successful homotopy is that Dynare
must be able to solve the steady state for the initial
parameters/exogenous without additional help (using the guess
values given in the ``initval`` block).
values given in the ``initval`` or ``endval`` block).
The ``from_initval_to_endval`` option can be used in the context of a
permanent shock, when the initial steady state has already been computed.
This option can be used following the ``endval`` block that describes the
terminal steady state. In that case, in the subsequent ``steady`` command,
Dynare will perform a homotopy from the initial to the terminal steady
state (technically, using this option is equivalent to writing a
``homotopy_setup`` block where all exogenous variables are asked to
transition from their values in the ``initval`` to their values in the
``endval`` block). When this option is used, the ``homotopy_setup`` block
is typically empty (but its nevertheless possible to add explicit
directives for moving exogenous or parameters; these will be added on top
of those implicitly generated by the ``from_initval_to_endval`` option).
If the homotopy fails, a possible solution is to increase the
number of steps (given in ``homotopy_steps`` option of

View File

@ -28,7 +28,7 @@ function steady()
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
global M_ oo_ options_
global M_ oo_ options_ ex0_
test_for_deep_parameters_calibration(M_);
@ -62,6 +62,18 @@ if options_.homotopy_mode ~= 0
error('HOMOTOPY_SETUP: incorrect variable types specified')
end
% If the “from_initval_to_endval” option was passed to the “homotopy_setup” block, add the relevant homotopy information
if options_.homotopy_from_initval_to_endval
if isempty(ex0_)
error('HOMOTOPY_SETUP: the from_initval_to_endval option cannot be used without an endval block')
end
for i = 1:M_.exo_nbr
if ~any(hv(:,1)==1 & hv(:,2)==i) % Do not overwrite information manually specified by the user
hv = vertcat(hv, [ 1 i ex0_(i) oo_.exo_steady_state(i)]);
end
end
end
homotopy_func = str2func(['homotopy' num2str(options_.homotopy_mode)]);
[M_,oo_,errorcode] = homotopy_func(hv, options_.homotopy_steps, M_, options_, oo_);

View File

@ -1062,6 +1062,8 @@ mod_and_m_tests = [
'extra' : [ 'steady_state/homotopy/common.mod' ] },
{ 'test' : [ 'steady_state/homotopy/homotopy3_test.mod' ],
'extra' : [ 'steady_state/homotopy/common.mod' ] },
{ 'test' : [ 'steady_state/homotopy/homotopy_from_initval_to_endval.mod' ],
'extra' : [ 'steady_state/homotopy/common.mod' ] },
{ 'test' : [ 'bvar_a_la_sims/bvar_standalone.mod' ],
'extra' : [ 'bvar_a_la_sims/bvar_sample.m' ] },
{ 'test' : [ 'bvar_a_la_sims/bvar_and_dsge.mod' ],

@ -1 +1 @@
Subproject commit 86b24dc9bf1c8fa5738f084e3cfac54d5523ca56
Subproject commit 084372a314a5f3081dc055ba83dd879947809576

View File

@ -19,11 +19,26 @@ k = ((delt+bet)/(aa*x*alph))^(1/(alph-1));
c = aa*x*k^alph-delt*k;
end;
@#ifdef homotopy_from_initval_to_endval
steady;
endval;
x = 2;
end;
homotopy_setup(from_initval_to_endval);
end;
@#else
homotopy_setup;
bet, 0.05, 0.1;
x, 2;
end;
@#endif
steady(homotopy_mode = @{homotopy_mode}, homotopy_steps = 50);
if abs(oo_.steady_state(1)/(aa*oo_.exo_steady_state(1)*oo_.steady_state(2)^alph-delt*oo_.steady_state(2)) - 1) > 1e-4

View File

@ -0,0 +1,3 @@
@#define homotopy_from_initval_to_endval
@#define homotopy_mode = 3
@#include "common.mod"