From 12cd217edfd1c1f329e04a5e39df68132305aa08 Mon Sep 17 00:00:00 2001 From: Johannes Pfeifer Date: Thu, 12 Aug 2021 21:06:00 +0200 Subject: [PATCH] Occbin: add documentation --- doc/manual/source/bibliography.rst | 3 + doc/manual/source/the-model-file.rst | 380 ++++++++++++++++++++++++++- 2 files changed, 381 insertions(+), 2 deletions(-) diff --git a/doc/manual/source/bibliography.rst b/doc/manual/source/bibliography.rst index a82d01559..eb3ecb5e3 100644 --- a/doc/manual/source/bibliography.rst +++ b/doc/manual/source/bibliography.rst @@ -23,6 +23,7 @@ Bibliography * Collard, Fabrice and Michel Juillard (2001a): “Accuracy of stochastic perturbation methods: The case of asset pricing models,” *Journal of Economic Dynamics and Control*, 25, 979–999. * Collard, Fabrice and Michel Juillard (2001b): “A Higher-Order Taylor Expansion Approach to Simulation of Stochastic Forward-Looking Models with an Application to a Non-Linear Phillips Curve,” *Computational Economics*, 17, 125–139. * Corana, Angelo, M. Marchesi, Claudio Martini, and Sandro Ridella (1987): “Minimizing multimodal functions of continuous variables with the “simulated annealing” algorithm”, *ACM Transactions on Mathematical Software*, 13(3), 262–280. +* Cuba-Borda, Pablo, Luca Guerrieri, and Matteo Iacoviello (2019): "Likelihood evaluation of models with occasionally binding constraints", Journal of Applied Econometrics, 34(7), 1073-1085 * Del Negro, Marco and Frank Schorfheide (2004): “Priors from General Equilibrium Models for VARs”, *International Economic Review*, 45(2), 643–673. * Dennis, Richard (2007): “Optimal Policy In Rational Expectations Models: New Solution Algorithms”, *Macroeconomic Dynamics*, 11(1), 31–55. * Duffie, Darrel and Kenneth J. Singleton (1993): “Simulated Moments Estimation of Markov Models of Asset Prices”, *Econometrica*, 61(4), 929-952. @@ -34,7 +35,9 @@ Bibliography * Ferris, Michael C. and Todd S. Munson (1999): “Interfaces to PATH 3.0: Design, Implementation and Usage”, *Computational Optimization and Applications*, 12(1), 207–227. * Geweke, John (1992): “Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments,” in J.O. Berger, J.M. Bernardo, A.P. Dawid, and A.F.M. Smith (eds.) Proceedings of the Fourth Valencia International Meeting on Bayesian Statistics, pp. 169–194, Oxford University Press. * Geweke, John (1999): “Using simulation methods for Bayesian econometric models: Inference, development and communication,” *Econometric Reviews*, 18(1), 1–73. +* Giovannini, Massimo, Philipp Pfeiffer, and Marco Ratto (2021), “Efficient and robust inference of models with occasionally binding constraints,” Working Papers 2021-03, Joint Research Centre, European Commission * Giordani, Paolo, Michael Pitt, and Robert Kohn (2011): “Bayesian Inference for Time Series State Space Models” in: *The Oxford Handbook of Bayesian Econometrics*, ed. by John Geweke, Gary Koop, and Herman van Dijk, Oxford University Press, 61–124. +* Guerrieri, Luca and Matteo Iacoviello (2015): “OccBin: A toolkit for solving dynamic models with occasionally binding constraints easily,” *Journal of Monetary Economics*, 70, 22–38. * Goffe, William L., Gary D. Ferrier, and John Rogers (1994): “Global Optimization of Statistical Functions with Simulated Annealing,” *Journal of Econometrics*, 60(1/2), 65–100. * Hansen, Lars P. (1982): “Large sample properties of generalized method of moments estimators,” Econometrica, 50(4), 1029–1054. * Hansen, Nikolaus and Stefan Kern (2004): “Evaluating the CMA Evolution Strategy on Multimodal Test Functions”. In: *Eighth International Conference on Parallel Problem Solving from Nature PPSN VIII*, Proceedings, Berlin: Springer, 282–291. diff --git a/doc/manual/source/the-model-file.rst b/doc/manual/source/the-model-file.rst index 6308ab26b..a13e12312 100644 --- a/doc/manual/source/the-model-file.rst +++ b/doc/manual/source/the-model-file.rst @@ -4069,7 +4069,7 @@ Computing the stochastic solution Triggers the computation and display of the theoretical spectral density of the (filtered) model variables. Results are - stored in ´´oo_.SpectralDensity´´, defined below. Default: do + stored in ``oo_.SpectralDensity``, defined below. Default: do not request spectral density estimates. .. option:: hp_ngrid = INTEGER @@ -4621,7 +4621,383 @@ multidimensional indices of state variables, in such a way that symmetric elements are never repeated (for more details, see the description of ``oo_.dr.g_3`` in the third-order case). +Occasionally binding constraints (OCCBIN) +============== +Dynare allows simulating models with up to two occasionally-binding constraints by +relying on a piecewise linear solution as in *Guerrieri and Iacoviello (2015)*. +It also allows estimating such models employing either the inversion filter of +*Cuba-Borda, Guerrieri, and Iacoviello (2019)* or the piecewise Kalman filter of +*Giovannini, Pfeiffer, and Ratto (2021)*. To trigger computations involving +occasionally-binding constraints requires + +#. defining and naming the occasionally-binding constraints using an ``occbin_constraints``-block +#. specifying the model equations for the respective regimes in the ``model``-block using appropriate equation tags. +#. potentially specifying a sequence of surprise shocks using a ``shocks(surprise)``-block +#. setting up Occbin simulations or estimation with ``occbin_setup`` +#. triggering a simulation with ``occbin_solver`` or running ``estimation`` or ``calib_smoother``. + +All of these elements are discussed in the following. + + +.. block:: occbin_constraints ; + + |br| The ``occbin_constraints``-block specifies the occasionally-binding constraints. It contains + one or two of the following lines: + + name 'STRING'; bind EXPRESSION; [relax EXPRESSION;] [error_bind EXPRESSION;] [error_relax EXPRESSION;] + + ``STRING`` is the name of constraint that is used to reference the constraint in ``relax/bind`` + equation-tags to identify the respective regime (see below). The ``bind``-expresssion is mandatory and defines + a logical condition that is evaluated in the baseline (non-binding) regime to check whether the + constraint becomes binding. In contrast, the ``relax``-expression is optional and specifies a + logical condition that is evaluated in the binding regime to check whether the regime returns + to the baseline non-binding state. If not specified, Dynare will simply check in the binding + regime whether the ``bind``-expression evaluates to false. However, there are cases + where the ``bind``-expression cannot be evaluated in the binding regime(s), because + the variables involved are constant by definition so that e.g. the value of the Lagrange + multiplier on the complementary slackness condition needs to be checked. In these cases, + it is necessary to provide an explicit condition that can be evaluated in the binding + regime that allows to check whether it should be left. + + Three things are important to keep in mind when specifying the expressions. + First, feasible expressions may only contain contemporaneous endogenous variables. + If you want to include leads/lags or exogenous variables, you need to define + an auxiliary variable. Second, Dynare will at the current stage not linearly + approximate the entered expressions. Because Occbin will work with a linearized + model, consistency will often require the user to enter a linearized constraint. + Otherwise, the condition employed for checking constraint violations may differ + from the one employed within model simulations based on the piecewise-linear + model solution. Third, in contrast to the original Occbin replication codes, the + variables used in expressions are not automatically demeaned, i.e. they refer to + the levels, not deviations from the steady state. To access the steady state + level of a variable, the ``STEADY_STATE()``-operator can be used. + + The ``error_bind`` and ``error_relax``-options are optional and allow specifying + numerical criteria for the size of the respective constraint violations employed + in numerical routines. By default, Dynare will simply use the absolute value of + the ``bind`` and ``relax`` inequalities. But occasionnally, user-specified + expressions perform better. + + *Example* + + :: + + occbin_constraints; + name 'IRR'; bind log_Invest-log(steady_state(Invest))`. + + .. option:: simul_maxit = INTEGER + + See :opt:`simul_maxit `. + + .. option:: simul_check_ahead_periods = INTEGER + + See :opt:`simul_check_ahead_periods `. + + .. option:: simul_curb_retrench + + See :opt:`simul_curb_retrench`. + + .. option:: simul_debug + + See :opt:`simul_debug`. + + *Output* + + The command outputs various objects into ``oo_.occbin``. + +.. matvar:: oo_.occbin.piecewise + + |br| Matrix storing the simulations based on the piecewise-linear solution. + The variables are arranged column by column, in order of declaration (as in + ``M_.endo_names``), while the the rows correspond to the ``simul_periods``. + +.. matvar:: oo_.occbin.linear + + |br| Matrix storing the simulations based on the linear solution, i.e. ignoring + the occasionally binding constraint(s). The variables are arranged column by column, + in order of declaration (as in ``M_.endo_names``), while the the rows correspond to + the ``simul_periods``. + +.. matvar:: oo_.occbin.shocks_sequence + + |br| Matrix storing the shock sequence employed during the simulation. The shocks are arranged + column by column, with their order in ``M_.exo_names`` stored in ``oo_.occbin.exo_pos``. The + the rows correspond to the number of shock periods specified in a `surprise(shocks)`-block, which + may be smaller than ``simul_periods``. + +.. matvar:: oo_.occbin.regime_history + + |br| Structure storing information on the regime history, conditional on the shock that + happened in the respective period (stored along the rows). The subfield ``regime`` contains + a vector storing the regime state, while the the subfield ``regimestart`` indicates the + expected start of the respective regime state. For example, if row 40 contains ``[1,0]`` for + ``regime2`` and ``[1,6]`` for ``regimestart2``, it indicates that - after the shock in period 40 + has occurred - the second constraint became binding (1) and is expected to revert to non-binding (0) six periods + later. + +.. matvar:: oo_.occbin.ys + + |br| Vector of steady state values + +.. command:: occbin_graph [VARIABLE_NAME...]; + occbin_graph (OPTIONS...) [VARIABLE_NAME...]; + + |br| Plots a graph comparing the simulation results of the piecewise-linear solution + with the occasionally binding contraints to the linear solution ignoring the constraint. + + *Options* + + .. option:: noconstant + + Omit the steady state in the graphs. + +.. command:: occbin_write_regimes ; + occbin_write_regimes (OPTIONS...); + + |br| Write the information on the regime history stored in ``oo_.occbin.regime_history`` + into an Excel file stored in the ``FILENAME/Output``-folder. + + *Options* + + .. option:: periods = INTEGER + + Number of periods for which to write the expected regime durations. Default: write all + available periods. + + .. option:: filename = FILENAME + + Name of the Excel-file to write. Default: ``FILENAME_occbin_regimes``. + + .. _estim: Estimation based on likelihood @@ -7351,7 +7727,7 @@ block decomposition of the model (see :opt:`block`). ``VarianceDecompositionME`` Same as `VarianceDecomposition`_, but contains - theh decomposition of the measured as opposed to the + the decomposition of the measured as opposed to the actual variable. The joint contribution of the measurement error will be saved in a field named ``ME``.