Merge remote-tracking branch 'community/master' into enterprise
commit
43ed7b2b69
|
@ -40,6 +40,7 @@ checksum
|
|||
|
||||
# Make Check Rules
|
||||
*.trs
|
||||
*.tls
|
||||
|
||||
# Doc rules
|
||||
*.pdf
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
TERM: linux
|
||||
MATLAB_VERSION: R2020a
|
||||
OLD_MATLAB_VERSION: R2009b
|
||||
|
||||
# The next stanza creates the version number used for the source tarball and the
|
||||
# binary packages. Here are the following possible cases:
|
||||
|
@ -10,15 +12,11 @@ variables:
|
|||
# + if on master: use enterprise-unstable-$TIMESTAMP-$COMMIT
|
||||
# + on another branch: use $BRANCH-$TIMESTAMP-$COMMIT
|
||||
# - if in a personal repository: use $USER-$TIMESTAMP-$COMMIT
|
||||
#
|
||||
# Also sets the path and version of the default MATLAB installation.
|
||||
before_script:
|
||||
- '[[ -z $VERSION ]] && [[ $CI_PROJECT_NAMESPACE == Enterprise ]] && [[ -n $CI_COMMIT_TAG ]] && export VERSION=$CI_COMMIT_TAG'
|
||||
- '[[ -z $VERSION ]] && [[ $CI_PROJECT_NAMESPACE == Enterprise ]] && [[ $CI_COMMIT_REF_NAME == enterprise ]] && export VERSION=enterprise-unstable-$(date +%F-%H%M)-$CI_COMMIT_SHORT_SHA'
|
||||
- '[[ -z $VERSION ]] && [[ $CI_PROJECT_NAMESPACE == Enterprise ]] && export VERSION=$CI_COMMIT_REF_NAME-$(date +%F-%H%M)-$CI_COMMIT_SHORT_SHA'
|
||||
- '[[ -z $VERSION ]] && export VERSION=$CI_PROJECT_NAMESPACE-$(date +%F-%H%M)-$CI_COMMIT_SHORT_SHA'
|
||||
- 'export MATLAB_PATH=$(dirname $(dirname $(readlink -f $(which matlab))))'
|
||||
- 'export MATLAB_VERSION=$(echo version | matlab -nodesktop -nodisplay -nosplash 2>/dev/null | sed -En "/ans\ =/!d;n;n;s/^[^0-9]*([0-9]+\.[0-9]+).*$/\1/;p")'
|
||||
|
||||
stages:
|
||||
- build
|
||||
|
@ -29,7 +27,7 @@ build_binaries:
|
|||
stage: build
|
||||
script:
|
||||
- autoreconf -si
|
||||
- ./configure --with-matlab=$MATLAB_PATH MATLAB_VERSION=$MATLAB_VERSION PACKAGE_VERSION=$VERSION PACKAGE_STRING="dynare $VERSION"
|
||||
- ./configure --with-matlab=/usr/local/MATLAB/$MATLAB_VERSION MATLAB_VERSION=$MATLAB_VERSION PACKAGE_VERSION=$VERSION PACKAGE_STRING="dynare $VERSION"
|
||||
- make -j $(nproc) LN_S="cp -p"
|
||||
artifacts:
|
||||
paths:
|
||||
|
@ -68,9 +66,10 @@ build_doc:
|
|||
pkg_source:
|
||||
stage: test_and_pkg
|
||||
script:
|
||||
- rm doc/manual/source/_static/mathjax && sed -i "/^mathjax_path *=/d" doc/manual/source/conf.py
|
||||
- 'for f in configure.ac preprocessor/configure.ac mex/build/matlab/configure.ac mex/build/octave/configure.ac; do sed -i "s/^AC_INIT(\[\(.*\)\],\s*\[\(.*\)\])/AC_INIT([\1], [$VERSION])/" $f; done'
|
||||
- autoreconf -si
|
||||
- ./configure --with-matlab=$MATLAB_PATH MATLAB_VERSION=$MATLAB_VERSION
|
||||
- ./configure --with-matlab=/usr/local/MATLAB/$MATLAB_VERSION MATLAB_VERSION=$MATLAB_VERSION
|
||||
- make dist
|
||||
artifacts:
|
||||
paths:
|
||||
|
@ -142,14 +141,14 @@ test_matlab:
|
|||
extends: .test_matlab_template
|
||||
script:
|
||||
- autoreconf -si
|
||||
- ./configure --disable-octave --with-matlab=$MATLAB_PATH MATLAB_VERSION=$MATLAB_VERSION
|
||||
- ./configure --disable-octave --with-matlab=/usr/local/MATLAB/$MATLAB_VERSION MATLAB_VERSION=$MATLAB_VERSION
|
||||
- make -j $(($(nproc) * 3 / 4)) -C tests check-matlab
|
||||
|
||||
test_old_matlab:
|
||||
extends: .test_matlab_template
|
||||
script:
|
||||
- autoreconf -si
|
||||
- ./configure --disable-octave --with-matlab=/usr/local/MATLAB/R2009b MATLAB_VERSION=R2009b
|
||||
- ./configure --disable-octave --with-matlab=/usr/local/MATLAB/$OLD_MATLAB_VERSION MATLAB_VERSION=$OLD_MATLAB_VERSION
|
||||
- make -C mex/build/matlab clean
|
||||
- make -j $(nproc) -C mex/build/matlab
|
||||
- make -j $(($(nproc) * 3 / 4)) -C tests check-matlab
|
||||
|
|
10
Makefile.am
10
Makefile.am
|
@ -16,7 +16,7 @@ ACLOCAL_AMFLAGS = -I m4
|
|||
EXTRA_DIST = \
|
||||
matlab \
|
||||
contrib \
|
||||
NEWS \
|
||||
NEWS.md \
|
||||
license.txt \
|
||||
README.md \
|
||||
COPYING \
|
||||
|
@ -34,9 +34,10 @@ all-local: preprocessor/src/dynare_m$(EXEEXT)
|
|||
ARCH="32"; \
|
||||
fi; \
|
||||
mkdir -p $(abs_srcdir)/matlab/preprocessor$$ARCH && \
|
||||
$(LN_S) -f $(abs_builddir)/preprocessor/src/dynare_m$(EXEEXT) $(abs_srcdir)/matlab/preprocessor$$ARCH && \
|
||||
mkdir -p $(abs_srcdir)/julia/preprocessor$$ARCH && \
|
||||
$(LN_S) -f $(abs_builddir)/preprocessor/src/dynare_m$(EXEEXT) $(abs_srcdir)/julia/preprocessor$$ARCH
|
||||
$(LN_S) -f $(abs_builddir)/preprocessor/src/dynare_m$(EXEEXT) $(abs_srcdir)/matlab/preprocessor$$ARCH
|
||||
|
||||
clean-local:
|
||||
rm -rf $(abs_srcdir)/matlab/preprocessor32 $(abs_srcdir)/matlab/preprocessor64
|
||||
|
||||
dist-hook:
|
||||
rm -rf `find $(distdir)/matlab $(distdir)/examples -name *~`
|
||||
|
@ -62,5 +63,4 @@ install-exec-local:
|
|||
cp preprocessor/src/dynare_m $(DESTDIR)$(pkglibdir)/matlab/preprocessor$$ARCH
|
||||
|
||||
uninstall-local:
|
||||
rm -f $(DESTDIR)$(bindir)/dynare++
|
||||
rm -rf $(DESTDIR)$(pkglibdir)
|
||||
|
|
999
NEWS → NEWS.md
999
NEWS → NEWS.md
File diff suppressed because it is too large
Load Diff
20
README.md
20
README.md
|
@ -234,7 +234,7 @@ All the prerequisites are packaged:
|
|||
- `texlive-fonts-extra` (for ccicons)
|
||||
- `texlive-latex-recommended`
|
||||
- `texlive-science` (for amstex)
|
||||
- `texlive-generic-extra` (for Sphinx)
|
||||
- `texlive-plain-generic`
|
||||
- `lmodern` (for macroprocessor PDF)
|
||||
- `python3-sphinx`
|
||||
- `latexmk`
|
||||
|
@ -243,7 +243,7 @@ All the prerequisites are packaged:
|
|||
|
||||
You can install them all at once with:
|
||||
```
|
||||
apt install build-essential gfortran liboctave-dev libboost-graph-dev libgsl-dev libmatio-dev libslicot-dev libslicot-pic libsuitesparse-dev flex bison autoconf automake texlive texlive-publishers texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-generic-extra lmodern python3-sphinx latexmk libjs-mathjax doxygen
|
||||
apt install build-essential gfortran liboctave-dev libboost-graph-dev libgsl-dev libmatio-dev libslicot-dev libslicot-pic libsuitesparse-dev flex bison autoconf automake texlive texlive-publishers texlive-latex-extra texlive-fonts-extra texlive-latex-recommended texlive-science texlive-plain-generic lmodern python3-sphinx latexmk libjs-mathjax doxygen
|
||||
```
|
||||
|
||||
## Windows
|
||||
|
@ -262,30 +262,32 @@ pacman -Syu
|
|||
```
|
||||
pacman -S git autoconf automake-wrapper bison flex make tar texinfo mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-fortran mingw-w64-x86_64-boost mingw-w64-x86_64-gsl mingw-w64-x86_64-matio mingw-w64-x86_64-openblas
|
||||
```
|
||||
- **(Optional)** compile and install SLICOT, needed for the `kalman_steady_state`
|
||||
MEX file
|
||||
- Compile and install SLICOT, needed for the `kalman_steady_state` MEX file
|
||||
```
|
||||
wget https://deb.debian.org/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz
|
||||
tar xf slicot_5.0+20101122.orig.tar.gz
|
||||
cd slicot-5.0+20101122
|
||||
make FORTRAN=gfortran OPTS="-O2 -fno-underscoring -fdefault-integer-8" LOADER=gfortran slicot.a
|
||||
make FORTRAN=gfortran OPTS="-O2 -fno-underscoring -fdefault-integer-8" LOADER=gfortran lib
|
||||
mkdir -p /usr/local/lib
|
||||
cp slicot.a /usr/local/lib/libslicot64_pic.a
|
||||
cd ..
|
||||
```
|
||||
- Clone and prepare the Dynare sources:
|
||||
- Prepare the Dynare sources, either by unpacking the source tarball, or with:
|
||||
```
|
||||
git clone --recurse-submodules https://git.dynare.org/Dynare/dynare.git
|
||||
cd dynare
|
||||
autoreconf -si
|
||||
```
|
||||
- Configure Dynare:
|
||||
- Configure Dynare from the source directory:
|
||||
```
|
||||
./configure --with-slicot=/usr/local --with-matlab=<…> MATLAB_VERSION=<…> --disable-octave
|
||||
./configure --with-slicot=/usr/local --with-matlab=<…> MATLAB_VERSION=<…> --disable-octave --disable-doc
|
||||
```
|
||||
where the path and version of MATLAB are specified. Note that you should use
|
||||
the MSYS2 notation and not put spaces in the MATLAB path, so you probably want
|
||||
to use something like `/c/Progra~1/MATLAB/…`.
|
||||
to use something like `/c/Progra~1/MATLAB/…`. Alternatively, if your filesystem
|
||||
does not have short filenames (8dot3), then you can run `mkdir -p
|
||||
/usr/local/MATLAB && mount c:/Program\ Files/MATLAB /usr/local/MATLAB`, and
|
||||
then pass `/usr/local/MATLAB/…` as MATLAB path to the configure script.
|
||||
- Compile:
|
||||
```
|
||||
make
|
||||
|
|
|
@ -18,7 +18,7 @@ dnl You should have received a copy of the GNU General Public License
|
|||
dnl along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_PREREQ([2.62])
|
||||
AC_INIT([dynare], [4.6-unstable])
|
||||
AC_INIT([dynare], [4.7-unstable])
|
||||
AC_CONFIG_SRCDIR([preprocessor/src/DynareMain.cc])
|
||||
AM_INIT_AUTOMAKE([1.11 -Wall -Wno-portability foreign no-dist-gzip dist-xz tar-pax])
|
||||
|
||||
|
|
|
@ -16,3 +16,4 @@ build/latex/dynare-manual.pdf: $(SRC) source/conf.py
|
|||
|
||||
clean-local:
|
||||
rm -rf build
|
||||
rm -rf utils/__pycache__
|
||||
|
|
|
@ -44,6 +44,7 @@ Bibliography
|
|||
* Kim, Jinill and Sunghyun Kim (2003): “Spurious welfare reversals in international business cycle models,” *Journal of International Economics*, 60, 471–500.
|
||||
* Kanzow, Christian and Stefania Petra (2004): “On a semismooth least squares formulation of complementarity problems with gap reduction,” *Optimization Methods and Software*, 19, 507–525.
|
||||
* Kim, Jinill, Sunghyun Kim, Ernst Schaumburg, and Christopher A. Sims (2008): “Calculating and using second-order accurate solutions of discrete time dynamic equilibrium models,” *Journal of Economic Dynamics and Control*, 32(11), 3397–3414.
|
||||
* Komunjer, Ivana and Ng, Serena (2011): ”Dynamic identification of dynamic stochastic general equilibrium models”, *Econometrica*, 79, 1995–2032.
|
||||
* Koop, Gary (2003), *Bayesian Econometrics*, John Wiley & Sons.
|
||||
* Koopman, S. J. and J. Durbin (2000): “Fast Filtering and Smoothing for Multivariate State Space Models,” *Journal of Time Series Analysis*, 21(3), 281–296.
|
||||
* Koopman, S. J. and J. Durbin (2003): “Filtering and Smoothing of State Vector for Diffuse State Space Models,” *Journal of Time Series Analysis*, 24(1), 85–98.
|
||||
|
@ -52,13 +53,16 @@ Bibliography
|
|||
* Liu, Jane and Mike West (2001): “Combined parameter and state estimation in simulation-based filtering”, in *Sequential Monte Carlo Methods in Practice*, Eds. Doucet, Freitas and Gordon, Springer Verlag.
|
||||
* Lubik, Thomas and Frank Schorfheide (2007): “Do Central Banks Respond to Exchange Rate Movements? A Structural Investigation,” *Journal of Monetary Economics*, 54(4), 1069–1087.
|
||||
* Murray, Lawrence M., Emlyn M. Jones and John Parslow (2013): “On Disturbance State-Space Models and the Particle Marginal Metropolis-Hastings Sampler”, *SIAM/ASA Journal on Uncertainty Quantification*, 1, 494–521.
|
||||
* Mutschler, Willi (2015): “Identification of DSGE models - The effect of higher-order approximation and pruning“, *Journal of Economic Dynamics & Control*, 56, 34-54.
|
||||
* Pearlman, Joseph, David Currie, and Paul Levine (1986): “Rational expectations models with partial information,” *Economic Modelling*, 3(2), 90–105.
|
||||
* Planas, Christophe, Marco Ratto and Alessandro Rossi (2015): “Slice sampling in Bayesian estimation of DSGE models”.
|
||||
* Pfeifer, Johannes (2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models”.
|
||||
* Pfeifer, Johannes (2014): “An Introduction to Graphs in Dynare”.
|
||||
* Qu, Zhongjun and Tkachenko, Denis (2012): “Identification and frequency domain quasi-maximum likelihood estimation of linearized dynamic stochastic general equilibrium models“, *Quantitative Economics*, 3, 95–132.
|
||||
* Rabanal, Pau and Juan Rubio-Ramirez (2003): “Comparing New Keynesian Models of the Business Cycle: A Bayesian Approach,” Federal Reserve of Atlanta, *Working Paper Series*, 2003-30.
|
||||
* Raftery, Adrian E. and Steven Lewis (1992): “How many iterations in the Gibbs sampler?,” in *Bayesian Statistics, Vol. 4*, ed. J.O. Berger, J.M. Bernardo, A.P. * Dawid, and A.F.M. Smith, Clarendon Press: Oxford, pp. 763-773.
|
||||
* Ratto, Marco (2008): “Analysing DSGE models with global sensitivity analysis”, *Computational Economics*, 31, 115–139.
|
||||
* Ratto, Marco and Iskrev, Nikolay (2011): “Identification Analysis of DSGE Models with DYNARE.“, *MONFISPOL* 225149.
|
||||
* Schorfheide, Frank (2000): “Loss Function-based evaluation of DSGE models,” *Journal of Applied Econometrics*, 15(6), 645–670.
|
||||
* Schmitt-Grohé, Stephanie and Martin Uríbe (2004): “Solving Dynamic General Equilibrium Models Using a Second-Order Approximation to the Policy Function,” *Journal of Economic Dynamics and Control*, 28(4), 755–775.
|
||||
* Schnabel, Robert B. and Elizabeth Eskow (1990): “A new modified Cholesky algorithm,” *SIAM Journal of Scientific and Statistical Computing*, 11, 1136–1158.
|
||||
|
@ -68,6 +72,3 @@ Bibliography
|
|||
* Stock, James H. and Mark W. Watson (1999). “Forecasting Inflation,”, *Journal of Monetary Economics*, 44(2), 293–335.
|
||||
* Uhlig, Harald (2001): “A Toolkit for Analysing Nonlinear Dynamic Stochastic Models Easily,” in *Computational Methods for the Study of Dynamic Economies*, Eds. Ramon Marimon and Andrew Scott, Oxford University Press, 30–61.
|
||||
* Villemot, Sébastien (2011): “Solving rational expectations models at first order: what Dynare does,” *Dynare Working Papers*, 2, CEPREMAP.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (C) 2018-2019 Dynare Team
|
||||
# Copyright (C) 2018-2020 Dynare Team
|
||||
#
|
||||
# This file is part of Dynare.
|
||||
#
|
||||
|
@ -36,7 +36,7 @@ mathjax_path = 'mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
|
|||
master_doc = 'index'
|
||||
|
||||
project = u'Dynare'
|
||||
copyright = u'2019, Dynare Team'
|
||||
copyright = u'2020, Dynare Team'
|
||||
author = u'Dynare Team'
|
||||
|
||||
add_function_parentheses = False
|
||||
|
@ -77,6 +77,7 @@ latex_elements = {
|
|||
warningBorderColor={RGB}{255,50,50},OuterLinkColor={RGB}{34,139,34}, \
|
||||
InnerLinkColor={RGB}{51,51,255},TitleColor={RGB}{51,51,255}',
|
||||
'papersize': 'a4paper',
|
||||
'preamble': r'\DeclareUnicodeCharacter{200B}{}', # Part of the workaround for #1707
|
||||
}
|
||||
|
||||
latex_documents = [
|
||||
|
|
|
@ -167,24 +167,26 @@ Dynare misc commands
|
|||
|
||||
A ``1*Nblck`` array of doubles. Current acceptance ratios.
|
||||
|
||||
.. matcomm:: prior [options[, ...]];
|
||||
.. matcomm:: prior [OPTIONS[, ...]];
|
||||
|
||||
Prints various informations about the prior distribution depending
|
||||
on the options. If no options are provided, the command returns
|
||||
the list of available options. Following options are available:
|
||||
Prints information about the prior distribution given the provided
|
||||
options. If no options are provided, the command returns the list of
|
||||
available options.
|
||||
|
||||
``table``
|
||||
*Options*
|
||||
|
||||
.. option:: table
|
||||
|
||||
Prints a table describing the marginal prior distributions
|
||||
(mean, mode, std., lower and upper bounds, HPD interval).
|
||||
|
||||
``moments``
|
||||
.. option:: moments
|
||||
|
||||
Computes and displays first and second order moments of the
|
||||
endogenous variables at the prior mode (considering the
|
||||
linearized version of the model).
|
||||
|
||||
``moments(distribution)``
|
||||
.. option:: moments(distribution)
|
||||
|
||||
Computes and displays the prior mean and prior standard
|
||||
deviation of the first and second moments of the endogenous
|
||||
|
@ -193,7 +195,7 @@ Dynare misc commands
|
|||
stored in the ``prior`` subfolder in a
|
||||
``_endogenous_variables_prior_draws.mat`` file.
|
||||
|
||||
``optimize``
|
||||
.. option:: optimize
|
||||
|
||||
Optimizes the prior density (starting from a random initial
|
||||
guess). The parameters such that the steady state does not
|
||||
|
@ -203,7 +205,7 @@ Dynare misc commands
|
|||
defined over such regions, the optimization algorithm may fail
|
||||
to converge to the true solution (the prior mode).
|
||||
|
||||
``simulate``
|
||||
.. option:: simulate
|
||||
|
||||
Computes the effective prior mass using a Monte-Carlo. Ideally
|
||||
the effective prior mass should be equal to 1, otherwise
|
||||
|
@ -215,6 +217,6 @@ Dynare misc commands
|
|||
:math:`p_A\neq p_B \leq 1` so that the prior mass of the
|
||||
compared models are identical.
|
||||
|
||||
``plot``
|
||||
.. option:: plot
|
||||
|
||||
Plots the marginal prior density.
|
||||
|
|
|
@ -56,3 +56,9 @@ description, please refer to the comments inside the files themselves.
|
|||
Baseline New Keynesian Model estimated in *Fernández-Villaverde
|
||||
(2010)*. It demonstrates how to use an explicit steady state file
|
||||
to update parameters and call a numerical solver.
|
||||
|
||||
``Ramsey_Example.mod``
|
||||
|
||||
File demonstrating how to conduct optimal policy experiments in a
|
||||
simple New Keynesian model either under commitment (Ramsey) or using
|
||||
optimal simple rules (OSR)
|
|
@ -25,7 +25,7 @@ The following people used to be members of the team:
|
|||
* Stéphane Lhuissier
|
||||
* George Perendia
|
||||
|
||||
Copyright © 1996-2019, Dynare Team.
|
||||
Copyright © 1996-2020, Dynare Team.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ Installation and configuration
|
|||
Software requirements
|
||||
=====================
|
||||
|
||||
Packaged versions of Dynare are available for Windows 7/8/10, several GNU/Linux
|
||||
Packaged versions of Dynare are available for Windows (7, 8.1, 10), several GNU/Linux
|
||||
distributions (Debian, Ubuntu, Linux Mint, Arch Linux) and macOS
|
||||
10.11 or later. Dynare should work on other systems, but some compilation steps
|
||||
are necessary in that case.
|
||||
|
@ -15,7 +15,10 @@ are necessary in that case.
|
|||
In order to run Dynare, you need one of the following:
|
||||
|
||||
* MATLAB version 7.9 (R2009b) or above;
|
||||
* Octave version 4.2.1 or above, with the statistics package from `Octave-Forge`_.
|
||||
* GNU Octave version 4.4 or above, with the statistics package from
|
||||
`Octave-Forge`_. Note however that the Dynare installers for Windows and
|
||||
macOS require a more specific version of Octave, as indicated on the download
|
||||
page.
|
||||
|
||||
The following optional extensions are also useful to benefit from
|
||||
extra features, but are in no way required:
|
||||
|
@ -84,27 +87,33 @@ be under ``/usr/share/doc/dynare-doc`` (only on Debian, Ubuntu and Linux Mint).
|
|||
On macOS
|
||||
--------
|
||||
|
||||
To install Dynare for use with MATLAB, execute the automated installer
|
||||
called ``dynare-4.x.y.pkg`` (where *4.x.y* is the version number), and
|
||||
follow the instructions. The default installation directory is
|
||||
``/Applications/Dynare/4.x.y`` (please refer to the `Dynare wiki`_ for
|
||||
detailed instructions).
|
||||
|
||||
After installation, this directory will contain several
|
||||
sub-directories, among which are ``matlab``, ``mex`` and ``doc``.
|
||||
To install Dynare for use with MATLAB, execute the automated installer called
|
||||
``dynare-4.x.y.pkg`` (where *4.x.y* is the version number), and follow the
|
||||
instructions. The default installation directory is
|
||||
``/Applications/Dynare/4.x.y``. After installation, this directory will contain
|
||||
several sub-directories, among which are ``matlab``, ``mex``, and ``doc``.
|
||||
|
||||
Note that several versions of Dynare can coexist (by default in
|
||||
``/Applications/Dynare``), as long as you correctly adjust your path
|
||||
settings (see :ref:`words-warning`).
|
||||
|
||||
To install Dynare for Octave, first install Homebrew following the
|
||||
instructions on their site: `https://brew.sh/
|
||||
<https://brew.sh/>`__. Then install Octave, issuing the command ``brew
|
||||
install octave`` at the Terminal prompt. You can then install the
|
||||
latest stable version of Dynare by typing ``brew install dynare`` at
|
||||
the Terminal prompt. You can also pass options to the installation
|
||||
command. These options can be viewed by typing ``brew info dynare`` at
|
||||
the Terminal prompt.
|
||||
By default, the installer installs a version of GCC (for use with :opt:`use_dll`)
|
||||
in the installation directory, under the ``.brew`` folder. To do so, it also
|
||||
installs a version of `Homebrew <https://brew.sh>`__ in the same folder and
|
||||
Xcode Command Line Tools (this is an Apple product) in a system folder.
|
||||
|
||||
All of this requires a bit of time and hard disk space. The amount of time it
|
||||
takes will depend on your computing power and internet connection. To reduce
|
||||
the time the Dynare installer takes, you can install Xcode Command Line Tools
|
||||
yourself (see :ref:`prerequisites-macos`). Dynare, Homebrew, and GCC use
|
||||
about 600 MB of disk space while the Xcode Command Line Tools require about 400
|
||||
MB.
|
||||
|
||||
If you do not use the :opt:`use_dll` option, you have the choice to forgo the
|
||||
installation of GCC and hence Dynare will only take about 50 MB of disk space.
|
||||
|
||||
Dynare for Octave works with Octave installed via the package located here:
|
||||
`https://octave-app.org <https://octave-app.org>`__.
|
||||
|
||||
|
||||
For other systems
|
||||
|
@ -140,14 +149,17 @@ Users of Octave under GNU/Linux should install the package for MEX file
|
|||
compilation (under Debian, Ubuntu or Linux Mint, it can be done via ``apt
|
||||
install liboctave-dev``).
|
||||
|
||||
.. _prerequisites-macos:
|
||||
|
||||
Prerequisites on macOS
|
||||
----------------------
|
||||
|
||||
Dynare now ships a compilation environment that can be used with the
|
||||
:opt:`use_dll` option. Specifically, the Dynare installer downloads and
|
||||
installs the Xcode Command Line Tools, installs `Homebrew <https://brew.sh>`_
|
||||
under the Dynare installation directory (in the ``.brew`` folder), and finally
|
||||
installs GCC.
|
||||
:opt:`use_dll` option. To install this environment correctly, the Dynare
|
||||
installer ensures that the Xcode Command Line Tools (an Apple product) have
|
||||
been installed on a system folder. To install the Xcode Command Line Tools
|
||||
yourself, simply type ``xcode-select --install`` into the Terminal
|
||||
(``/Applications/Utilities/Terminal.app``) prompt.
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
@ -209,10 +221,10 @@ command; the packaging does it for you. Under Arch Linux, you need to do::
|
|||
|
||||
octave:1> addpath /usr/lib/dynare/matlab
|
||||
|
||||
Under macOS, assuming that you have installed Dynare and Octave via
|
||||
Homebrew, type::
|
||||
Under macOS, assuming you have installed Octave via `https://octave-app.org
|
||||
<https://octave-app.org>`__, type::
|
||||
|
||||
octave:1> addpath /usr/local/opt/dynare/lib/dynare/matlab
|
||||
octave:1> addpath /Applications/Dynare/4.x.y/matlab
|
||||
|
||||
If you don’t want to type this command every time you run Octave, you
|
||||
can put it in a file called ``.octaverc`` in your home directory
|
||||
|
|
|
@ -55,7 +55,7 @@ manual. Part of Dynare is programmed in C++, while the rest is written
|
|||
using the `MATLAB`_ programming language. The latter implies that
|
||||
commercially-available MATLAB software is required in order to run
|
||||
Dynare. However, as an alternative to MATLAB, Dynare is also able to
|
||||
run on top of `Octave`_ (basically a free clone of MATLAB): this
|
||||
run on top of `GNU Octave`_ (basically a free clone of MATLAB): this
|
||||
possibility is particularly interesting for students or institutions
|
||||
who cannot afford, or do not want to pay for, MATLAB and are willing
|
||||
to bear the concomitant performance loss.
|
||||
|
@ -122,7 +122,7 @@ https://www.dynare.org.
|
|||
|
||||
|
||||
.. _MATLAB: https://www.mathworks.com/products/matlab/
|
||||
.. _Octave: https://www.octave.org/
|
||||
.. _GNU Octave: https://www.octave.org/
|
||||
.. _CEPREMAP: https://www.cepremap.fr/
|
||||
.. _web forum: https://forum.dynare.org/
|
||||
.. _official Dynare website: https://www.dynare.org/
|
||||
|
|
|
@ -104,6 +104,23 @@ by the ``dynare`` command.
|
|||
Octave, it also means that the ``.mod`` file cannot be named
|
||||
``test.mod`` or ``example.mod``.
|
||||
|
||||
.. _quote-note:
|
||||
|
||||
.. note::
|
||||
Note on Quotes
|
||||
|
||||
When passing command line options that contains a space (or, under
|
||||
Octave, a double quote), you must surround the entire option (keyword
|
||||
and argument) with single quotes, as in the following example.
|
||||
|
||||
*Example*
|
||||
|
||||
Call Dynare with options containing spaces
|
||||
|
||||
.. code-block:: matlab
|
||||
|
||||
>> dynare <<modfile.mod>> '-DA=[ i in [1,2,3] when i > 1 ]' 'conffile=C:\User\My Documents\config.txt'
|
||||
|
||||
*Options*
|
||||
|
||||
.. option:: noclearall
|
||||
|
@ -140,10 +157,11 @@ by the ``dynare`` command.
|
|||
|
||||
.. option:: savemacro[=FILENAME]
|
||||
|
||||
Instructs ``dynare`` to save the intermediary file which is
|
||||
obtained after macro processing (see :ref:`macro-proc-lang`);
|
||||
the saved output will go in the file specified, or if no file
|
||||
is specified in ``FILENAME-macroexp.mod``
|
||||
Instructs ``dynare`` to save the intermediary file which is obtained
|
||||
after macro processing (see :ref:`macro-proc-lang`); the saved output
|
||||
will go in the file specified, or if no file is specified in
|
||||
``FILENAME-macroexp.mod``. See the :ref:`note on quotes<quote-note>`
|
||||
for info on passing a ``FILENAME`` argument containing spaces.
|
||||
|
||||
.. option:: onlymacro
|
||||
|
||||
|
@ -152,19 +170,12 @@ by the ``dynare`` command.
|
|||
debugging purposes or for using the macro processor
|
||||
independently of the rest of Dynare toolbox.
|
||||
|
||||
.. option:: nolinemacro
|
||||
.. option:: linemacro
|
||||
|
||||
Instructs the macro preprocessor to omit line numbering
|
||||
information in the intermediary ``.mod`` file created after
|
||||
the macro processing step. Useful in conjunction with
|
||||
:opt:`savemacro <savemacro[=FILENAME]>` when one wants that to reuse the intermediary
|
||||
``.mod`` file, without having it cluttered by line numbering
|
||||
directives.
|
||||
|
||||
.. option:: noemptylinemacro
|
||||
|
||||
Passing this option removes all empty from the macro expanded
|
||||
mod file created when the :opt:`savemacro <savemacro[=FILENAME]>` option is used.
|
||||
Instructs the macro preprocessor include ``@#line`` directives
|
||||
specifying the line on which macro directives were encountered and
|
||||
expanded from. Only useful in conjunction with :opt:`savemacro
|
||||
<savemacro[=FILENAME]>`.
|
||||
|
||||
.. option:: onlymodel
|
||||
|
||||
|
@ -305,9 +316,10 @@ by the ``dynare`` command.
|
|||
|
||||
.. option:: matlabroot=<<path>>
|
||||
|
||||
The path to the MATLAB installation for use with
|
||||
:opt:`use_dll`. Dynare is able to set this automatically,
|
||||
so you should not need to set it yourself.
|
||||
The path to the MATLAB installation for use with :opt:`use_dll`. Dynare
|
||||
is able to set this automatically, so you should not need to set it
|
||||
yourself. See the :ref:`note on quotes<quote-note>` for info on
|
||||
passing a ``<<path>>`` argument containing spaces.
|
||||
|
||||
.. option:: parallel[=CLUSTER_NAME]
|
||||
|
||||
|
@ -320,9 +332,11 @@ by the ``dynare`` command.
|
|||
|
||||
.. option:: conffile=FILENAME
|
||||
|
||||
Specifies the location of the configuration file if it differs
|
||||
from the default. See :ref:`conf-file`, for more information
|
||||
about the configuration file and its default location.
|
||||
Specifies the location of the configuration file if it differs from the
|
||||
default. See :ref:`conf-file`, for more information about the
|
||||
configuration file and its default location. See the :ref:`note on
|
||||
quotes<quote-note>` for info on passing a ``FILENAME`` argument
|
||||
containing spaces.
|
||||
|
||||
.. option:: parallel_slave_open_mode
|
||||
|
||||
|
@ -338,18 +352,30 @@ by the ``dynare`` command.
|
|||
|
||||
.. option:: -DMACRO_VARIABLE=MACRO_EXPRESSION
|
||||
|
||||
Defines a macro-variable from the command line (the same
|
||||
effect as using the Macro directive ``@#define`` in a model
|
||||
file, see :ref:`macro-proc-lang`).
|
||||
Defines a macro-variable from the command line (the same effect as
|
||||
using the Macro directive ``@#define`` in a model file, see
|
||||
:ref:`macro-proc-lang`). See the :ref:`note on quotes<quote-note>` for
|
||||
info on passing a ``MACRO_EXPRESSION`` argument containing spaces. Note
|
||||
that an expression passed on the command line can reference variables
|
||||
defined before it.
|
||||
|
||||
*Example*
|
||||
|
||||
Call dynare with command line defines
|
||||
|
||||
.. code-block:: matlab
|
||||
|
||||
>> dynare <<modfile.mod>> -DA=true '-DB="A string with space"' -DC=[1,2,3] '-DD=[ i in C when i > 1 ]'
|
||||
|
||||
.. option:: -I<<path>>
|
||||
|
||||
Defines a path to search for files to be included by the
|
||||
macro processor (using the ``@#include`` command). Multiple
|
||||
``-I`` flags can be passed on the command line. The paths will
|
||||
be searched in the order that the ``-I`` flags are passed and
|
||||
the first matching file will be used. The flags passed here
|
||||
take priority over those passed to ``@#includepath``.
|
||||
Defines a path to search for files to be included by the macro
|
||||
processor (using the ``@#include`` command). Multiple ``-I`` flags can
|
||||
be passed on the command line. The paths will be searched in the order
|
||||
that the ``-I`` flags are passed and the first matching file will be
|
||||
used. The flags passed here take priority over those passed to
|
||||
``@#includepath``. See the :ref:`note on quotes<quote-note>` for info
|
||||
on passing a ``<<path>>`` argument containing spaces.
|
||||
|
||||
.. option:: nostrict
|
||||
|
||||
|
@ -475,13 +501,14 @@ by the ``dynare`` command.
|
|||
after the name of the ``.mod`` file. They can alternatively be
|
||||
defined in the first line of the ``.mod`` file, this avoids typing
|
||||
them on the command line each time a ``.mod`` file is to be
|
||||
run. This line must be a Dynare comment (ie must begin with //)
|
||||
and the options must be comma separated between ``--+`` options:
|
||||
run. This line must be a Dynare one-line comment (i.e. must begin with ``//``)
|
||||
and the options must be whitespace separated between ``--+ options:``
|
||||
and ``+--``. Note that any text after the ``+--`` will be
|
||||
discarded. As in the command line, if an option admits a value the
|
||||
equal symbol must not be surrounded by spaces. For instance ``json
|
||||
= compute`` is not correct, and should be written
|
||||
``json=compute``.
|
||||
``json=compute``. The ``nopathchange`` option cannot be specified in
|
||||
this way, it must be passed on the command-line.
|
||||
|
||||
*Output*
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -52,7 +52,7 @@ class DynareLexer(RegexLexer):
|
|||
"save_params_and_steady_state","load_params_and_steady_state",
|
||||
"dynare_version","write_latex_definitions","write_latex_parameter_table",
|
||||
"write_latex_prior_table","collect_latex_files","prior_function",
|
||||
"posterior_function","generate_trace_plots")
|
||||
"posterior_function","generate_trace_plots","evaluate_planner_objective")
|
||||
|
||||
report_commands = ("report","addPage","addSection","addGraph","addTable",
|
||||
"addSeries","addParagraph","addVspace","write","compile")
|
||||
|
@ -73,7 +73,7 @@ class DynareLexer(RegexLexer):
|
|||
(r'\s*(%|//).*$', Comment),
|
||||
|
||||
(words((
|
||||
'model','steady_state_model','initval','endval','histval',
|
||||
'model','steady_state_model','initval','endval','histval','epilogue',
|
||||
'shocks','mshocks','homotopy_setup','observation_trends',
|
||||
'estimated_params','estimated_params_init','estimated_params_bounds',
|
||||
'shock_groups','conditional_forecast_paths','optim_weights',
|
||||
|
@ -92,7 +92,6 @@ class DynareLexer(RegexLexer):
|
|||
|
||||
(r'\s*[a-zA-Z_]\s*', Name),
|
||||
|
||||
|
||||
(r'\s*(\d+\.\d+|\d*\.\d+)([eEf][+-]?[0-9]+)?\s*', Number.Float),
|
||||
(r'\s*\d+[eEf][+-]?[0-9]+\s*', Number.Float),
|
||||
(r'\s*\d+\s*', Number.Integer),
|
||||
|
|
|
@ -1 +1,11 @@
|
|||
SUBDIRS = utils/cc sylv parser/cc tl doc integ kord src tests
|
||||
|
||||
EXTRA_DIST = dynare_simul
|
||||
|
||||
install-exec-local:
|
||||
$(MKDIR_P) $(DESTDIR)$(pkglibdir)/dynare++
|
||||
cp -r dynare_simul/* $(DESTDIR)$(pkglibdir)/dynare++
|
||||
|
||||
uninstall-local:
|
||||
rm -rf $(DESTDIR)$(pkglibdir)/dynare++
|
||||
|
||||
|
|
|
@ -0,0 +1,176 @@
|
|||
%
|
||||
% SYNOPSIS
|
||||
%
|
||||
% r = dynare_simul(name, shocks)
|
||||
% r = dynare_simul(name, prefix, shocks)
|
||||
% r = dynare_simul(name, shocks, start)
|
||||
% r = dynare_simul(name, prefix, shocks, start)
|
||||
%
|
||||
% name name of MAT-file produced by dynare++
|
||||
% prefix prefix of variables in the MAT-file
|
||||
% shocks matrix of shocks
|
||||
% start zero period value
|
||||
%
|
||||
% Note that this file requires the dynare_simul_ DLL to be in the path.
|
||||
% This DLL is distributed with Dynare, under the mex/matlab or mex/octave
|
||||
% subdirectory.
|
||||
%
|
||||
% SEMANTICS
|
||||
%
|
||||
% The command reads a decision rule from the MAT-file having the given
|
||||
% prefix. Then it starts simulating the decision rule with zero time value
|
||||
% equal to the given start. It uses the given shocks for the simulation. If
|
||||
% the start is not given, the state about which the decision rule is
|
||||
% centralized is taken (called fix point, or stochastic steady state, take
|
||||
% your pick).
|
||||
%
|
||||
% prefix Use the prefix with which you called dynare++, the default
|
||||
% prefix in dynare++ is 'dyn'.
|
||||
% shocks Number of rows must be a number of exogenous shocks,
|
||||
% number of columns gives the number of simulated
|
||||
% periods. NaNs and Infs in the matrix are substitued by
|
||||
% draws from the normal distribution using the covariance
|
||||
% matrix given in the model file.
|
||||
% start Vector of endogenous variables in the ordering given by
|
||||
% <prefix>_vars.
|
||||
%
|
||||
% Seed for random generator is derived from calling rand(1,1). Therefore,
|
||||
% seeding can be controlled with rand('state') and rand('state',some_seed).
|
||||
%
|
||||
% EXAMPLES
|
||||
%
|
||||
% All examples suppose that the prefix is 'dyn' and that your_model.mat
|
||||
% has been loaded into Matlab.
|
||||
%
|
||||
% 1. response to permanent negative shock to the third exo var EPS3 for
|
||||
% 100 periods
|
||||
%
|
||||
% shocks = zeros(4,100); % 4 exogenous variables in the model
|
||||
% shocks(dyn_i_EPS3,:) = -0.1; % the permanent shock to EPS3
|
||||
% r = dynare_simul('your_model.mat',shocks);
|
||||
%
|
||||
% 2. one stochastic simulation for 100 periods
|
||||
%
|
||||
% shocks = zeros(4,100)./0; % put NaNs everywhere
|
||||
% r = dynare_simul('your_model.mat',shocks);
|
||||
%
|
||||
% 3. one stochastic simulation starting at 75% undercapitalized economy
|
||||
%
|
||||
% shocks = zeros(4,100)./0; % put NaNs everywhere
|
||||
% ystart = dyn_ss; % get copy of DR fix point
|
||||
% ystart(dyn_i_K) = 0.75*dyn_ss(dyn_i_K); % scale down the capital
|
||||
% r = dynare_simul('your_model.mat',shocks,ystart);
|
||||
%
|
||||
%
|
||||
% SEE ALSO
|
||||
%
|
||||
% "DSGE Models with Dynare++. A Tutorial.", Ondra Kamenik, 2005
|
||||
|
||||
% Copyright (C) 2005-2011, Ondra Kamenik
|
||||
% Copyright (C) 2020, Dynare Team
|
||||
|
||||
|
||||
function r = dynare_simul(varargin)
|
||||
|
||||
if ~exist('dynare_simul_','file')
|
||||
error('Can''t find dynare_simul_ DLL in the path. The simplest way to add it is to run Dynare once in this session.')
|
||||
end
|
||||
|
||||
% get the file name and load data
|
||||
fname = varargin{1};
|
||||
load(fname);
|
||||
|
||||
% set prefix, shocks, ystart
|
||||
if ischar(varargin{2})
|
||||
prefix = varargin{2};
|
||||
if length(varargin) == 3
|
||||
shocks = varargin{3};
|
||||
ystart = NaN;
|
||||
elseif length(varargin) == 4
|
||||
shocks = varargin{3};
|
||||
ystart = varargin{4};
|
||||
else
|
||||
error('Wrong number of parameters.');
|
||||
end
|
||||
else
|
||||
prefix = 'dyn';
|
||||
if length(varargin) == 2
|
||||
shocks = varargin{2};
|
||||
ystart = NaN;
|
||||
elseif length(varargin) == 3
|
||||
shocks = varargin{2};
|
||||
ystart = varargin{3};
|
||||
else
|
||||
error('Wrong number of parameters.');
|
||||
end
|
||||
end
|
||||
|
||||
% load all needed variables but prefix_g_*
|
||||
if exist([prefix '_nstat'],'var')
|
||||
nstat = eval([prefix '_nstat']);
|
||||
else
|
||||
error(['Could not find variable ' prefix '_nstat in workspace']);
|
||||
end
|
||||
if exist([prefix '_npred'],'var')
|
||||
npred = eval([prefix '_npred']);
|
||||
else
|
||||
error(['Could not find variable ' prefix '_npred in workspace']);
|
||||
end
|
||||
if exist([prefix '_nboth'],'var')
|
||||
nboth = eval([prefix '_nboth']);
|
||||
else
|
||||
error(['Could not find variable ' prefix '_nboth in workspace']);
|
||||
end
|
||||
if exist([prefix '_nforw'],'var')
|
||||
nforw = eval([prefix '_nforw']);
|
||||
else
|
||||
error(['Could not find variable ' prefix '_nforw in workspace']);
|
||||
end
|
||||
if exist([prefix '_ss'],'var')
|
||||
ss = eval([prefix '_ss']);
|
||||
else
|
||||
error(['Could not find variable ' prefix '_ss in workspace']);
|
||||
end
|
||||
if exist([prefix '_vcov_exo'],'var')
|
||||
vcov_exo = eval([prefix '_vcov_exo']);
|
||||
else
|
||||
error(['Could not find variable ' prefix '_vcov_exo in workspace']);
|
||||
end
|
||||
nexog = size(vcov_exo,1);
|
||||
|
||||
if isnan(ystart)
|
||||
ystart = ss;
|
||||
end
|
||||
|
||||
% newer version of dynare++ doesn't return prefix_g_0, we make it here if
|
||||
% it does not exist in workspace
|
||||
g_zero = [prefix '_g_0'];
|
||||
if ~exist(g_zero,'var')
|
||||
dr.g_0=zeros(nstat+npred+nboth+nforw,1);
|
||||
else
|
||||
dr.g_0=eval(g_zero);
|
||||
end
|
||||
|
||||
% make derstr a string of comma seperated existing prefix_g_*
|
||||
order = 1;
|
||||
cont = 1;
|
||||
while cont == 1
|
||||
g_ord = [prefix '_g_' num2str(order)];
|
||||
if exist(g_ord,'var')
|
||||
dr.(['g_' num2str(order)])=eval(g_ord);
|
||||
order = order + 1;
|
||||
else
|
||||
cont = 0;
|
||||
end
|
||||
end
|
||||
|
||||
% set seed
|
||||
seed = ceil(10000*rand(1,1));
|
||||
|
||||
% call dynare_simul_
|
||||
[err,r]=dynare_simul_(order-1,nstat,npred,nboth,nforw,...
|
||||
nexog,ystart,shocks,vcov_exo,seed,ss,dr);
|
||||
|
||||
if err
|
||||
error('Simulation failed')
|
||||
end
|
|
@ -29,13 +29,15 @@
|
|||
static const int gh_num_levels = 26;
|
||||
|
||||
// Number of points in each level
|
||||
static const int gh_num_points[] = {
|
||||
static const int gh_num_points[] =
|
||||
{
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
30, 32, 40, 50, 60, 64
|
||||
};
|
||||
|
||||
// Weights, starting with the first level
|
||||
static const double gh_weights[] = {
|
||||
static const double gh_weights[] =
|
||||
{
|
||||
// weights 1 = √π
|
||||
1.77245385090551588191942755656782537698745727539062,
|
||||
// weights 2
|
||||
|
@ -551,7 +553,8 @@ static const double gh_weights[] = {
|
|||
};
|
||||
|
||||
// Points, starting with the first level
|
||||
static const double gh_points[] = {
|
||||
static const double gh_points[] =
|
||||
{
|
||||
// points 1
|
||||
0.0,
|
||||
// points 2
|
||||
|
@ -1072,13 +1075,15 @@ static const double gh_points[] = {
|
|||
static const int gl_num_levels = 22;
|
||||
|
||||
// Number of points in each level
|
||||
static const int gl_num_points[] = {
|
||||
static const int gl_num_points[] =
|
||||
{
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
32, 64
|
||||
};
|
||||
|
||||
// Weights, starting with the first level
|
||||
static const double gl_weights[] = {
|
||||
static const double gl_weights[] =
|
||||
{
|
||||
// weight 1
|
||||
2.0e+00,
|
||||
// weights 2
|
||||
|
@ -1410,7 +1415,8 @@ static const double gl_weights[] = {
|
|||
};
|
||||
|
||||
// Points, starting with the first level
|
||||
static const double gl_points[] = {
|
||||
static const double gl_points[] =
|
||||
{
|
||||
// points 1
|
||||
0.0e+00,
|
||||
// points 2
|
||||
|
|
|
@ -106,7 +106,8 @@ RadicalInverse::print() const
|
|||
/* Here we have the first 170 primes. This means that we are not able to
|
||||
integrate dimensions greater than 170. */
|
||||
|
||||
std::array<int, 170> HaltonSequence::primes = {
|
||||
std::array<int, 170> HaltonSequence::primes =
|
||||
{
|
||||
2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
|
||||
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
|
||||
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
|
||||
|
|
|
@ -70,7 +70,6 @@ VectorFunctionSet::VectorFunctionSet(VectorFunction &f, int n)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* Here we construct the object from the given function f and given
|
||||
variance-covariance matrix Σ=vcov. The matrix A is calculated as lower
|
||||
triangular and yields Σ=AAᵀ. */
|
||||
|
|
|
@ -180,6 +180,7 @@ public:
|
|||
protected:
|
||||
void fillTensors(const _Tg &g, double sigma);
|
||||
void centralize(const DecisionRuleImpl &dr);
|
||||
public:
|
||||
void eval(emethod em, Vector &out, const ConstVector &v) const override;
|
||||
};
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
// Dynamic model abstraction
|
||||
|
||||
/* This file only defines a generic interface to a DSGE model. The model
|
||||
|
|
|
@ -112,117 +112,173 @@ MatrixS::MatrixS(const FSSparseTensor &f, const IntSequence &ss,
|
|||
interesting here. */
|
||||
|
||||
template<>
|
||||
ctraits<Storage::unfold>::Tg& KOrder::g<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::Tg &
|
||||
KOrder::g<Storage::unfold>()
|
||||
{
|
||||
return _ug;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::Tg& KOrder::g<Storage::unfold>() const
|
||||
{ return _ug;}
|
||||
const ctraits<Storage::unfold>::Tg &
|
||||
KOrder::g<Storage::unfold>() const
|
||||
{
|
||||
return _ug;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::Tg& KOrder::g<Storage::fold>()
|
||||
ctraits<Storage::fold>::Tg &
|
||||
KOrder::g<Storage::fold>()
|
||||
{
|
||||
return _fg;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::Tg& KOrder::g<Storage::fold>() const
|
||||
{ return _fg;}
|
||||
const ctraits<Storage::fold>::Tg &
|
||||
KOrder::g<Storage::fold>() const
|
||||
{
|
||||
return _fg;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::unfold>::Tgs& KOrder::gs<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::Tgs &
|
||||
KOrder::gs<Storage::unfold>()
|
||||
{
|
||||
return _ugs;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::Tgs& KOrder::gs<Storage::unfold>() const
|
||||
{ return _ugs;}
|
||||
const ctraits<Storage::unfold>::Tgs &
|
||||
KOrder::gs<Storage::unfold>() const
|
||||
{
|
||||
return _ugs;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::Tgs& KOrder::gs<Storage::fold>()
|
||||
ctraits<Storage::fold>::Tgs &
|
||||
KOrder::gs<Storage::fold>()
|
||||
{
|
||||
return _fgs;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::Tgs& KOrder::gs<Storage::fold>() const
|
||||
{ return _fgs;}
|
||||
const ctraits<Storage::fold>::Tgs &
|
||||
KOrder::gs<Storage::fold>() const
|
||||
{
|
||||
return _fgs;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::unfold>::Tgss& KOrder::gss<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::Tgss &
|
||||
KOrder::gss<Storage::unfold>()
|
||||
{
|
||||
return _ugss;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::Tgss& KOrder::gss<Storage::unfold>() const
|
||||
{ return _ugss;}
|
||||
const ctraits<Storage::unfold>::Tgss &
|
||||
KOrder::gss<Storage::unfold>() const
|
||||
{
|
||||
return _ugss;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::Tgss& KOrder::gss<Storage::fold>()
|
||||
ctraits<Storage::fold>::Tgss &
|
||||
KOrder::gss<Storage::fold>()
|
||||
{
|
||||
return _fgss;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::Tgss& KOrder::gss<Storage::fold>() const
|
||||
{ return _fgss;}
|
||||
const ctraits<Storage::fold>::Tgss &
|
||||
KOrder::gss<Storage::fold>() const
|
||||
{
|
||||
return _fgss;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::unfold>::TG& KOrder::G<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::TG &
|
||||
KOrder::G<Storage::unfold>()
|
||||
{
|
||||
return _uG;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::TG& KOrder::G<Storage::unfold>() const
|
||||
{ return _uG;}
|
||||
const ctraits<Storage::unfold>::TG &
|
||||
KOrder::G<Storage::unfold>() const
|
||||
{
|
||||
return _uG;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::TG& KOrder::G<Storage::fold>()
|
||||
ctraits<Storage::fold>::TG &
|
||||
KOrder::G<Storage::fold>()
|
||||
{
|
||||
return _fG;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::TG& KOrder::G<Storage::fold>() const
|
||||
{ return _fG;}
|
||||
const ctraits<Storage::fold>::TG &
|
||||
KOrder::G<Storage::fold>() const
|
||||
{
|
||||
return _fG;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::unfold>::TZstack& KOrder::Zstack<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::TZstack &
|
||||
KOrder::Zstack<Storage::unfold>()
|
||||
{
|
||||
return _uZstack;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::TZstack& KOrder::Zstack<Storage::unfold>() const
|
||||
{ return _uZstack;}
|
||||
const ctraits<Storage::unfold>::TZstack &
|
||||
KOrder::Zstack<Storage::unfold>() const
|
||||
{
|
||||
return _uZstack;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::TZstack& KOrder::Zstack<Storage::fold>()
|
||||
ctraits<Storage::fold>::TZstack &
|
||||
KOrder::Zstack<Storage::fold>()
|
||||
{
|
||||
return _fZstack;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::TZstack& KOrder::Zstack<Storage::fold>() const
|
||||
{ return _fZstack;}
|
||||
const ctraits<Storage::fold>::TZstack &
|
||||
KOrder::Zstack<Storage::fold>() const
|
||||
{
|
||||
return _fZstack;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::unfold>::TGstack& KOrder::Gstack<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::TGstack &
|
||||
KOrder::Gstack<Storage::unfold>()
|
||||
{
|
||||
return _uGstack;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::TGstack& KOrder::Gstack<Storage::unfold>() const
|
||||
{ return _uGstack;}
|
||||
const ctraits<Storage::unfold>::TGstack &
|
||||
KOrder::Gstack<Storage::unfold>() const
|
||||
{
|
||||
return _uGstack;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::TGstack& KOrder::Gstack<Storage::fold>()
|
||||
ctraits<Storage::fold>::TGstack &
|
||||
KOrder::Gstack<Storage::fold>()
|
||||
{
|
||||
return _fGstack;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::TGstack& KOrder::Gstack<Storage::fold>() const
|
||||
{ return _fGstack;}
|
||||
const ctraits<Storage::fold>::TGstack &
|
||||
KOrder::Gstack<Storage::fold>() const
|
||||
{
|
||||
return _fGstack;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::unfold>::Tm& KOrder::m<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::Tm &
|
||||
KOrder::m<Storage::unfold>()
|
||||
{
|
||||
return _um;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::Tm& KOrder::m<Storage::unfold>() const
|
||||
{ return _um;}
|
||||
const ctraits<Storage::unfold>::Tm &
|
||||
KOrder::m<Storage::unfold>() const
|
||||
{
|
||||
return _um;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::Tm& KOrder::m<Storage::fold>()
|
||||
ctraits<Storage::fold>::Tm &
|
||||
KOrder::m<Storage::fold>()
|
||||
{
|
||||
return _fm;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::Tm& KOrder::m<Storage::fold>() const
|
||||
{ return _fm;}
|
||||
const ctraits<Storage::fold>::Tm &
|
||||
KOrder::m<Storage::fold>() const
|
||||
{
|
||||
return _fm;
|
||||
}
|
||||
|
||||
/* Here is the constructor of the KOrder class. We pass what we have to. The
|
||||
partitioning of the y vector, a sparse container with model derivatives,
|
||||
|
|
|
@ -77,112 +77,134 @@ KOrderStoch::KOrderStoch(const PartitionY &yp, int nu,
|
|||
|
||||
// KOrderStoch convenience method specializations
|
||||
template<>
|
||||
ctraits<Storage::unfold>::Tg &KOrderStoch::g<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::Tg &
|
||||
KOrderStoch::g<Storage::unfold>()
|
||||
{
|
||||
return _ug;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::Tg &KOrderStoch::g<Storage::unfold>() const
|
||||
const ctraits<Storage::unfold>::Tg &
|
||||
KOrderStoch::g<Storage::unfold>() const
|
||||
{
|
||||
return _ug;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::Tg &KOrderStoch::g<Storage::fold>()
|
||||
ctraits<Storage::fold>::Tg &
|
||||
KOrderStoch::g<Storage::fold>()
|
||||
{
|
||||
return _fg;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::Tg &KOrderStoch::g<Storage::fold>() const
|
||||
const ctraits<Storage::fold>::Tg &
|
||||
KOrderStoch::g<Storage::fold>() const
|
||||
{
|
||||
return _fg;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::unfold>::Tgs &KOrderStoch::gs<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::Tgs &
|
||||
KOrderStoch::gs<Storage::unfold>()
|
||||
{
|
||||
return _ugs;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::Tgs &KOrderStoch::gs<Storage::unfold>() const
|
||||
const ctraits<Storage::unfold>::Tgs &
|
||||
KOrderStoch::gs<Storage::unfold>() const
|
||||
{
|
||||
return _ugs;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::Tgs &KOrderStoch::gs<Storage::fold>()
|
||||
ctraits<Storage::fold>::Tgs &
|
||||
KOrderStoch::gs<Storage::fold>()
|
||||
{
|
||||
return _fgs;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::Tgs &KOrderStoch::gs<Storage::fold>() const
|
||||
const ctraits<Storage::fold>::Tgs &
|
||||
KOrderStoch::gs<Storage::fold>() const
|
||||
{
|
||||
return _fgs;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::Tgss &KOrderStoch::h<Storage::unfold>() const
|
||||
const ctraits<Storage::unfold>::Tgss &
|
||||
KOrderStoch::h<Storage::unfold>() const
|
||||
{
|
||||
return *_uh;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::Tgss &KOrderStoch::h<Storage::fold>() const
|
||||
const ctraits<Storage::fold>::Tgss &
|
||||
KOrderStoch::h<Storage::fold>() const
|
||||
{
|
||||
return *_fh;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::unfold>::TG &KOrderStoch::G<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::TG &
|
||||
KOrderStoch::G<Storage::unfold>()
|
||||
{
|
||||
return _uG;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::TG &KOrderStoch::G<Storage::unfold>() const
|
||||
const ctraits<Storage::unfold>::TG &
|
||||
KOrderStoch::G<Storage::unfold>() const
|
||||
{
|
||||
return _uG;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::TG &KOrderStoch::G<Storage::fold>()
|
||||
ctraits<Storage::fold>::TG &
|
||||
KOrderStoch::G<Storage::fold>()
|
||||
{
|
||||
return _fG;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::TG& KOrderStoch::G<Storage::fold>() const
|
||||
const ctraits<Storage::fold>::TG &
|
||||
KOrderStoch::G<Storage::fold>() const
|
||||
{
|
||||
return _fG;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::unfold>::TZXstack &KOrderStoch::Zstack<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::TZXstack &
|
||||
KOrderStoch::Zstack<Storage::unfold>()
|
||||
{
|
||||
return _uZstack;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::TZXstack &KOrderStoch::Zstack<Storage::unfold>() const
|
||||
const ctraits<Storage::unfold>::TZXstack &
|
||||
KOrderStoch::Zstack<Storage::unfold>() const
|
||||
{
|
||||
return _uZstack;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::TZXstack &KOrderStoch::Zstack<Storage::fold>()
|
||||
ctraits<Storage::fold>::TZXstack &
|
||||
KOrderStoch::Zstack<Storage::fold>()
|
||||
{
|
||||
return _fZstack;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::TZXstack &KOrderStoch::Zstack<Storage::fold>() const
|
||||
const ctraits<Storage::fold>::TZXstack &
|
||||
KOrderStoch::Zstack<Storage::fold>() const
|
||||
{
|
||||
return _fZstack;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::unfold>::TGXstack &KOrderStoch::Gstack<Storage::unfold>()
|
||||
ctraits<Storage::unfold>::TGXstack &
|
||||
KOrderStoch::Gstack<Storage::unfold>()
|
||||
{
|
||||
return _uGstack;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::unfold>::TGXstack &KOrderStoch::Gstack<Storage::unfold>() const
|
||||
const ctraits<Storage::unfold>::TGXstack &
|
||||
KOrderStoch::Gstack<Storage::unfold>() const
|
||||
{
|
||||
return _uGstack;
|
||||
}
|
||||
template<>
|
||||
ctraits<Storage::fold>::TGXstack &KOrderStoch::Gstack<Storage::fold>()
|
||||
ctraits<Storage::fold>::TGXstack &
|
||||
KOrderStoch::Gstack<Storage::fold>()
|
||||
{
|
||||
return _fGstack;
|
||||
}
|
||||
template<>
|
||||
const ctraits<Storage::fold>::TGXstack &KOrderStoch::Gstack<Storage::fold>() const
|
||||
const ctraits<Storage::fold>::TGXstack &
|
||||
KOrderStoch::Gstack<Storage::fold>() const
|
||||
{
|
||||
return _fGstack;
|
||||
}
|
||||
|
|
|
@ -116,13 +116,15 @@ SparseGenerator::fillContainer(TensorContainer<FSSparseTensor> &c,
|
|||
}
|
||||
}
|
||||
|
||||
const double vdata [] = { // 3x3
|
||||
const double vdata[] =
|
||||
{ // 3x3
|
||||
0.1307870268, 0.1241940078, 0.1356703123,
|
||||
0.1241940078, 0.1986920419, 0.2010160581,
|
||||
0.1356703123, 0.2010160581, 0.2160336975
|
||||
};
|
||||
|
||||
const double gy_data [] = { // 8x4
|
||||
const double gy_data[] =
|
||||
{ // 8x4
|
||||
0.3985178619, -0.5688233582, 0.9572900437, -0.6606847776, 0.1453004017,
|
||||
0.3025310675, -0.8627437750, -0.6903410191, 0.4751910580, -0.7270018589,
|
||||
-0.0939612498, -0.1463831989, 0.6742110220, 0.6046671043, 0.5215893126,
|
||||
|
@ -132,7 +134,8 @@ const double gy_data [] = { // 8x4
|
|||
-0.5452861965, 1.6320340279
|
||||
};
|
||||
|
||||
const double gu_data [] = { // just some numbers, no structure
|
||||
const double gu_data[] =
|
||||
{ // just some numbers, no structure
|
||||
1.8415286914, -0.2638743845, 1.7690713274, 0.9668585956, 0.2303143646,
|
||||
-0.2229624279, -0.4381991822, 1.0082401405, -0.3186555860, -0.0624691529,
|
||||
-0.5189085756, 1.4269672156, 0.1163282969, 1.4020183445, -0.0952660426,
|
||||
|
@ -143,7 +146,8 @@ const double gu_data [] = { // just some numbers, no structure
|
|||
-1.2421792262, -1.0724161722, -0.4276904972, 0.1801494950, -2.0716473264
|
||||
};
|
||||
|
||||
const double vdata2 [] = { // 10×10 positive definite
|
||||
const double vdata2[] =
|
||||
{ // 10×10 positive definite
|
||||
0.79666, -0.15536, 0.05667, -0.21026, 0.20262, 0.28505, 0.60341, -0.09703, 0.32363, 0.13299,
|
||||
-0.15536, 0.64380, -0.01131, 0.00980, 0.03755, 0.43791, 0.21784, -0.31755, -0.55911, -0.29655,
|
||||
0.05667, -0.01131, 0.56165, -0.34357, -0.40584, 0.20990, 0.28348, 0.20398, -0.19856, 0.35820,
|
||||
|
@ -156,7 +160,8 @@ const double vdata2 [] = { // 10×10 positive definite
|
|||
0.13299, -0.29655, 0.35820, -0.31560, -0.12919, -0.02155, -0.19016, 0.41750, -0.12992, 0.89608
|
||||
};
|
||||
|
||||
const double gy_data2 [] = { // 600 items make gy 30×20, whose gy(6:25,:) has spectrum within unit
|
||||
const double gy_data2[] =
|
||||
{ // 600 items make gy 30×20, whose gy(6:25,:) has spectrum within unit
|
||||
0.39414, -0.29766, 0.08948, -0.19204, -0.00750, 0.21159, 0.05494, 0.06225, 0.01771, 0.21913,
|
||||
-0.01373, 0.20086, -0.06086, -0.10955, 0.14424, -0.08390, 0.03948, -0.14713, 0.11674, 0.05091,
|
||||
0.24039, 0.28307, -0.11835, 0.13030, 0.11682, -0.27444, -0.19311, -0.16654, 0.12867, 0.25116,
|
||||
|
@ -219,7 +224,8 @@ const double gy_data2 [] = { // 600 items make gy 30×20, whose gy(6:25,:) has s
|
|||
-0.04680, -0.29441, 0.12231, 0.03960, -0.01188, 0.01406, 0.25402, 0.03315, 0.25026, -0.10922
|
||||
};
|
||||
|
||||
const double gu_data2 [] = { // raw data 300 items
|
||||
const double gu_data2[] =
|
||||
{ // raw data 300 items
|
||||
0.26599, 0.41329, 0.31846, 0.92590, 0.43050, 0.17466, 0.02322, 0.72621, 0.37921, 0.70597,
|
||||
0.97098, 0.14023, 0.57619, 0.09938, 0.02281, 0.92341, 0.72654, 0.71000, 0.76687, 0.70182,
|
||||
0.88752, 0.49524, 0.42549, 0.42806, 0.57615, 0.76051, 0.15341, 0.47457, 0.60066, 0.40880,
|
||||
|
|
|
@ -29,8 +29,8 @@ class DynareException
|
|||
std::string mes;
|
||||
public:
|
||||
DynareException(const std::string &m, const std::string &fname, int line, int col)
|
||||
: mes{"Parse error at " + fname + ", line " + std::to_string(line) + ", column " +
|
||||
std::to_string(col) + ": " + m}
|
||||
: mes{"Parse error at " + fname + ", line " + std::to_string(line) + ", column "
|
||||
+ std::to_string(col) + ": " + m}
|
||||
{
|
||||
}
|
||||
DynareException(const std::string &fname, int line, const std::string &m)
|
||||
|
|
|
@ -51,7 +51,8 @@ DynareParams::DynareParams(int argc, char **argv)
|
|||
modname = argv[argc-1];
|
||||
argc--;
|
||||
|
||||
struct option const opts [] = {
|
||||
struct option const opts[] =
|
||||
{
|
||||
{"periods", required_argument, nullptr, static_cast<int>(opt::per)},
|
||||
{"per", required_argument, nullptr, static_cast<int>(opt::per)},
|
||||
{"burn", required_argument, nullptr, static_cast<int>(opt::burn)},
|
||||
|
|
|
@ -87,7 +87,6 @@ PlannerBuilder::PlannerBuilder(const PlannerBuilder &pb, ogdyn::DynareModel &m)
|
|||
diff_b_static(pb.diff_b_static),
|
||||
diff_f_static(pb.diff_f_static),
|
||||
aux_map(), static_aux_map()
|
||||
|
||||
{
|
||||
fill_yset(m.atoms.get_name_storage(), pb.yset);
|
||||
fill_aux_map(m.atoms.get_name_storage(), pb.aux_map, pb.static_aux_map);
|
||||
|
|
|
@ -42,7 +42,9 @@ class TransposedMatrix
|
|||
private:
|
||||
T &orig;
|
||||
public:
|
||||
TransposedMatrix(T &orig_arg) : orig{orig_arg} {};
|
||||
TransposedMatrix(T &orig_arg) : orig{orig_arg}
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
// Syntactic sugar for representing a transposed matrix
|
||||
|
|
|
@ -86,7 +86,8 @@
|
|||
class PerTensorDimens : public TensorDimens
|
||||
{
|
||||
private:
|
||||
static IntSequence sortIntSequence(IntSequence s)
|
||||
static IntSequence
|
||||
sortIntSequence(IntSequence s)
|
||||
{
|
||||
s.sort();
|
||||
return s;
|
||||
|
|
|
@ -136,7 +136,8 @@ public:
|
|||
insert(std::make_unique<_Ttype>(first_row, num, *(it.second)));
|
||||
}
|
||||
|
||||
TensorContainer<_Ttype> &operator=(const TensorContainer<_Ttype> &c)
|
||||
TensorContainer<_Ttype> &
|
||||
operator=(const TensorContainer<_Ttype> &c)
|
||||
{
|
||||
n = c.n;
|
||||
m.clear();
|
||||
|
|
|
@ -101,7 +101,8 @@ public:
|
|||
struct dummy { using type = T; };
|
||||
|
||||
template<class T>
|
||||
const T &getNext()
|
||||
const T &
|
||||
getNext()
|
||||
{
|
||||
return getNext(dummy<T>());
|
||||
}
|
||||
|
|
|
@ -71,8 +71,8 @@ class TLException
|
|||
{
|
||||
const std::string fname;
|
||||
int lnum;
|
||||
const std::string message;
|
||||
public:
|
||||
const std::string message;
|
||||
TLException(std::string fname_arg, int lnum_arg, std::string message_arg)
|
||||
: fname{std::move(fname_arg)},
|
||||
lnum{lnum_arg},
|
||||
|
|
|
@ -142,7 +142,6 @@ public:
|
|||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
~TwoDMatrix() override = default;
|
||||
|
||||
TwoDMatrix &operator=(const TwoDMatrix &m) = default;
|
||||
|
|
|
@ -68,7 +68,6 @@ PascalRow::print() const
|
|||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
|
||||
namespace PascalTriangle
|
||||
{
|
||||
namespace // Anonymous namespace that is a functional equivalent of “private”
|
||||
|
|
|
@ -29,11 +29,10 @@
|
|||
*
|
||||
* Please note that the following copyright notice only applies to this Dynare
|
||||
* implementation of the model.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013-2016 Dynare Team
|
||||
* Copyright (C) 2013-2020 Dynare Team
|
||||
*
|
||||
* This file is part of Dynare.
|
||||
*
|
||||
|
@ -51,72 +50,78 @@
|
|||
* along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
var d //preference shock
|
||||
c //consumption
|
||||
mu_z //trend growth rate of the economy (from neutral and investment specific technology)
|
||||
mu_I //growth rate of investment-specific technology growth
|
||||
mu_A //growth rate of neutral technology
|
||||
lambda //Lagrange multiplier
|
||||
R //Nominal Interest rate
|
||||
PI //Inflation
|
||||
r //rental rate of capital
|
||||
x //investment
|
||||
u //capacity utilization
|
||||
q //Tobin's marginal q
|
||||
f //variable for recursive formulation of wage setting
|
||||
ld //aggregate labor demand
|
||||
w //real wage
|
||||
wstar //optimal real wage
|
||||
PIstarw //optimal wage inflation
|
||||
PIstar //optimal price inflation
|
||||
g1 //variable 1 for recursive formulation of price setting
|
||||
g2 //variable 2 for recursive formulation of price setting
|
||||
yd //aggregate output
|
||||
mc //marginal costs
|
||||
k //capital
|
||||
vp //price dispersion term
|
||||
vw //wage dispersion term
|
||||
l //aggregate labor bundle
|
||||
phi //labor disutility shock
|
||||
F; //firm profits
|
||||
var d (long_name='preference shock')
|
||||
c (long_name='consumption')
|
||||
mu_z (long_name='trend growth rate of the economy (from neutral and investment specific technology)')
|
||||
mu_I (long_name='growth rate of investment-specific technology growth')
|
||||
mu_A (long_name='growth rate of neutral technology')
|
||||
lambda (long_name='Lagrange multiplier')
|
||||
R (long_name='Nominal Interest rate')
|
||||
PI (long_name='Inflation')
|
||||
r (long_name='rental rate of capital')
|
||||
x (long_name='investment')
|
||||
u (long_name='capacity utilization')
|
||||
q (long_name='Tobin marginal q')
|
||||
f (long_name='variable for recursive formulation of wage setting')
|
||||
ld (long_name='aggregate labor demand')
|
||||
w (long_name='real wage')
|
||||
wstar (long_name='optimal real wage')
|
||||
PIstarw (long_name='optimal wage inflation')
|
||||
PIstar (long_name='optimal price inflation')
|
||||
g1 (long_name='variable 1 for recursive formulation of price setting')
|
||||
g2 (long_name='variable 2 for recursive formulation of price setting')
|
||||
yd (long_name='aggregate output')
|
||||
mc (long_name='marginal costs')
|
||||
k (long_name='capital')
|
||||
vp (long_name='price dispersion term')
|
||||
vw (long_name='wage dispersion term')
|
||||
l (long_name='aggregate labor bundle')
|
||||
phi (long_name='labor disutility shock')
|
||||
F (long_name='firm profits')
|
||||
;
|
||||
|
||||
varexo epsd epsphi epsmu_I epsA epsm;
|
||||
varexo epsd (long_name='Innovation preference shock')
|
||||
epsphi (long_name='Innovation labor disutility shock')
|
||||
epsmu_I (long_name='Innovation investment-specific technology')
|
||||
epsA (long_name='Innovation neutral technology')
|
||||
epsm (long_name='Innovation monetary policy shock')
|
||||
;
|
||||
|
||||
predetermined_variables k;
|
||||
|
||||
parameters h //consumption habits
|
||||
betta //discount factor
|
||||
gammma1 //capital utilization, linear term
|
||||
gammma2 //capital utilization, quadratic term
|
||||
delta //depreciation rate
|
||||
kappa //capital adjustment costs parameter
|
||||
eta //elasticity of substitution between labor varieties
|
||||
epsilon //elasticity of substitution between goods varieties
|
||||
varpsi //labor disutility parameter
|
||||
gammma //inverse Frisch elasticity
|
||||
chiw //wage indexation parameter
|
||||
chi //price indexation
|
||||
thetap //Calvo parameter prices
|
||||
thetaw //Calvo parameter wages
|
||||
alppha //capital share
|
||||
Rbar //steady state interest rate
|
||||
PIbar //steady state inflation
|
||||
gammmaR //interest smoothing coefficient Taylor rule
|
||||
gammmaPI //feedback coefficient to inflation monetary policy rule
|
||||
gammmay //feedback coefficient to output growth deviation in monetary policy rule
|
||||
Phi //firms fixed costs
|
||||
rhod //autocorrelation preference shock
|
||||
rhophi //autocorrelation labor disutility shock
|
||||
Lambdamu //steady state growth rate of investmentment-specific technology
|
||||
LambdaA //steady state neutral technology growth
|
||||
Lambdax //steady state growth rate of investment
|
||||
LambdaYd //steady state growth rate of output
|
||||
sigma_d //standard deviation preference shock
|
||||
sigma_phi //standard deviation labor disutility shock
|
||||
sigma_mu //standard deviation investment-specific technology
|
||||
sigma_A //standard deviation neutral technology
|
||||
sigma_m; //standard deviation preference shock
|
||||
|
||||
parameters h (long_name='consumption habits')
|
||||
betta (long_name='discount factor')
|
||||
gammma1 (long_name='capital utilization, linear term')
|
||||
gammma2 (long_name='capital utilization, quadratic term')
|
||||
delta (long_name='depreciation rate')
|
||||
kappa (long_name='capital adjustment costs parameter')
|
||||
eta (long_name='elasticity of substitution between labor varieties')
|
||||
epsilon (long_name='elasticity of substitution between goods varieties')
|
||||
varpsi (long_name='labor disutility parameter')
|
||||
gammma (long_name='inverse Frisch elasticity')
|
||||
chiw (long_name='wage indexation parameter')
|
||||
chi (long_name='price indexation')
|
||||
thetap (long_name='Calvo parameter prices')
|
||||
thetaw (long_name='Calvo parameter wages')
|
||||
alppha (long_name='capital share')
|
||||
Rbar (long_name='steady state interest rate')
|
||||
PIbar (long_name='steady state inflation')
|
||||
gammmaR (long_name='interest smoothing coefficient Taylor rule')
|
||||
gammmaPI (long_name='feedback coefficient to inflation monetary policy rule')
|
||||
gammmay (long_name='feedback coefficient to output growth deviation in monetary policy rule')
|
||||
Phi (long_name='firms fixed costs')
|
||||
rhod (long_name='autocorrelation preference shock')
|
||||
rhophi (long_name='autocorrelation labor disutility shock')
|
||||
Lambdamu (long_name='steady state growth rate of investmentment-specific technology')
|
||||
LambdaA (long_name='steady state neutral technology growth')
|
||||
Lambdax (long_name='steady state growth rate of investment')
|
||||
LambdaYd (long_name='steady state growth rate of output')
|
||||
sigma_d (long_name='standard deviation preference shock')
|
||||
sigma_phi (long_name='standard deviation labor disutility shock')
|
||||
sigma_mu (long_name='standard deviation investment-specific technology')
|
||||
sigma_A (long_name='standard deviation neutral technology')
|
||||
sigma_m (long_name='standard deviation monetary policy shock')
|
||||
;
|
||||
|
||||
//Note that the parameter naming in FV(2010) differs from FV(2006)
|
||||
//Fixed parameters, taken from FV(2010), Table 2, p. 37
|
||||
|
@ -177,60 +182,67 @@ FV(2006), p. 20, section 3.2.
|
|||
*/
|
||||
|
||||
model;
|
||||
//1. FOC consumption
|
||||
[name='FOC consumption']
|
||||
d*(c-h*c(-1)*mu_z^(-1))^(-1)-h*betta*d(+1)*(c(+1)*mu_z(+1)-h*c)^(-1)=lambda;
|
||||
//2. Euler equation
|
||||
[name='Euler equation']
|
||||
lambda=betta*lambda(+1)*mu_z(+1)^(-1)/PI(+1)*R;
|
||||
//3. FOC capital utilization
|
||||
[name='FOC capital utilization']
|
||||
r=gammma1+gammma2*(u-1);
|
||||
//4. FOC capital
|
||||
[name='FOC capital']
|
||||
q=betta*lambda(+1)/lambda*mu_z(+1)^(-1)*mu_I(+1)^(-1)*((1-delta)*q(+1)+r(+1)*u(+1)-(gammma1*(u(+1)-1)+gammma2/2*(u(+1)-1)^2));
|
||||
//5. FOC investment
|
||||
[name='FOC investment']
|
||||
1=q*(1-(kappa/2*(x/x(-1)*mu_z-Lambdax)^2)-(kappa*(x/x(-1)*mu_z-Lambdax)*x/x(-1)*mu_z))
|
||||
+betta*q(+1)*lambda(+1)/lambda*mu_z(+1)^(-1)*kappa*(x(+1)/x*mu_z(+1)-Lambdax)*(x(+1)/x*mu_z(+1))^2;
|
||||
//6-7. Wage setting
|
||||
[name='Wage setting 1']
|
||||
f=(eta-1)/eta*wstar^(1-eta)*lambda*w^eta*ld+betta*thetaw*(PI^chiw/PI(+1))^(1-eta)*(wstar(+1)/wstar*mu_z(+1))^(eta-1)*f(+1);
|
||||
[name='Wage setting 2']
|
||||
f=varpsi*d*phi*PIstarw^(-eta*(1+gammma))*ld^(1+gammma)+betta*thetaw*(PI^chiw/PI(+1))^(-eta*(1+gammma))*(wstar(+1)/wstar*mu_z(+1))^(eta*(1+gammma))*f(+1);
|
||||
|
||||
//8-10. firm's price setting
|
||||
[name='Firm price setting 1']
|
||||
g1=lambda*mc*yd+betta*thetap*(PI^chi/PI(+1))^(-epsilon)*g1(+1);
|
||||
[name='Firm price setting 2']
|
||||
g2=lambda*PIstar*yd+betta*thetap*(PI^chi/PI(+1))^(1-epsilon)*PIstar/PIstar(+1)*g2(+1);
|
||||
[name='Firm price setting 3']
|
||||
epsilon*g1=(epsilon-1)*g2;
|
||||
//11-12. optimal inputs
|
||||
[name='Optimal capital labor ratio']
|
||||
u*k/ld=alppha/(1-alppha)*w/r*mu_z*mu_I;
|
||||
[name='Marginal costs']
|
||||
mc=(1/(1-alppha))^(1-alppha)*(1/alppha)^alppha*w^(1-alppha)*r^alppha;
|
||||
//13. law of motion wages
|
||||
[name='law of motion wages']
|
||||
1=thetaw*(PI(-1)^chiw/PI)^(1-eta)*(w(-1)/w*mu_z^(-1))^(1-eta)+(1-thetaw)*PIstarw^(1-eta);
|
||||
//14. law of motion prices
|
||||
[name='law of motion prices']
|
||||
1=thetap*(PI(-1)^chi/PI)^(1-epsilon)+(1-thetap)*PIstar^(1-epsilon);
|
||||
|
||||
//15. Taylor Rule
|
||||
[name='Taylor Rule']
|
||||
R/Rbar=(R(-1)/Rbar)^gammmaR*((PI/PIbar)^gammmaPI*((yd/yd(-1)*mu_z)/exp(LambdaYd))^gammmay)^(1-gammmaR)*exp(epsm);
|
||||
|
||||
//16-17. Market clearing
|
||||
[name='Resource constraint']
|
||||
yd=c+x+mu_z^(-1)*mu_I^(-1)*(gammma1*(u-1)+gammma2/2*(u-1)^2)*k;
|
||||
[name='Aggregate production']
|
||||
yd=(mu_A*mu_z^(-1)*(u*k)^alppha*ld^(1-alppha)-Phi)/vp;
|
||||
//18-20. Price and wage dispersion terms
|
||||
[name='Aggregate labor market']
|
||||
l=vw*ld;
|
||||
[name='LOM Price dispersion term']
|
||||
vp=thetap*(PI(-1)^chi/PI)^(-epsilon)*vp(-1)+(1-thetap)*PIstar^(-epsilon);
|
||||
[name='LOM Wage dispersion term']
|
||||
vw=thetaw*(w(-1)/w*mu_z^(-1)*PI(-1)^chiw/PI)^(-eta)*vw(-1)+(1-thetaw)*(PIstarw)^(-eta);
|
||||
//21. Law of motion for capital
|
||||
[name='Law of motion for capital']
|
||||
k(+1)*mu_z*mu_I-(1-delta)*k-mu_z*mu_I*(1-kappa/2*(x/x(-1)*mu_z-Lambdax)^2)*x=0;
|
||||
//22. Profits
|
||||
[name='Profits']
|
||||
F=yd-1/(1-alppha)*w*ld;
|
||||
//23. definition optimal wage inflation
|
||||
[name='definition optimal wage inflation']
|
||||
PIstarw=wstar/w;
|
||||
|
||||
//exogenous processes
|
||||
//24. Preference Shock
|
||||
[name='Preference Shock']
|
||||
log(d)=rhod*log(d(-1))+epsd;
|
||||
//25. Labor disutility Shock
|
||||
[name='Labor disutility Shock']
|
||||
log(phi)=rhophi*log(phi(-1))+epsphi;
|
||||
//26. Investment specific technology
|
||||
[name='Investment specific technology']
|
||||
log(mu_I)=Lambdamu+epsmu_I;
|
||||
//27. Neutral technology
|
||||
[name='Neutral technology']
|
||||
log(mu_A)=LambdaA+epsA;
|
||||
//28. Defininition composite technology
|
||||
[name='Defininition composite technology']
|
||||
mu_z=mu_A^(1/(1-alppha))*mu_I^(alppha/(1-alppha));
|
||||
|
||||
end;
|
||||
|
|
|
@ -15,6 +15,23 @@ function [ys,params,check] = NK_baseline_steadystate(ys,exo,M_,options_)
|
|||
% - check [scalar] set to 0 if steady state computation worked and to
|
||||
% 1 of not (allows to impose restrictions on parameters)
|
||||
|
||||
% Copyright (C) 2013-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
% read out parameters to access them with their name
|
||||
NumberOfParameters = M_.param_nbr;
|
||||
for ii = 1:NumberOfParameters
|
||||
|
|
|
@ -0,0 +1,239 @@
|
|||
/*
|
||||
* This file replicates the model studied in:
|
||||
* Lawrence J. Christiano, Roberto Motto and Massimo Rostagno (2007):
|
||||
* "Notes on Ramsey-Optimal Monetary Policy", Section 2
|
||||
* The paper is available at http://faculty.wcas.northwestern.edu/~lchrist/d16/d1606/ramsey.pdf
|
||||
*
|
||||
* Notes:
|
||||
* - This mod-files allows to simulate a simple New Keynesian Model with Rotemberg price
|
||||
* adjustment costs under three different monetary policy arrangements:
|
||||
* 1. a Taylor rule with a fixed inflation feedback coefficient alpha
|
||||
* -> set the Optimal_policy switch to 0
|
||||
* 2. a Taylor rule where the inflation feedback coefficient alpha is chosen
|
||||
* optimally to minimize a quadratic loss function (optimal simple rule (OSR))
|
||||
* -> set the Optimal_policy switch to 1 and the Ramsey switch to 0
|
||||
* 3. fully optimal monetary under commitment (Ramsey)
|
||||
* -> set the Optimal_policy switch to 1 and the Ramsey switch to 1
|
||||
*
|
||||
* - The Efficent_steady_state switch can be used to switch from an distorted steady state
|
||||
* due to a monopolistic distortion to one where a labor subsidy counteracts this
|
||||
* distortion. Note that the purely quadratic loss function in the OSR case does not capture
|
||||
* the full welfare losses with a distorted steady state as there would be a linear term
|
||||
* appearing.
|
||||
*
|
||||
* - This files shows how to use a conditional steady state file in the Ramsey case. It takes
|
||||
* the value of the defined instrument R as given and then computes the rest of the steady
|
||||
* state, including the steady state inflation rate, based on this value. The initial value
|
||||
* of the instrument for steady state search must then be defined in an initval-block.
|
||||
*
|
||||
* - The optim_weights in the OSR case are based on a second order approximation to the welfare function
|
||||
* as in Gali (2015). The relative weight between inflation and output gap volatility is essentially
|
||||
* given by the slope of the New Keynesian Phillips Curve. Note that the linear terms that would be
|
||||
* present in case of a distorted steady state need to be dropped for OSR.
|
||||
*
|
||||
* - Due to divine coincidence, the first best policy involves fully stabilizing inflation
|
||||
* and thereby the output gap. As a consequence, the optimal inflation feedback coefficient
|
||||
* in a Taylor rule would be infinity. The OSR command therefore estimates it to be at the
|
||||
* upper bound defined via osr_params_bounds.
|
||||
*
|
||||
* - The mod-file also allows to conduct estimation under Ramsey policy by setting the
|
||||
* Estimation_under_Ramsey switch to 1.
|
||||
*
|
||||
* This implementation was written by Johannes Pfeifer.
|
||||
*
|
||||
* If you spot mistakes, email me at jpfeifer@gmx.de
|
||||
*
|
||||
* Please note that the following copyright notice only applies to this Dynare
|
||||
* implementation of the model.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2019 Dynare Team
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* It is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* For a copy of the GNU General Public License,
|
||||
* see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//**********Define which monetary policy setup to use ***********
|
||||
|
||||
@#ifndef Optimal_policy
|
||||
@#define Optimal_policy=1
|
||||
@#ifndef Ramsey
|
||||
@#define Ramsey=1
|
||||
@#endif
|
||||
@#endif
|
||||
|
||||
//**********Define whether to use distorted steady state***********
|
||||
|
||||
@#ifndef Efficent_steady_state
|
||||
@#define Efficent_steady_state=0
|
||||
@#endif
|
||||
|
||||
@#ifndef Estimation_under_Ramsey
|
||||
@#define Estimation_under_Ramsey=0
|
||||
@#endif
|
||||
|
||||
var C $C$ (long_name='Consumption')
|
||||
pi $\pi$ (long_name='Gross inflation')
|
||||
h $h$ (long_name='hours worked')
|
||||
Z $Z$ (long_name='TFP')
|
||||
R $R$ (long_name='Net nominal interest rate')
|
||||
log_C ${\ln C}$ (long_name='Log Consumption')
|
||||
log_h ${\ln h}$ (long_name='Log hours worked')
|
||||
pi_ann ${\pi^{ann}}$ (long_name='Annualized net inflation')
|
||||
R_ann ${R^{ann}}$ (long_name='Annualized net nominal interest rate')
|
||||
r_real ${r^{ann,real}}$ (long_name='Annualized net real interest rate')
|
||||
y_nat ${y^{nat}}$ (long_name='Natural (flex price) output')
|
||||
y_gap ${r^{gap}}$ (long_name='Output gap')
|
||||
;
|
||||
|
||||
varexo epsilon ${\varepsilon}$ (long_name='TFP shock')
|
||||
;
|
||||
|
||||
parameters beta ${\beta}$ (long_name='discount factor')
|
||||
theta ${\theta}$ (long_name='substitution elasticity')
|
||||
tau ${\tau}$ (long_name='labor subsidy')
|
||||
chi ${\chi}$ (long_name='labor disutility')
|
||||
phi ${\phi}$ (long_name='price adjustment costs')
|
||||
rho ${\rho}$ (long_name='TFP autocorrelation')
|
||||
@# if !defined(Ramsey) || Ramsey==0
|
||||
pi_star ${\pi^*}$ (long_name='steady state inflation')
|
||||
alpha ${\alpha}$ (long_name='inflation feedback Taylor rule')
|
||||
@# endif
|
||||
;
|
||||
|
||||
beta=0.99;
|
||||
theta=5;
|
||||
phi=100;
|
||||
rho=0.9;
|
||||
@# if !defined(Ramsey) || Ramsey==0
|
||||
alpha=1.5;
|
||||
pi_star=1;
|
||||
@# endif
|
||||
@# if Efficent_steady_state
|
||||
tau=1/(theta-1);
|
||||
@# else
|
||||
tau=0;
|
||||
@# endif
|
||||
chi=1;
|
||||
|
||||
model;
|
||||
[name='Euler equation']
|
||||
1/(1+R)=beta*C/(C(+1)*pi(+1));
|
||||
[name='Firm FOC']
|
||||
(tau-1/(theta-1))*(1-theta)+theta*(chi*h*C/(exp(Z))-1)=phi*(pi-1)*pi-beta*phi*(pi(+1)-1)*pi(+1);
|
||||
[name='Resource constraint']
|
||||
C*(1+phi/2*(pi-1)^2)=exp(Z)*h;
|
||||
[name='TFP process']
|
||||
Z=rho*Z(-1)+epsilon;
|
||||
@#if !defined(Ramsey) || Ramsey==0
|
||||
[name='Taylor rule']
|
||||
R=pi_star/beta-1+alpha*(pi-pi_star);
|
||||
@#endif
|
||||
[name='Definition log consumption']
|
||||
log_C=log(C);
|
||||
[name='Definition log hours worked']
|
||||
log_h=log(h);
|
||||
[name='Definition annualized inflation rate']
|
||||
pi_ann=4*log(pi);
|
||||
[name='Definition annualized nominal interest rate']
|
||||
R_ann=4*R;
|
||||
[name='Definition annualized real interest rate']
|
||||
r_real=4*log((1+R)/pi(+1));
|
||||
[name='Definition natural output']
|
||||
y_nat=exp(Z)*sqrt((theta-1)/theta*(1+tau)/chi);
|
||||
[name='output gap']
|
||||
y_gap=log_C-log(y_nat);
|
||||
end;
|
||||
|
||||
steady_state_model;
|
||||
Z=0;
|
||||
@# if !defined(Ramsey) || Ramsey==0
|
||||
R=pi_star/beta-1; %only set this if not conditional steady state file for Ramsey
|
||||
@# endif
|
||||
pi=(R+1)*beta;
|
||||
C=sqrt((1+1/theta*((1-beta)*(pi-1)*pi-(tau-1/(theta-1))*(1-theta)))/(chi*(1+phi/2*(pi-1)^2)));
|
||||
h=C*(1+phi/2*(pi-1)^2);
|
||||
log_C=log(C);
|
||||
log_h=log(h);
|
||||
pi_ann=4*log(pi);
|
||||
R_ann=4*R;
|
||||
r_real=4*log((1+R)/pi);
|
||||
y_nat=sqrt((theta-1)/theta*(1+tau)/chi);
|
||||
y_gap=log_C-log(y_nat);
|
||||
end;
|
||||
|
||||
@# if defined(Ramsey) && Ramsey==1
|
||||
//define initial value of instrument for Ramsey
|
||||
initval;
|
||||
R=1/beta-1;
|
||||
end;
|
||||
@# endif
|
||||
|
||||
shocks;
|
||||
var epsilon = 0.01^2;
|
||||
end;
|
||||
|
||||
@#if Optimal_policy==0
|
||||
//use Taylor rule
|
||||
stoch_simul(order=2) pi_ann log_h R_ann log_C Z r_real y_nat;
|
||||
@#else
|
||||
@# if !defined(Ramsey) || Ramsey==0
|
||||
//use OSR Taylor rule
|
||||
|
||||
//set weights on (co-)variances for OSR
|
||||
optim_weights;
|
||||
pi theta/((theta-1)/phi);
|
||||
y_gap 1;
|
||||
end;
|
||||
|
||||
//define OSR parameters to be optimized
|
||||
osr_params alpha;
|
||||
|
||||
//starting value for OSR parameter
|
||||
alpha = 1.5;
|
||||
|
||||
//define bounds for OSR during optimization
|
||||
osr_params_bounds;
|
||||
alpha, 0, 100;
|
||||
end;
|
||||
|
||||
//compute OSR and provide output
|
||||
osr(opt_algo=9) pi_ann log_h R_ann log_C Z r_real;
|
||||
|
||||
@# else
|
||||
//use Ramsey optimal policy
|
||||
|
||||
//define planner objective, which corresponds to utility function of agents
|
||||
planner_objective log(C)-chi/2*h^2;
|
||||
|
||||
//set up Ramsey optimal policy problem with interest rate R as the instrument,...
|
||||
// defining the discount factor in the planner objective to be the one of private agents
|
||||
ramsey_model(instruments=(R),planner_discount=beta,planner_discount_latex_name=$\beta$);
|
||||
|
||||
//conduct stochastic simulations of the Ramsey problem
|
||||
stoch_simul(order=1,irf=20,periods=500) pi_ann log_h R_ann log_C Z r_real;
|
||||
evaluate_planner_objective;
|
||||
|
||||
@# if Estimation_under_Ramsey==1
|
||||
datatomfile('ramsey_simulation',{'log_C'})
|
||||
|
||||
estimated_params;
|
||||
rho,0.5,uniform_pdf, , ,0,1;
|
||||
end;
|
||||
varobs log_C;
|
||||
|
||||
estimation(datafile=ramsey_simulation,mode_compute=5);
|
||||
@# endif
|
||||
@# endif
|
||||
@# endif
|
|
@ -1,57 +0,0 @@
|
|||
module Dynare
|
||||
|
||||
##
|
||||
# Copyright © 2015-2016 Dynare Team
|
||||
#
|
||||
# This file is part of Dynare.
|
||||
#
|
||||
# Dynare is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Dynare is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
export @compile, @dynare
|
||||
|
||||
function compile(modfile)
|
||||
# Add cd to path if not already there
|
||||
if isempty(findin([pwd()], LOAD_PATH))
|
||||
unshift!(LOAD_PATH, pwd())
|
||||
end
|
||||
# Process modfile
|
||||
println(string("Using ", Sys.WORD_SIZE, "-bit preprocessor"))
|
||||
preprocessor = string(dirname(@__FILE__()), "/preprocessor", Sys.WORD_SIZE, "/dynare_m")
|
||||
run(`$preprocessor $modfile language=julia output=dynamic`)
|
||||
end
|
||||
|
||||
macro dynare(modfiles...)
|
||||
ex = Expr(:toplevel)
|
||||
if length(modfiles)>1
|
||||
for modfile in modfiles
|
||||
eval(:(compile($modfile)))
|
||||
basename = split(modfile, ".mod"; keep=false)
|
||||
push!(ex.args, Expr(:import, Symbol(basename[1])))
|
||||
end
|
||||
else
|
||||
eval(:(compile($modfiles)))
|
||||
basename = split(modfiles[1], ".mod"; keep=false)
|
||||
push!(ex.args, Expr(:importall, Symbol(basename[1])))
|
||||
end
|
||||
return ex
|
||||
end
|
||||
|
||||
macro compile(modfiles...)
|
||||
for modfile in modfiles
|
||||
eval(:(compile($modfile)))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,197 +0,0 @@
|
|||
module DynareModel
|
||||
##
|
||||
# Copyright © 2015-2018 Dynare Team
|
||||
#
|
||||
# This file is part of Dynare.
|
||||
#
|
||||
# Dynare is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Dynare is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
export Model, Endo, Exo, ExoDet, Param, dynare_model
|
||||
|
||||
abstract type Atom end
|
||||
|
||||
immutable Endo <: Atom
|
||||
name::String
|
||||
tex_name::String
|
||||
long_name::String
|
||||
end
|
||||
|
||||
immutable Exo <: Atom
|
||||
name::String
|
||||
tex_name::String
|
||||
long_name::String
|
||||
end
|
||||
|
||||
immutable ExoDet <: Atom
|
||||
name::String
|
||||
tex_name::String
|
||||
long_name::String
|
||||
end
|
||||
|
||||
immutable Param <: Atom
|
||||
name::String
|
||||
tex_name::String
|
||||
long_name::String
|
||||
end
|
||||
|
||||
immutable AuxVars
|
||||
endo_index::Int
|
||||
var_type::Int
|
||||
orig_index::Int
|
||||
orig_lead_lag::Int
|
||||
eq_nbr::Int
|
||||
orig_expr::String
|
||||
end
|
||||
|
||||
immutable PredVars
|
||||
index::Int
|
||||
end
|
||||
|
||||
immutable ObsVars
|
||||
index::Int
|
||||
end
|
||||
|
||||
immutable DetShocks
|
||||
exo_det::Int
|
||||
exo_id::Int
|
||||
multiplicative::Bool
|
||||
periods::Vector{Int}
|
||||
value::Float64
|
||||
end
|
||||
|
||||
immutable EquationTag
|
||||
eq_nbr::Int
|
||||
name::String
|
||||
value::String
|
||||
end
|
||||
|
||||
type Model
|
||||
fname::String
|
||||
dname::String
|
||||
dynare_version::String
|
||||
endo::Vector{Endo}
|
||||
exo::Vector{Exo}
|
||||
exo_det::Vector{ExoDet}
|
||||
param::Vector{Param}
|
||||
aux_vars::Vector{AuxVars}
|
||||
pred_vars::Vector{Int}
|
||||
obs_vars::Vector{Int}
|
||||
state_var::Vector{Int}
|
||||
orig_endo_nbr::Int
|
||||
orig_eq_nbr::Int
|
||||
eq_nbr::Int
|
||||
ramsey_eq_nbr::Int
|
||||
det_shocks::Vector{DetShocks}
|
||||
nstatic::Int
|
||||
nfwrd::Int
|
||||
npred::Int
|
||||
nboth::Int
|
||||
nsfwrd::Int
|
||||
nspred::Int
|
||||
ndynamic::Int
|
||||
maximum_lag::Int
|
||||
maximum_lead::Int
|
||||
maximum_endo_lag::Int
|
||||
maximum_endo_lead::Int
|
||||
maximum_exo_lag::Int
|
||||
maximum_exo_lead::Int
|
||||
orig_maximum_lag::Int
|
||||
orig_maximum_lead::Int
|
||||
orig_maximum_endo_lag::Int
|
||||
orig_maximum_endo_lead::Int
|
||||
orig_maximum_exo_lag::Int
|
||||
orig_maximum_exo_lead::Int
|
||||
orig_maximum_exo_det_lag::Int
|
||||
orig_maximum_exo_det_lead::Int
|
||||
lead_lag_incidence::Matrix{Int}
|
||||
nnzderivatives::Vector{Int}
|
||||
analytical_steady_state::Bool
|
||||
user_written_analytical_steady_state::Bool
|
||||
static_and_dynamic_models_differ::Bool
|
||||
equation_tags::Vector{String}
|
||||
exo_names_orig_ord::Vector{Int}
|
||||
sigma_e::Matrix{Float64}
|
||||
correlation_matrix::Matrix{Float64}
|
||||
h::Matrix{Float64}
|
||||
correlation_matrix_me::Matrix{Float64}
|
||||
sigma_e_is_diagonal::Bool
|
||||
params::Vector{Float64}
|
||||
static::Function
|
||||
static_params_derivs::Function
|
||||
dynamic::Function
|
||||
dynamic_params_derivs::Function
|
||||
steady_state::Function
|
||||
end
|
||||
|
||||
function dynare_model()
|
||||
return Model("", # fname
|
||||
"", # dname
|
||||
"", # dynare_version
|
||||
Vector{Endo}(), # endo
|
||||
Vector{Exo}(), # exo
|
||||
Vector{ExoDet}(), # exo_det
|
||||
Vector{Param}(), # param
|
||||
Vector{AuxVars}(), # aux_vars
|
||||
Vector{Int}(), # pred_vars
|
||||
Vector{Int}(), # obs_vars
|
||||
Vector{Int}(), # state_var
|
||||
0, # orig_endo_nbr
|
||||
0, # orig_eq_nbr
|
||||
0, # eq_nbr
|
||||
0, # ramsey_eq_nbr
|
||||
Vector{DetShocks}(), # det_shocks
|
||||
0, # nstatic
|
||||
0, # nfwrd
|
||||
0, # npred
|
||||
0, # nboth
|
||||
0, # nsfwrd
|
||||
0, # nspred
|
||||
0, # ndynamic
|
||||
0, # maximum_lag
|
||||
0, # maximum_lead
|
||||
0, # maximum_endo_lag
|
||||
0, # maximum_endo_lead
|
||||
0, # maximum_exo_lag
|
||||
0, # maximum_exo_lead
|
||||
0, # orig_maximum_lag
|
||||
0, # orig_maximum_lead
|
||||
0, # orig_maximum_endo_lag
|
||||
0, # orig_maximum_endo_lead
|
||||
0, # orig_maximum_exo_lag
|
||||
0, # orig_maximum_exo_lead
|
||||
0, # orig_maximum_exo_det_lag
|
||||
0, # orig_maximum_exo_det_lead
|
||||
Matrix{Int}(0,0), # lead_lag_incidence
|
||||
zeros(Int64,3), # nnzderivatives
|
||||
false, # analytical_steady_state
|
||||
false, # user_written_analytical_steady_state
|
||||
false, # static_and_dynamic_models_differ
|
||||
Vector{String}(), # equation_tags
|
||||
Vector{Int}(), # exo_names_orig_ord
|
||||
Matrix{Float64}(0,0), # sigma_e (Cov matrix of the structural innovations)
|
||||
Matrix{Float64}(0,0), # correlation_matrix (Corr matrix of the structural innovations)
|
||||
Matrix{Float64}(0,0), # h (Cov matrix of the measurement errors)
|
||||
Matrix{Float64}(0,0), # correlation_matrix_me (Cov matrix of the measurement errors)
|
||||
true, # sigma_e_is_diagonal
|
||||
Vector{Float64}(), # params
|
||||
function()end, # static
|
||||
function()end, # static_params_derivs
|
||||
function()end, # dynamic
|
||||
function()end, # dynamic_params_derivs
|
||||
function()end # steady_state
|
||||
)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,51 +0,0 @@
|
|||
module DynareOptions
|
||||
##
|
||||
# Copyright © 2015 Dynare Team
|
||||
#
|
||||
# This file is part of Dynare.
|
||||
#
|
||||
# Dynare is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Dynare is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
export Options, dynare_options
|
||||
|
||||
type PFMSolver
|
||||
maxit::Int
|
||||
periods::Int
|
||||
tolx::Float64
|
||||
tolf::Float64
|
||||
end
|
||||
|
||||
function pfmsolver_set_defaults()
|
||||
return PFMSolver(500, # maxit (Maximum number of iterations in Newton algorithm)
|
||||
400, # periods (Number of periods to return to the steady state)
|
||||
1e-6, # tolx (Tolerance criterion on the paths for the endogenous variables)
|
||||
1e-6 # tolf (Tolerance criterion on the stacked non linear equations)
|
||||
)
|
||||
end
|
||||
|
||||
type Options
|
||||
dynare_version::String
|
||||
linear::Bool
|
||||
pfmsolver::PFMSolver
|
||||
end
|
||||
|
||||
function dynare_options()
|
||||
return Options("", # dynare_version
|
||||
false, # linear
|
||||
pfmsolver_set_defaults() # pfmsolver
|
||||
)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,36 +0,0 @@
|
|||
module DynareOutput
|
||||
##
|
||||
# Copyright © 2015-2018 Dynare Team
|
||||
#
|
||||
# This file is part of Dynare.
|
||||
#
|
||||
# Dynare is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Dynare is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
export Ouput, dynare_output
|
||||
|
||||
type Output
|
||||
dynare_version::String
|
||||
steady_state::Vector{Float64}
|
||||
exo_steady_state::Vector{Float64}
|
||||
end
|
||||
|
||||
function dynare_output()
|
||||
return Output("", # dynare_version
|
||||
Vector{Float64}(), # steady_state
|
||||
Vector{Float64}() # exo_steady_state
|
||||
)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,134 +0,0 @@
|
|||
module PerfectForesightModelSolver
|
||||
|
||||
##
|
||||
# Copyright © 2016 Dynare Team
|
||||
#
|
||||
# This file is part of Dynare.
|
||||
#
|
||||
# Dynare is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Dynare is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
import DynareModel.Model
|
||||
import DynareOutput.Output
|
||||
import DynareOptions.Options
|
||||
|
||||
export simulate_perfect_foresight_model!
|
||||
|
||||
function simulate_perfect_foresight_model!(endogenousvariables::Matrix{Float64}, exogenousvariables::Matrix{Float64}, steadystate::Vector{Float64}, model::Model, options::Options)
|
||||
|
||||
lead_lag_incidence = model.lead_lag_incidence
|
||||
|
||||
nyp = countnz(lead_lag_incidence[1,:])
|
||||
ny0 = countnz(lead_lag_incidence[2,:])
|
||||
nyf = countnz(lead_lag_incidence[3,:])
|
||||
|
||||
ny = length(model.endo)
|
||||
nd = nyp+ny0+nyf
|
||||
|
||||
periods = options.pfmsolver.periods
|
||||
params = model.params
|
||||
|
||||
tmp = lead_lag_incidence[2:3,:]'
|
||||
i_cols_A1 = find(tmp)
|
||||
i_cols_1 = tmp[i_cols_A1]
|
||||
|
||||
tmp = lead_lag_incidence[1:2,:]'
|
||||
i_cols_AT = find(tmp)
|
||||
i_cols_T = tmp[i_cols_AT]
|
||||
|
||||
tmp = lead_lag_incidence[2,:]'
|
||||
i_cols_A0 = find(tmp)
|
||||
i_cols_0 = tmp[i_cols_A0]
|
||||
|
||||
i_cols_j = collect(1:nd)
|
||||
i_upd = ny+collect(1:periods*ny)
|
||||
|
||||
Y = vec(endogenousvariables)
|
||||
z = Y[find(lead_lag_incidence')]
|
||||
|
||||
jacobian = zeros(Float64, ny, length(z)+length(model.exo))
|
||||
residuals = zeros(Float64, ny)
|
||||
|
||||
println("\nMODEL SIMULATION:\n")
|
||||
|
||||
rd = zeros(Float64, periods*ny)
|
||||
|
||||
iA = zeros(Int64, periods*model.nnzderivatives[1])
|
||||
jA = zeros(Int64, periods*model.nnzderivatives[1])
|
||||
vA = zeros(Float64, periods*model.nnzderivatives[1])
|
||||
|
||||
convergence = false
|
||||
iteration = 0
|
||||
|
||||
while !convergence
|
||||
iteration += 1
|
||||
i_rows = collect(1:ny)
|
||||
i_cols_A = find(lead_lag_incidence')
|
||||
i_cols = i_cols_A
|
||||
m = 0
|
||||
for it = 2:(periods+1)
|
||||
model.dynamic(Y[i_cols], exogenousvariables, params, steadystate, it, residuals, jacobian)
|
||||
if it==(periods+1) & it==2
|
||||
(r, c, v) = findnz(jacobian[:,i_cols_0])
|
||||
k = collect(1:length(v))+m
|
||||
iA[k] = i_rows[r]
|
||||
jA[k] = i_cols_A0[c]
|
||||
vA[k] = v
|
||||
elseif it==(periods+1)
|
||||
(r, c, v) = findnz(jacobian[:,i_cols_T])
|
||||
k = collect(1:length(v))+m
|
||||
iA[k] = i_rows[r]
|
||||
jA[k] = i_cols_A[i_cols_T[c]]
|
||||
vA[k] = v
|
||||
elseif it==2
|
||||
(r, c, v) = findnz(jacobian[:,i_cols_1])
|
||||
k = collect(1:length(v))+m
|
||||
iA[k] = i_rows[r]
|
||||
jA[k] = i_cols_A1[c]
|
||||
vA[k] = v
|
||||
else
|
||||
(r, c, v) = findnz(jacobian[:,i_cols_j])
|
||||
k = collect(1:length(v))+m
|
||||
iA[k] = i_rows[r]
|
||||
jA[k] = i_cols_A[c]
|
||||
vA[k] = v
|
||||
end
|
||||
m += length(v)
|
||||
rd[i_rows] = residuals
|
||||
i_rows += ny
|
||||
i_cols += ny
|
||||
if it>2
|
||||
i_cols_A += ny
|
||||
end
|
||||
end
|
||||
err = maximum(abs.(rd))
|
||||
println("Iter. ", iteration, "\t err. ", round(err, 12))
|
||||
if err<options.pfmsolver.tolf
|
||||
iteration -= 1
|
||||
convergence = true
|
||||
end
|
||||
A = sparse(iA[1:m], jA[1:m], vA[1:m])
|
||||
dy = -A\rd
|
||||
Y[i_upd] += dy
|
||||
if maximum(abs.(dy))<options.pfmsolver.tolx
|
||||
convergence = true
|
||||
end
|
||||
end
|
||||
if convergence
|
||||
println("\nPFM solver converged in ", iteration, " iterations!\n")
|
||||
endogenousvariables = reshape(Y, ny, periods+2)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,100 +0,0 @@
|
|||
module SteadyState
|
||||
|
||||
##
|
||||
# Copyright © 2016 Dynare Team
|
||||
#
|
||||
# This file is part of Dynare.
|
||||
#
|
||||
# Dynare is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Dynare is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
using NLsolve
|
||||
|
||||
import DynareModel.Model
|
||||
import DynareOutput.Output
|
||||
|
||||
export steady, steady!
|
||||
export steady_state, steady_state!
|
||||
|
||||
function steady(model::Model, oo::Output)
|
||||
if model.analytical_steady_state || model.user_written_analytical_steady_state
|
||||
steadystate = zeros(length(model.endo))
|
||||
model.steady_state(steadystate, oo.exo_steady_state, model.params)
|
||||
return steadystate
|
||||
else
|
||||
error("You have to provide a closed form solution for the steady state, or declare a guess\nfor the steady state as a third input argument.")
|
||||
end
|
||||
end
|
||||
|
||||
function steady!(model::Model, oo::Output)
|
||||
if model.analytical_steady_state || model.user_written_analytical_steady_state
|
||||
model.steady_state(oo.steady_state, oo.exo_steady_state, model.params)
|
||||
return
|
||||
else
|
||||
error("You have to provide a closed form solution for the steady state, or declare a guess\nfor the steady state as a third input argument.")
|
||||
end
|
||||
end
|
||||
|
||||
function steady(model::Model, oo::Output, yinit::Vector{Float64})
|
||||
f!(fval::Vector{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval)
|
||||
j!(fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fjac)
|
||||
fj!(fval::Vector{Float64}, fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval, fjac)
|
||||
r = nlsolve(f!, j!, fj!, yinit, show_trace=false)
|
||||
if converged(r)
|
||||
return r.zero
|
||||
else
|
||||
return fill(NaN, length(yinit))
|
||||
end
|
||||
end
|
||||
|
||||
function steady!(model::Model, oo::Output, yinit::Vector{Float64})
|
||||
f!(fval::Vector{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval)
|
||||
j!(fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fjac)
|
||||
fj!(fval::Vector{Float64}, fjac::Matrix{Float64}, y::Vector{Float64}) = model.static(y, oo.exo_steady_state, model.params, fval, fjac)
|
||||
r = nlsolve(f!, j!, fj!, yinit, show_trace=false)
|
||||
if converged(r)
|
||||
oo.steady_state = r.zero
|
||||
else
|
||||
oo.steady_state = fill(NaN, length(yinit))
|
||||
end
|
||||
end
|
||||
|
||||
function steady_state(model::Model, oo::Output)
|
||||
ys = steady(model, oo)
|
||||
display_steady_state(model, oo, ys)
|
||||
end
|
||||
|
||||
function steady_state!(model::Model, oo::Output)
|
||||
steady!(model, oo)
|
||||
display_steady_state(model, oo, oo.steady_state)
|
||||
end
|
||||
|
||||
function display_steady_state(model::Model, oo::Output, ys::Vector{Float64})
|
||||
println("\n\nSTEADY STATE:\n")
|
||||
for i = 1:length(model.endo)
|
||||
println(string(model.endo[i].name, " = ", ys[i]))
|
||||
end
|
||||
end
|
||||
|
||||
function issteadystate(model::Model, oo::Output, ys::Vector{Float64})
|
||||
residuals = zeros(Float64, length(ys))
|
||||
compute_static_model_residuals!(model, oo, ys, residuals)
|
||||
return maximum(abs(residuals))<1e-6
|
||||
end
|
||||
|
||||
function compute_static_model_residuals!(model::Model, oo::Output, ys::Vector{Float64}, residuals::Vector{Float64})
|
||||
model.static(ys, oo.exo_steady_state, model.params, residuals)
|
||||
end
|
||||
|
||||
end
|
|
@ -1,36 +0,0 @@
|
|||
module Utils
|
||||
##
|
||||
# Copyright © 2015 Dynare Team
|
||||
#
|
||||
# This file is part of Dynare.
|
||||
#
|
||||
# Dynare is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Dynare is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
export get_power_deriv
|
||||
|
||||
function get_power_deriv(x::Float64, p::Real, k::Int)
|
||||
if abs(x)<1e-12 && p>0 && k>p && typeof(p)==Int
|
||||
dxp = .0
|
||||
else
|
||||
dxp = x^(p-k)
|
||||
for i = 0:k-1
|
||||
dxp *= p
|
||||
p -= 1
|
||||
end
|
||||
end
|
||||
return dxp
|
||||
end
|
||||
|
||||
end
|
140
license.txt
140
license.txt
|
@ -1,6 +1,6 @@
|
|||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: Dynare
|
||||
Upstream-Contact: Dynare Team, whose members in 2019 are:
|
||||
Upstream-Contact: Dynare Team, whose members in 2020 are:
|
||||
- Stéphane Adjemian <stephane.adjemian@univ-lemans.fr>
|
||||
- Houtan Bastani <houtan@dynare.org>
|
||||
- Michel Juillard <michel.juillard@mjui.fr>
|
||||
|
@ -22,7 +22,7 @@ Upstream-Contact: Dynare Team, whose members in 2019 are:
|
|||
Source: https://www.dynare.org
|
||||
|
||||
Files: *
|
||||
Copyright: 1996-2019 Dynare Team
|
||||
Copyright: 1996-2020 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/AIM/SP*
|
||||
|
@ -53,45 +53,45 @@ Files: matlab/optimization/bfgsi1.m matlab/csolve.m matlab/optimization/csminit1
|
|||
matlab/bvar_toolbox.m matlab/partial_information/PI_gensys.m matlab/partial_information/qzswitch.m
|
||||
matlab/partial_information/qzdiv.m
|
||||
Copyright: 1993-2009 Christopher Sims
|
||||
2006-2016 Dynare Team
|
||||
2006-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/optimization/cmaes.m
|
||||
Copyright: 2001-2012 Nikolaus Hansen
|
||||
2012 Dynare Team
|
||||
2012-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/optimization/solvopt.m
|
||||
Copyright: 1997-2008 Alexei Kuntsevich and Franz Kappel
|
||||
2008-2015 Giovanni Lombardo
|
||||
2015 Dynare Team
|
||||
2015-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/optimization/simulated_annealing.m
|
||||
Copyright: 1995 E.G.Tsionas
|
||||
1995-2002 Thomas Werner
|
||||
2002-2015 Giovanni Lombardo
|
||||
2015 Dynare Team
|
||||
2015-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/endogenous_prior.m
|
||||
Copyright: 2011 Lawrence J. Christiano, Mathias Trabandt and Karl Walentin
|
||||
2013 Dynare Team
|
||||
2013-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/trust_region.m
|
||||
Copyright: 2008-2012 VZLU Prague, a.s.
|
||||
2014-2016 Dynare Team
|
||||
2014-2019 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/one_sided_hp_filter.m
|
||||
Copyright: 2010-2015 Alexander Meyer-Gohde
|
||||
2015 Dynare Team
|
||||
2015-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/convergence_diagnostics/raftery_lewis.m
|
||||
Copyright: 2016 Benjamin Born and Johannes Pfeifer
|
||||
2016 Dynare Team
|
||||
2016-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/commutation.m matlab/duplication.m
|
||||
|
@ -99,10 +99,38 @@ Copyright: 1997 Tom Minka <minka@microsoft.com>
|
|||
2019 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/allVL1.m
|
||||
Copyright: 2007-2010 Bruno Luong <brunoluong@yahoo.com>
|
||||
2019 Dynare Team
|
||||
License: GPL-3+
|
||||
Comment: The original author gave authorization to change
|
||||
the license from BSD-2-clause to GPL-3+ and redistribute
|
||||
it under GPL-3+ with Dynare.
|
||||
|
||||
Files: matlab/uperm.m
|
||||
Copyright: 2014 Bruno Luong <brunoluong@yahoo.com>
|
||||
2019 Dynare Team
|
||||
License: GPL-3+
|
||||
Comment: The original author gave authorization to change
|
||||
the license from BSD-2-clause to GPL-3+ and redistribute
|
||||
it under GPL-3+ with Dynare.
|
||||
|
||||
Files: matlab/prodmom.m matlab/bivmom.m
|
||||
Copyright: 2008-2015 Raymond Kan <kan@chass.utoronto.ca>
|
||||
2019-2020 Dynare Team
|
||||
License: GPL-3+
|
||||
Comment: The author gave authorization to redistribute
|
||||
these functions under GPL-3+ with Dynare and would
|
||||
appreciate acknowledgement of the source by citation
|
||||
of the following paper:
|
||||
Kan, R.: "From moments of sum to moments of product."
|
||||
Journal of Multivariate Analysis, 2008, vol. 99, issue 3,
|
||||
pages 542-554.
|
||||
|
||||
Files: matlab/gsa/Morris_Measure_Groups.m
|
||||
matlab/gsa/Sampling_Function_2.m
|
||||
Copyright: 2005 European Commission
|
||||
2012 Dynare Team
|
||||
2012-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
Comment: Written by Jessica Cariboni and Francesca Campolongo
|
||||
Joint Research Centre, The European Commission,
|
||||
|
@ -153,7 +181,7 @@ Comment: This file is part of GLUEWIN.
|
|||
Files: matlab/optimization/simpsa.m matlab/optimization/simpsaget.m matlab/optimization/simpsaset.m
|
||||
Copyright: 2005 Henning Schmidt, FCC, henning@fcc.chalmers.se
|
||||
2006 Brecht Donckels, BIOMATH, brecht.donckels@ugent.be
|
||||
2013-2016 Dynare Team
|
||||
2013-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/missing/stats/normpdf.m matlab/missing/stats/gamcdf.m
|
||||
|
@ -163,22 +191,20 @@ Files: matlab/missing/stats/normpdf.m matlab/missing/stats/gamcdf.m
|
|||
matlab/missing/stats/betapdf.m matlab/missing/stats/normcdf.m
|
||||
matlab/missing/stats/stdnormal_cdf.m matlab/missing/stats/norminv.m
|
||||
matlab/missing/stats/stdnormal_pdf.m matlab/missing/stats/betainv.m
|
||||
matlab/missing/stats-matlab/common_size.m
|
||||
Copyright: 1995-2007 Kurt Hornik
|
||||
2008-2011 Dynare Team
|
||||
2008-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/missing/stats-matlab/quantile.m
|
||||
Files: matlab/missing/stats/quantile.m
|
||||
Copyright: 2014-2016 Christopher Hummersone
|
||||
2016 Dynare Team
|
||||
2016-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
|
||||
Files: matlab/missing/stats-matlab/corr.m
|
||||
Files: matlab/missing/stats/corr.m
|
||||
Copyright: 1993-1996 Kurt Hornik
|
||||
1996-2015 John W. Eaton
|
||||
2013-2015 Julien Bect
|
||||
2016 Dynare Team
|
||||
2016-2017 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/missing/strjoin/strjoin.m
|
||||
|
@ -187,47 +213,35 @@ Copyright: 2013-2019 Ben Abbott
|
|||
2019 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/missing/corrcoef/corrcoef.m matlab/missing/corrcoef/sumskipnan.m
|
||||
matlab/missing/corrcoef/flag_implicit_skip_nan.m matlab/missing/corrcoef/tcdf.m
|
||||
Copyright: 2000-2005,2008,2009,2011 by Alois Schloegl <alois.schloegl@gmail.com>
|
||||
2014 Dynare Team
|
||||
License: GPL-3+
|
||||
|
||||
Files: matlab/lmmcp/catstruct.m
|
||||
Copyright: 2005 Jos van der Geest <jos@jasen.nl>
|
||||
2013 Christophe Gouel
|
||||
2016 Dynare Team
|
||||
2016-2017 Dynare Team
|
||||
License: BSD-2-clause
|
||||
|
||||
Files: matlab/lmmcp/lmmcp.m
|
||||
Copyright: 2005 Christian Kanzow and Stefania Petra
|
||||
2013 Christophe Gouel
|
||||
2014 Dynare Team
|
||||
2014-2017 Dynare Team
|
||||
License: permissive-lmmcp
|
||||
Unlimited permission is granted to everyone to use, copy, modify or
|
||||
distribute this software.
|
||||
|
||||
Files: matlab/utilities/graphics/distinguishable_colors.m
|
||||
Copyright: 2010-2011 Timothy E. Holy
|
||||
2017 Dynare Team
|
||||
License: BSD-2-clause
|
||||
|
||||
Files: matlab/utilities/graphics/colorspace.m
|
||||
Copyright: 2005-2010 Pascal Getreuer
|
||||
2017 Dynare Team
|
||||
License: BSD-2-clause
|
||||
|
||||
Files: doc/*.rst doc/*.tex doc/*.svg doc/*.pdf doc/*.bib
|
||||
Copyright: 1996-2019 Dynare Team
|
||||
Copyright: 1996-2020 Dynare Team
|
||||
License: GFDL-NIV-1.3+
|
||||
|
||||
Files: doc/macroprocessor/*
|
||||
Copyright: 2008-2015 Dynare Team
|
||||
License: CC-BY-SA-4.0
|
||||
|
||||
Files: doc/preprocessor/*
|
||||
Copyright: 2007-2019 Dynare Team
|
||||
License: CC-BY-SA-4.0
|
||||
|
||||
Files: doc/dr.tex doc/bvar_a_la_sims.tex
|
||||
Files: doc/dr.tex doc/dr.bib doc/bvar-a-la-sims.tex
|
||||
Copyright: 2007-2011 Sébastien Villemot
|
||||
License: GFDL-NIV-1.3+
|
||||
|
||||
|
@ -237,19 +251,13 @@ Copyright: 2004-2011 Ondra Kamenik
|
|||
License: GPL-3+
|
||||
|
||||
Files: m4/ax_blas.m4 m4/ax_lapack.m4
|
||||
Copyright: 2008 Steven G. Johnson <stevenj@alum.mit.edu>
|
||||
Copyright: 2008-2009 Steven G. Johnson <stevenj@alum.mit.edu>
|
||||
License: GPL-3+ with Autoconf exception
|
||||
|
||||
Files: m4/ax_boost_base.m4
|
||||
Copyright: 2008 Thomas Porschberg <thomas@randspringer.de>
|
||||
2009 Peter Adolphs
|
||||
License: FSFAP
|
||||
|
||||
Files: m4/ax_compare_version.m4
|
||||
Copyright: 2008 Tim Toolan <toolan@ele.uri.edu>
|
||||
License: FSFAP
|
||||
|
||||
|
||||
Files: m4/ax_cxx_compile_stdcxx.m4
|
||||
m4/ax_cxx_compile_stdcxx_17.m4
|
||||
Copyright: 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||
|
@ -262,14 +270,14 @@ Copyright: 2008 Benjamin Kosnik <bkoz@redhat.com>
|
|||
2019 Enji Cooper <yaneurabeya@gmail.com>
|
||||
License: FSFAP
|
||||
|
||||
Files: m4/ax_latex_class.m4 m4/ax_tex_test.m4
|
||||
Files: m4/ax_latex_class.m4 m4/ax_latex_test.m4
|
||||
Copyright: 2008 Boretti Mathieu <boretti@eig.unige.ch>
|
||||
2009 Dynare Team
|
||||
License: LGPL-2.1+
|
||||
|
||||
Files: m4/ax_matlab_arch.m4 m4/ax_matlab.m4 m4/ax_mexext.m4
|
||||
Copyright: 2002-2003 Ralph Schleicher
|
||||
2009 Dynare Team
|
||||
2009-2019 Dynare Team
|
||||
License: GPL-2+ with Autoconf exception
|
||||
|
||||
Files: scripts/dynare.el
|
||||
|
@ -286,18 +294,48 @@ License: GPL-3+
|
|||
Files: mex/sources/sobol/sobol.hh mex/sources/sobol/initialize_v_array.hh
|
||||
mex/sources/sobol/initialize_v_array.inc
|
||||
Copyright: 2009 John Burkardt
|
||||
2010-2011 Dynare Team
|
||||
2010-2017 Dynare Team
|
||||
License: LGPL-3+
|
||||
|
||||
Files: macOS/brewfiles/*
|
||||
Copyright: 2009-2019, Homebrew contributors
|
||||
Copyright: 2009-2019 Homebrew contributors
|
||||
2019 Dynare Team
|
||||
License: BSD-2-clause
|
||||
|
||||
Files: contrib/jsonlab
|
||||
Files: preprocessor/m4/ax_boost_base.m4
|
||||
Copyright: 2008-2009 Thomas Porschberg <thomas@randspringer.de>
|
||||
2009 Peter Adolphs
|
||||
License: FSFAP
|
||||
|
||||
Files: preprocessor/m4/ax_cxx_compile_stdcxx.m4
|
||||
preprocessor/m4/ax_cxx_compile_stdcxx_17.m4
|
||||
Copyright: 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||
2012 Zack Weinberg <zackw@panix.com>
|
||||
2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
||||
2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
|
||||
2015 Paul Norman <penorman@mac.com>
|
||||
2015 Moritz Klammler <moritz@klammler.eu>
|
||||
2016, 2018 Krzesimir Nowak <qdlacz@gmail.com>
|
||||
2019 Enji Cooper <yaneurabeya@gmail.com>
|
||||
License: FSFAP
|
||||
|
||||
Files: preprocessor/m4/ax_latex_class.m4
|
||||
preprocessor/m4/ax_latex_test.m4
|
||||
Copyright: 2008 Boretti Mathieu <boretti@eig.unige.ch>
|
||||
2009 Dynare Team
|
||||
License: LGPL-2.1+
|
||||
|
||||
Files: preprocessor/doc/macroprocessor/*
|
||||
Copyright: 2008-2019 Dynare Team
|
||||
License: CC-BY-SA-4.0
|
||||
|
||||
Files: preprocessor/doc/preprocessor/*
|
||||
Copyright: 2007-2019 Dynare Team
|
||||
License: CC-BY-SA-4.0
|
||||
|
||||
Files: contrib/jsonlab/*
|
||||
Copyright: 2011-2018 Qianqian Fang <q.fang at neu.edu>
|
||||
License: BSD or GPL-3+
|
||||
Comment: https://www.mathworks.com/matlabcentral/fileexchange/33381-jsonlab-a-toolbox-to-encode-decode-json-files
|
||||
License: BSD-2-clause or GPL-3+
|
||||
|
||||
Files: contrib/ms-sbvar/utilities_dw/*
|
||||
Copyright: 1996-2011 Daniel Waggoner
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
# ===========================================================================
|
||||
# http://www.nongnu.org/autoconf-archive/ax_latex_test.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# OBSOLETE MACRO
|
||||
#
|
||||
# Deprecated because of licensing issues. The Lesser GPL imposes licensing
|
||||
# restrictions on the generated configure script unless it is augmented
|
||||
# with an Autoconf Exception clause.
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_TEX_TEST(FILEDATA,VARIABLETOSET,[NOCLEAN])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macros execute the pdftex application with FILEDATA as input and set
|
||||
# VARIABLETOSET to yes or no depending on the result. If NOCLEAN is set,
|
||||
# the folder used for the test is not delete after testing.
|
||||
#
|
||||
# The macro assumes that the variable PDFTEX is set.
|
||||
#
|
||||
# Adapted from the macro AX_LATEX_TEST by Sébastien Villemot.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright © 2008 Boretti Mathieu <boretti@eig.unige.ch>
|
||||
# Copyright © 2009 Dynare Team
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or (at
|
||||
# your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
AC_DEFUN([AX_TEX_TEST],[
|
||||
rm -rf conftest.dir/.acltx
|
||||
AS_MKDIR_P([conftest.dir/.acltx])
|
||||
cd conftest.dir/.acltx
|
||||
m4_ifval([$2],[$2="no"; export $2;])
|
||||
cat > conftest.tex << ACLEOF
|
||||
$1
|
||||
ACLEOF
|
||||
cat conftest.tex | $PDFTEX 2>&1 1>output m4_ifval([$2],[&& $2=yes])
|
||||
cd ..
|
||||
cd ..
|
||||
sed 's/^/| /' conftest.dir/.acltx/conftest.tex >&5
|
||||
echo "$as_me:$LINENO: executing cat conftest.tex | $PDFTEX" >&5
|
||||
sed 's/^/| /' conftest.dir/.acltx/output >&5
|
||||
m4_ifval([$3],,[rm -rf conftest.dir/.acltx])
|
||||
])
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright © 2019 Dynare Team
|
||||
# Copyright © 2019-2020 Dynare Team
|
||||
#
|
||||
# This file is part of Dynare.
|
||||
#
|
||||
|
@ -99,7 +99,7 @@ mkdir -p \
|
|||
if [[ $VERSION == *-unstable* ]]; then
|
||||
echo "$SHA" > "$PKGFILES"/sha.txt
|
||||
fi
|
||||
cp -p "$ROOTDIR"/NEWS "$PKGFILES"
|
||||
cp -p "$ROOTDIR"/NEWS.md "$PKGFILES"
|
||||
cp -p "$ROOTDIR"/COPYING "$PKGFILES"
|
||||
cp -p "$ROOTDIR"/VERSION "$PKGFILES"
|
||||
cp -p "$ROOTDIR"/license.txt "$PKGFILES"
|
||||
|
@ -125,6 +125,7 @@ cp -r "$ROOTDIR"/doc/manual/build/html "$PKGFILES"
|
|||
cp "$ROOTDIR"/dynare++/doc/*.pdf "$PKGFILES"/doc/dynare++
|
||||
|
||||
cp "$ROOTDIR"/dynare++/src/dynare++ "$PKGFILES"/dynare++
|
||||
cp "$ROOTDIR"/dynare++/dynare_simul/dynare_simul.m "$PKGFILES"/dynare++
|
||||
|
||||
mkdir -p "$PKGFILES"/matlab/modules/dseries/externals/x13/macOS/64
|
||||
cp -p "$ROOTDIR"/macOS/deps/lib64/x13as/x13as "$PKGFILES"/matlab/modules/dseries/externals/x13/macOS/64
|
||||
|
@ -152,15 +153,18 @@ cp -L "$ROOTDIR"/mex/matlab/* "$PKGFILES"
|
|||
## Create mex for Octave
|
||||
##
|
||||
cd "$ROOTDIR"/mex/build/octave
|
||||
CC=$CC CXX=$CXX ./configure \
|
||||
OCTAVE_VERSION=$(grep OCTAVE_VERSION "$ROOTDIR"/macOS/deps/versions.mk | cut -d'=' -f2 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
OCTAVE_USR_DIR="/Applications/Octave-$OCTAVE_VERSION.app/Contents/Resources/usr"
|
||||
OCTAVE_BIN_DIR="$OCTAVE_USR_DIR/Cellar/octave-octave-app@$OCTAVE_VERSION/$OCTAVE_VERSION/bin"
|
||||
PATH="$OCTAVE_BIN_DIR:$PATH" CC=$CC CXX=$CXX ./configure \
|
||||
PACKAGE_VERSION="$VERSION" \
|
||||
PACKAGE_STRING="dynare $VERSION" \
|
||||
CXXFLAGS=-I/usr/local/include \
|
||||
LDFLAGS="-static-libgcc -L/usr/local/lib" \
|
||||
LDFLAGS="-static-libgcc -L$OCTAVE_USR_DIR/lib " \
|
||||
--with-gsl="$LIB64"/gsl \
|
||||
--with-matio="$LIB64"/matio \
|
||||
--with-slicot="$LIB64"/Slicot/with-underscore
|
||||
make -j"$NTHREADS"
|
||||
PATH="$OCTAVE_BIN_DIR:$PATH" make -j"$NTHREADS"
|
||||
cp -L "$ROOTDIR"/mex/octave/* "$PKGFILES"/mex/octave
|
||||
echo -e "function v = supported_octave_version\nv=\"$(octave --eval "disp(OCTAVE_VERSION)")\";\nend" > "$PKGFILES"/matlab/supported_octave_version.m
|
||||
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
SLICOT_VERSION = 5.0+20101122
|
||||
X13AS_VERSION = 1.1_B39
|
||||
OCTAVE_VERSION = 4.4.1
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
<background-darkAqua file="background.png" scaling="tofit" mime-type="image/png" alignment="topleft" />
|
||||
<welcome file="welcome.html" mime-type="text/html" />
|
||||
<license file="gpl-3.0-standalone.html" mime-type="text/html" />
|
||||
<pkg-ref id="com.cepremap.dynare" />
|
||||
<pkg-ref id="org.dynare" />
|
||||
<options customize="allow" require-scripts="false" hostArchitectures="x86_64" />
|
||||
<choices-outline>
|
||||
<line choice="com.cepremap.dynare" />
|
||||
<line choice="com.cepremap.dynare.gcc" />
|
||||
<line choice="org.dynare" />
|
||||
<line choice="org.dynare.gcc" />
|
||||
</choices-outline>
|
||||
<choice id="com.cepremap.dynare" title="Dynare" description="Dynare Required Files" start_enabled="false" enabled="false">
|
||||
<pkg-ref id="com.cepremap.dynare" />
|
||||
<choice id="org.dynare" title="Dynare" description="Dynare Required Files" start_enabled="false" enabled="false">
|
||||
<pkg-ref id="org.dynare" />
|
||||
</choice>
|
||||
<choice id="com.cepremap.dynare.gcc" title="GCC compiler for use_dll" description="This is necessary for the use of Dynare with the `use_dll` option. NB: This takes a few minutes and requires an active internet connection">
|
||||
<pkg-ref id="com.cepremap.dynare.gcc" />
|
||||
<choice id="org.dynare.gcc" title="GCC for `use_dll`" description="This is necessary for the use of Dynare with the `use_dll` option. NB: This takes a few minutes and requires an active internet connection.">
|
||||
<pkg-ref id="org.dynare.gcc" />
|
||||
</choice>
|
||||
<pkg-ref id="com.cepremap.dynare" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE.pkg</pkg-ref>
|
||||
<pkg-ref id="com.cepremap.dynare.gcc" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE-gcc.pkg</pkg-ref>
|
||||
<pkg-ref id="org.dynare" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE.pkg</pkg-ref>
|
||||
<pkg-ref id="org.dynare.gcc" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE-gcc.pkg</pkg-ref>
|
||||
</installer-gui-script>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright © 2019 Dynare Team
|
||||
# Copyright © 2019-2020 Dynare Team
|
||||
#
|
||||
# This file is part of Dynare.
|
||||
#
|
||||
|
@ -29,7 +29,12 @@ exec 2>&1
|
|||
rm -f "$2"/dummy
|
||||
|
||||
# Test for Internet connection
|
||||
[[ -z $(curl -s -m 4 www.google.com) ]] && { echo "No internet connection found"; exit 1; }
|
||||
[[ -z $(curl -s -m 4 https://github.com) ]] && \
|
||||
{ \
|
||||
osascript -e 'display alert "Dynare Installation Error" message "Not able to connect to github.com. Either you are not connected to the internet or github.com is blocked where you are.\n\nAccess to GitHub is necessary to make Dynare work with the `use_dll` option on macOS.\n\nIf you cannot establish this connection or do not want to use the `use_dll` option of Dynare, please run the installer again and choose \"Customize\" from the \"Installation Type\" screen and uncheck the `GCC` option." as critical'; \
|
||||
echo "No internet connection to github.com"; \
|
||||
exit 1; \
|
||||
}
|
||||
|
||||
# Install Command Line Tools
|
||||
if [[ -z $(/usr/bin/xcode-select -print-path) ]]; then
|
||||
|
@ -49,7 +54,20 @@ fi
|
|||
|
||||
# If CLT installation didn't work, exit
|
||||
[[ -z $(/usr/bin/xcode-select -print-path) ]] && \
|
||||
{ echo "You must install Command Line Tools to proceed with installation of GCC"; exit 1; }
|
||||
{ \
|
||||
osascript -e 'display alert "Dynare Installation Error" message "Not able to find Command Line Tools.\n\nCommand Line Tools is necessary to make Dynare work with the `use_dll` option on macOS.\n\nIf you cannot establish this connection or do not want to use the `use_dll` option of Dynare, please run the installer again and choose \"Customize\" from the \"Installation Type\" screen and uncheck the `GCC` option." as critical'; \
|
||||
echo "Command Line Tools not installed"; \
|
||||
exit 1; \
|
||||
}
|
||||
|
||||
# Ensure git is in the path
|
||||
[[ -z $(which git) ]] && \
|
||||
{ \
|
||||
osascript -e 'display alert "Dynare Installation Error" message "Not able to find Git even though the Command Line Tools have already been installed. This is likely a problem with your PATH environment variable.\n\nGit is necessary to make Dynare work with the `use_dll` option on macOS.\n\nIf you cannot establish this connection or do not want to use the `use_dll` option of Dynare, please run the installer again and choose \"Customize\" from the \"Installation Type\" screen and uncheck the `GCC` option." as critical'; \
|
||||
echo $PATH; \
|
||||
echo "Git not found in PATH"; \
|
||||
exit 1; \
|
||||
}
|
||||
|
||||
# Install Homebrew
|
||||
BREWDIR="$2"/.brew
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
<p style="text-align: center;">Version VERSION_NO_SPACE</p>
|
||||
<p style="text-align: center;">DATE</p>
|
||||
|
||||
<p><b>Just a few things to note</b>. This installation can be customized as you can choose not to install the GNU C Compiler (GCC). Installing GCC is necessary if you want to use the <tt>use_dll</tt> option in Dynare, but otherwise unnecessary.</p>
|
||||
<p><b>Just a few things to note</b>. This installation can be customized as you can choose not to install the GNU Compiler Collection (GCC). Installing GCC is necessary if you want to use the <tt>use_dll</tt> option in Dynare, but otherwise unnecessary.</p>
|
||||
|
||||
<p>To install GCC we run a script that first installs the XCode Command Line Tools (an Apple product). The script then installs Homebrew, a package manager for macOS and, finally, GCC itself. Both Homebrew and GCC will be installed in your Dynare installation folder. So, when you delete this folder, they too will be deleted.</p>
|
||||
|
||||
<p>Installing GCC will require an active internet connection and will take a few minutes to a half an hour during the <i>Running package scripts</i> phase of Installation. The time it takes depends on your internet speed, the speed of your computer, and whether or not you already have XCode Command Line Tools installed. The progress bar will not advance during this phase. Please be patient.</p>
|
||||
<p>Installing GCC will require an active internet connection with the ability to connect to the Apple servers and GitHub. The installation will take anywhere from a few minutes to a half an hour during the <i>Running package scripts</i> phase of Installation. The time it takes depends on your internet speed, the speed of your computer, and whether or not you already have XCode Command Line Tools installed. The progress bar will not advance during this phase. Please be patient.</p>
|
||||
|
||||
<p> You can choose not to install GCC by choosing <i>Customize</i> from the <i>Installation Type</i> screen and deselecting <i>GCC compiler</i>. If you already have <tt>GCC_BINARY</tt> installed under <tt>/usr/local</tt>, you can forgo the installation of GCC here as Dynare will find your system compiler when you use <tt>use_dll</tt>.</p>
|
||||
</body>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function run(json)
|
||||
% function varargout = run(json)
|
||||
function read(json)
|
||||
% function varargout = read(json)
|
||||
% Read JSON and run perfect foresight solver. Potentially return output as
|
||||
% JSON
|
||||
%
|
||||
|
@ -13,7 +13,7 @@ function run(json)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2019 Dynare Team
|
||||
% Copyright (C) 2019-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -34,7 +34,6 @@ global M_ options_ oo_
|
|||
|
||||
%loading JSON
|
||||
jm = loadjson_(json, 'SimplifyCell', 1);
|
||||
runflag=1;
|
||||
data2json=struct();
|
||||
|
||||
M_.exo_det_length = 0;
|
||||
|
@ -67,7 +66,7 @@ options_.order = jm.taylororder;
|
|||
% options_.k_order_solver = 3;
|
||||
% end
|
||||
var_list_ = char();
|
||||
info = stoch_simul(var_list_);
|
||||
[~, oo_, options_] = stoch_simul(M_, options_, oo_, var_list_);
|
||||
|
||||
irfnames=fieldnames(oo_.irfs);
|
||||
for jj = 1:numel(fieldnames(oo_.irfs))
|
||||
|
|
|
@ -58,7 +58,7 @@ function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK,T,R,P,PK,de
|
|||
% SPECIAL REQUIREMENTS
|
||||
% None
|
||||
|
||||
% Copyright (C) 2006-2018 Dynare Team
|
||||
% Copyright (C) 2006-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -185,8 +185,7 @@ elseif options_.lik_init == 3 % Diffuse Kalman filter
|
|||
end
|
||||
[Pstar,Pinf] = compute_Pinf_Pstar(mf,T,R,Q,options_.qz_criterium);
|
||||
elseif options_.lik_init == 4 % Start from the solution of the Riccati equation.
|
||||
[err, Pstar] = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(mf,np,vobs)),H);
|
||||
mexErrCheck('kalman_steady_state',err);
|
||||
Pstar = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(mf,np,vobs)),H);
|
||||
Pinf = [];
|
||||
if kalman_algo~=2
|
||||
kalman_algo = 1;
|
||||
|
|
|
@ -145,7 +145,7 @@ while fpar<B
|
|||
end
|
||||
stock_param(irun2,:) = deep;
|
||||
set_parameters(deep);
|
||||
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||
[dr,info,M_,options_,oo_] =compute_decision_rules(M_,options_,oo_);
|
||||
oo_.dr = dr;
|
||||
if info(1)
|
||||
nosaddle = nosaddle + 1;
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
function [DP6,DP6inv] = Q6_plication(p)
|
||||
% Computes the 6-way duplication Matrix DP6 (and its Moore-Penrose inverse)
|
||||
% such that for any p-dimensional vector x:
|
||||
% y=kron(kron(kron(kron(kron(x,x),x,x),x),x)=DP6*z
|
||||
% where z is of dimension np=p*(p+1)*(p+2)*(p+3)*(p+4)*(p+5)/(1*2*3*4*5*6)
|
||||
% and is obtained from y by removing each second and later occurence of the
|
||||
% same element. This is a generalization of the Duplication matrix.
|
||||
% Reference: Meijer (2005) - Matrix algebra for higher order moments.
|
||||
% Linear Algebra and its Applications, 410,pp. 112-134
|
||||
% =========================================================================
|
||||
% INPUTS
|
||||
% * p [integer] size of vector
|
||||
% -------------------------------------------------------------------------
|
||||
% OUTPUTS
|
||||
% * DP6 [p^6 by np] 6-way duplication matrix
|
||||
% * DP6inv [np by np] Moore-Penrose inverse of DP6
|
||||
% -------------------------------------------------------------------------
|
||||
% This function is called by
|
||||
% * pruned_state_space_system.m
|
||||
% -------------------------------------------------------------------------
|
||||
% This function calls
|
||||
% * binom_coef (embedded)
|
||||
% * mue (embedded)
|
||||
% * uperm
|
||||
% =========================================================================
|
||||
% Copyright (C) 2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
% =========================================================================
|
||||
np = p*(p+1)*(p+2)*(p+3)*(p+4)*(p+5)/(1*2*3*4*5*6);
|
||||
DP6 = spalloc(p^6,np,p^6);
|
||||
counti=1;
|
||||
for i1=1:p
|
||||
for i2=i1:p
|
||||
for i3=i2:p
|
||||
for i4=i3:p
|
||||
for i5=i4:p
|
||||
for i6=i5:p
|
||||
idx = uperm([i6 i5 i4 i3 i2 i1]);
|
||||
for r = 1:size(idx,1)
|
||||
ii1 = idx(r,1); ii2= idx(r,2); ii3=idx(r,3); ii4=idx(r,4); ii5=idx(r,5); ii6=idx(r,6);
|
||||
n = ii1 + (ii2-1)*p + (ii3-1)*p^2 + (ii4-1)*p^3 + (ii5-1)*p^4 + (ii6-1)*p^5;
|
||||
m = mue(p,i6,i5,i4,i3,i2,i1);
|
||||
DP6(n,m)=1;
|
||||
end
|
||||
counti = counti+1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
DP6inv = (transpose(DP6)*DP6)\transpose(DP6);
|
||||
|
||||
function m = mue(p,i1,i2,i3,i4,i5,i6)
|
||||
% Auxiliary expression, see page 122 of Meijer (2005)
|
||||
m = binom_coef(p,6,1) - binom_coef(p,1,i1+1) - binom_coef(p,2,i2+1) - binom_coef(p,3,i3+1) - binom_coef(p,4,i4+1) - binom_coef(p,5,i5+1) - binom_coef(p,6,i6+1);
|
||||
m = round(m);
|
||||
end
|
||||
|
||||
function N = binom_coef(p,q,i)
|
||||
% Auxiliary expression for binomial coefficients, see page 119 of Meijer (2005)
|
||||
t = q; r =p+q-i;
|
||||
if t==0
|
||||
N=1;
|
||||
else
|
||||
N=1;
|
||||
for h = 0:(t-1)
|
||||
N = N*(r-h);
|
||||
end
|
||||
N=N/factorial(t);
|
||||
end
|
||||
end
|
||||
end
|
|
@ -19,7 +19,7 @@ function [oo_] = UnivariateSpectralDensity(M_,oo_,options_,var_list)
|
|||
|
||||
% Adapted from th_autocovariances.m.
|
||||
|
||||
% Copyright (C) 2006-2018 Dynare Team
|
||||
% Copyright (C) 2006-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -105,7 +105,7 @@ end
|
|||
iky = iv(ivar);
|
||||
aa = ghx(iky,:);
|
||||
bb = ghu(iky,:);
|
||||
ngrid = options_.hp_ngrid; %number of grid points
|
||||
ngrid = options_.filtered_theoretical_moments_grid; %number of grid points
|
||||
freqs = (0 : pi/(ngrid-1):pi)'; % grid on which to compute
|
||||
tpos = exp( sqrt(-1)*freqs); %positive frequencies
|
||||
tneg = exp(-sqrt(-1)*freqs); %negative frequencies
|
||||
|
|
|
@ -100,8 +100,8 @@ for j=1:nvar
|
|||
comp_nbr=18;
|
||||
end
|
||||
|
||||
d0(1,:)=[{'Decomposition'} cellstr(labels(1:comp_nbr,:))' {'Smoot Var'}];
|
||||
d0=[d0; num2cell([x' z1'])];
|
||||
d0(1,:)=[{'Decomposition'} cellstr(labels(1:comp_nbr,:))' {'Smoot Var'} {'Steady State'}];
|
||||
d0=[d0; num2cell([x' z1' ]), [num2cell(SteadyState(i_var(j))); cell(size(z1,2)-1,1)]];
|
||||
LastRow=size(d0,1);
|
||||
if use_shock_groups
|
||||
d0(LastRow+2,1)={'Legend.'};
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
|
||||
function y0 = get_irf(exo,varargin)
|
||||
% function x = get_irf(exoname, vname1, vname2, ...)
|
||||
% returns IRF to individual exogenous for a list of variables and adds the
|
||||
% steady state
|
||||
%
|
||||
% INPUTS:
|
||||
% exo: exo variable name
|
||||
% vname1, vname2, ... : list of variable names
|
||||
%
|
||||
% OUTPUTS
|
||||
% x: irf matrix [time x number of variables]
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2019 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
global M_ oo_
|
||||
|
||||
ys_ = [oo_.steady_state];
|
||||
y0=zeros(length(oo_.irfs.([varargin{1} '_' exo]))+1,length(varargin));
|
||||
|
||||
|
||||
[i_var,nvar] = varlist_indices(varargin,M_.endo_names);
|
||||
|
||||
|
||||
for j=1:nvar
|
||||
% mfys = strmatch(varargin{j},lgy_,'exact');
|
||||
y0(:,j)=[0; oo_.irfs.([ varargin{j} '_' exo ])']+ys_(i_var(j));
|
||||
end
|
|
@ -0,0 +1,56 @@
|
|||
function y0 = get_mean(varargin)
|
||||
% function x = get_mean(vname1, vname2, <order>)
|
||||
% returns the steady-state of a variable identified by its name
|
||||
%
|
||||
% INPUTS:
|
||||
% vname1, vname2, ... : list of variable names
|
||||
% order: if integer 1 or 2, optionally last input can trigger the order
|
||||
% at which steady state is computed
|
||||
%
|
||||
% OUTPUTS
|
||||
% x: steady state values
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2019 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
global M_ oo_ options_
|
||||
|
||||
if ~isempty(regexp(varargin{end},'\d','ONCE')) && isempty(regexp(varargin{end},'\D','ONCE'))
|
||||
order=eval(varargin{end});
|
||||
else
|
||||
order=1;
|
||||
end
|
||||
if order==1
|
||||
ys_ = oo_.steady_state;
|
||||
ys_ = evaluate_steady_state(ys_,M_,options_,oo_,1);
|
||||
elseif order==2
|
||||
ys_ = oo_.dr.ys;
|
||||
ys_(oo_.dr.order_var)=ys_(oo_.dr.order_var)+oo_.dr.ghs2./2;
|
||||
else
|
||||
return
|
||||
end
|
||||
lgy_ = M_.endo_names;
|
||||
|
||||
mfys=nan(length(varargin),1);
|
||||
for j=1:length(varargin)
|
||||
mfys(j) = find(strcmp(varargin{j},lgy_));
|
||||
end
|
||||
|
||||
y0 = ys_(mfys);
|
|
@ -1,22 +1,17 @@
|
|||
function mexErrCheck(mexFunctionName, err)
|
||||
% function mexErrCheck(mexFunctionName, err)
|
||||
% this function halts processing if err is equal to 1.
|
||||
function x = get_shock_stderr_by_name(exoname)
|
||||
% function x = get_shock_stderr_by_name(exoname)
|
||||
% returns the value of a shock identified by its name
|
||||
%
|
||||
% INPUTS
|
||||
% mexFunctionName [char] Name of the mexFunction
|
||||
% err [double] error code returned from mexFunction
|
||||
% INPUTS:
|
||||
% exoname: shock name
|
||||
%
|
||||
% OUTPUTS
|
||||
% none.
|
||||
%
|
||||
% ALGORITHM
|
||||
% ...
|
||||
% x: shock value
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none.
|
||||
%
|
||||
% none
|
||||
|
||||
% Copyright (C) 2010 Dynare Team
|
||||
% Copyright (C) 2019 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -33,10 +28,12 @@ function mexErrCheck(mexFunctionName, err)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if ~ischar(mexFunctionName) || ~isscalar(err)
|
||||
error('The first argument must be a char and the second a scalar');
|
||||
global M_
|
||||
|
||||
i = find(strcmp(exoname,M_.exo_names));
|
||||
|
||||
if isempty(i)
|
||||
error(['Can''t find shock ', exoname])
|
||||
end
|
||||
|
||||
if err
|
||||
error(['Error encountered in: ' mexFunctionName '.']);
|
||||
end
|
||||
x = sqrt(M_.Sigma_e(i,i));
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
function y0 = get_smooth(varargin)
|
||||
% function x = get_smooth(vname1, vname2, )
|
||||
% returns smoothed variables or shocks identified by their name
|
||||
%
|
||||
% INPUTS:
|
||||
% vname1, vname2, ... : list of variable/shock names
|
||||
%
|
||||
% OUTPUTS
|
||||
% x: smoothed variables [T x number of variables]
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2019 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
global oo_
|
||||
|
||||
SmoothedVariables=[struct2cell(oo_.SmoothedVariables); struct2cell(oo_.SmoothedShocks)];
|
||||
my_field_names = [fieldnames(oo_.SmoothedVariables); fieldnames(oo_.SmoothedShocks)];
|
||||
isvar=zeros(length(SmoothedVariables),1);
|
||||
for jf = 1:length(SmoothedVariables)
|
||||
isvar(jf)=~(isstruct(SmoothedVariables{jf}));
|
||||
end
|
||||
SmoothedVariables=cell2struct(SmoothedVariables(logical(isvar)),my_field_names(logical(isvar)));
|
||||
|
||||
|
||||
y0=zeros(length(SmoothedVariables.(varargin{1})),length(varargin));
|
||||
for j=1:length(varargin)
|
||||
y0(:,j)=SmoothedVariables.(varargin{j});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function y0 = get_update(varargin)
|
||||
% function x = get_update(vname1, vname2, )
|
||||
% returns updated variables identified by their name
|
||||
%
|
||||
% INPUTS:
|
||||
% vname1, vname2, ... : list of variable names
|
||||
%
|
||||
% OUTPUTS
|
||||
% x: smoothed variables [T x number of variables]
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2019 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
global oo_
|
||||
|
||||
y0=zeros(length(oo_.UpdatedVariables.(varargin{1})),length(varargin));
|
||||
for j=1:length(varargin)
|
||||
y0(:,j)=oo_.UpdatedVariables.(varargin{j});
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
function set_shock_stderr_value(exoname,value)
|
||||
|
||||
% Copyright (C) 2019 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
global M_
|
||||
|
||||
i = strmatch(exoname,M_.exo_names,'exact');
|
||||
|
||||
if isempty(i)
|
||||
error(['Shock name ' exoname ' doesn''t exist'])
|
||||
end
|
||||
|
||||
M_.Sigma_e(i,i) = value^2;
|
|
@ -0,0 +1,200 @@
|
|||
function v = allVL1(n, L1, L1ops, MaxNbSol)
|
||||
% All integer permutations with sum criteria
|
||||
%
|
||||
% function v=allVL1(n, L1); OR
|
||||
% v=allVL1(n, L1, L1opt);
|
||||
% v=allVL1(n, L1, L1opt, MaxNbSol);
|
||||
%
|
||||
% INPUT
|
||||
% n: length of the vector
|
||||
% L1: target L1 norm
|
||||
% L1ops: optional string ('==' or '<=' or '<')
|
||||
% default value is '=='
|
||||
% MaxNbSol: integer, returns at most MaxNbSol permutations.
|
||||
% When MaxNbSol is NaN, allVL1 returns the total number of all possible
|
||||
% permutations, which is useful to check the feasibility before getting
|
||||
% the permutations.
|
||||
% OUTPUT:
|
||||
% v: (m x n) array such as: sum(v,2) == L1,
|
||||
% (or <= or < depending on L1ops)
|
||||
% all elements of v is naturel numbers {0,1,...}
|
||||
% v contains all (=m) possible combinations
|
||||
% v is sorted by sum (L1 norm), then by dictionnary sorting criteria
|
||||
% class(v) is same as class(L1)
|
||||
% Algorithm:
|
||||
% Recursive
|
||||
% Remark:
|
||||
% allVL1(n,L1-n)+1 for natural numbers defined as {1,2,...}
|
||||
% Example:
|
||||
% This function can be used to generate all orders of all
|
||||
% multivariable polynomials of degree p in R^n:
|
||||
% Order = allVL1(n, p)
|
||||
% Author: Bruno Luong (brunoluong@yahoo.com)
|
||||
% Original, 30/nov/2007
|
||||
% Version 1.1, 30/apr/2008: Add H1 line as suggested by John D'Errico
|
||||
% 1.2, 17/may/2009: Possibility to get the number of permutations
|
||||
% alone (set fourth parameter MaxNbSol to NaN)
|
||||
% 1.3, 16/Sep/2009: Correct bug for number of solution
|
||||
% 1.4, 18/Dec/2010: + non-recursive engine
|
||||
|
||||
% Retrieved from https://www.mathworks.com/matlabcentral/fileexchange/17818-all-permutations-of-integers-with-sum-criteria
|
||||
% =========================================================================
|
||||
% Copyright (C) 2007-2010 Bruno Luong <brunoluong@yahoo.com>
|
||||
% Copyright (C) 2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
% =========================================================================
|
||||
global MaxCounter;
|
||||
|
||||
if nargin<3 || isempty(L1ops)
|
||||
L1ops = '==';
|
||||
end
|
||||
|
||||
n = floor(n); % make sure n is integer
|
||||
|
||||
if n<1
|
||||
v = [];
|
||||
return
|
||||
end
|
||||
|
||||
if nargin<4 || isempty(MaxNbSol)
|
||||
MaxCounter = Inf;
|
||||
else
|
||||
MaxCounter = MaxNbSol;
|
||||
end
|
||||
Counter(0);
|
||||
|
||||
switch L1ops
|
||||
case {'==' '='},
|
||||
if isnan(MaxCounter)
|
||||
% return the number of solutions
|
||||
v = nchoosek(n+L1-1,L1); % nchoosek(n+L1-1,n-1)
|
||||
else
|
||||
v = allVL1eq(n, L1);
|
||||
end
|
||||
case '<=', % call allVL1eq for various sum targets
|
||||
if isnan(MaxCounter)
|
||||
% return the number of solutions
|
||||
%v = nchoosek(n+L1,L1)*factorial(n-L1); BUG <- 16/Sep/2009:
|
||||
v = 0;
|
||||
for j=0:L1
|
||||
v = v + nchoosek(n+j-1,j);
|
||||
end
|
||||
% See pascal's 11th identity, the sum doesn't seem to
|
||||
% simplify to a fix formula
|
||||
else
|
||||
v = cell2mat(arrayfun(@(j) allVL1eq(n, j), (0:L1)', ...
|
||||
'UniformOutput', false));
|
||||
end
|
||||
case '<',
|
||||
v = allVL1(n, L1-1, '<=', MaxCounter);
|
||||
otherwise
|
||||
error('allVL1: unknown L1ops')
|
||||
end
|
||||
|
||||
end % allVL1
|
||||
|
||||
%%
|
||||
function v = allVL1eq(n, L1)
|
||||
|
||||
global MaxCounter;
|
||||
|
||||
n = feval(class(L1),n);
|
||||
s = n+L1;
|
||||
sd = double(n)+double(L1);
|
||||
notoverflowed = double(s)==sd;
|
||||
if isinf(MaxCounter) && notoverflowed
|
||||
v = allVL1nonrecurs(n, L1);
|
||||
else
|
||||
v = allVL1recurs(n, L1);
|
||||
end
|
||||
|
||||
end % allVL1eq
|
||||
|
||||
%% Recursive engine
|
||||
function v = allVL1recurs(n, L1, head)
|
||||
% function v=allVL1eq(n, L1);
|
||||
% INPUT
|
||||
% n: length of the vector
|
||||
% L1: desired L1 norm
|
||||
% head: optional parameter to by concatenate in the first column
|
||||
% of the output
|
||||
% OUTPUT:
|
||||
% if head is not defined
|
||||
% v: (m x n) array such as sum(v,2)==L1
|
||||
% all elements of v is naturel numbers {0,1,...}
|
||||
% v contains all (=m) possible combinations
|
||||
% v is (dictionnary) sorted
|
||||
% Algorithm:
|
||||
% Recursive
|
||||
|
||||
global MaxCounter;
|
||||
|
||||
if n==1
|
||||
if Counter < MaxCounter
|
||||
v = L1;
|
||||
else
|
||||
v = zeros(0,1,class(L1));
|
||||
end
|
||||
else % recursive call
|
||||
v = cell2mat(arrayfun(@(j) allVL1recurs(n-1, L1-j, j), (0:L1)', ...
|
||||
'UniformOutput', false));
|
||||
end
|
||||
|
||||
if nargin>=3 % add a head column
|
||||
v = [head+zeros(size(v,1),1,class(head)) v];
|
||||
end
|
||||
|
||||
end % allVL1recurs
|
||||
|
||||
%%
|
||||
function res=Counter(newval)
|
||||
persistent counter;
|
||||
if nargin>=1
|
||||
counter = newval;
|
||||
res = counter;
|
||||
else
|
||||
res = counter;
|
||||
counter = counter+1;
|
||||
end
|
||||
end % Counter
|
||||
|
||||
%% Non-recursive engine
|
||||
function v = allVL1nonrecurs(n, L1)
|
||||
% function v=allVL1eq(n, L1);
|
||||
% INPUT
|
||||
% n: length of the vector
|
||||
% L1: desired L1 norm
|
||||
% OUTPUT:
|
||||
% if head is not defined
|
||||
% v: (m x n) array such as sum(v,2)==L1
|
||||
% all elements of v is naturel numbers {0,1,...}
|
||||
% v contains all (=m) possible combinations
|
||||
% v is (dictionnary) sorted
|
||||
% Algorithm:
|
||||
% NonRecursive
|
||||
|
||||
% Chose (n-1) the splitting points of the array [0:(n+L1)]
|
||||
s = nchoosek(1:n+L1-1,n-1);
|
||||
m = size(s,1);
|
||||
|
||||
s1 = zeros(m,1,class(L1));
|
||||
s2 = (n+L1)+s1;
|
||||
|
||||
v = diff([s1 s s2],1,2); % m x n
|
||||
v = v-1;
|
||||
|
||||
end % allVL1nonrecurs
|
|
@ -158,7 +158,7 @@ if realtime_ && isstruct(oo_) && isfield(oo_, 'realtime_shock_decomposition')
|
|||
myopts.plot_shock_decomp.realtime=1;
|
||||
myopts.plot_shock_decomp.vintage=i;
|
||||
% retrieve quarterly shock decomp
|
||||
z = plot_shock_decomposition(M_,oo_,myopts,[]);
|
||||
[z, ~] = plot_shock_decomposition(M_,oo_,myopts,[]);
|
||||
zdim = size(z);
|
||||
z = z(i_var,:,:);
|
||||
if isstruct(aux)
|
||||
|
@ -185,13 +185,14 @@ if realtime_ && isstruct(oo_) && isfield(oo_, 'realtime_shock_decomposition')
|
|||
if qvintage_>i-4 && qvintage_<i
|
||||
myopts.plot_shock_decomp.vintage=qvintage_;
|
||||
% retrieve quarterly shock decomp
|
||||
z = plot_shock_decomposition(M_,oo_,myopts,[]);
|
||||
[z, ~] = plot_shock_decomposition(M_,oo_,myopts,[]);
|
||||
z(:,:,end+1:zdim(3))=nan; % fill with nan's remaining time points to reach Q4
|
||||
z = z(i_var,:,:);
|
||||
if isstruct(aux)
|
||||
if ischar(aux0.y)
|
||||
% retrieve quarterly shock decomp for aux variable
|
||||
[y_aux, steady_state_aux] = plot_shock_decomposition(M_,oo_,myopts,aux0.y);
|
||||
y_aux(:,:,end+1:zdim(3))=nan; % fill with nan's remaining time points to reach Q4
|
||||
aux.y=y_aux;
|
||||
aux.yss=steady_state_aux;
|
||||
end
|
||||
|
@ -202,6 +203,7 @@ if realtime_ && isstruct(oo_) && isfield(oo_, 'realtime_shock_decomposition')
|
|||
|
||||
end
|
||||
oo_.annualized_realtime_forecast_shock_decomposition.(['yr_' int2str(yr)]) = z(:,:,end-nfrcst:end);
|
||||
oo_.annualized_realtime_forecast_shock_decomposition.pool(:,:,yr+1) = squeeze(z(:,:,end-nfrcst+1));
|
||||
if init>nfrcst
|
||||
oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(yr-nfrcst)]) = ...
|
||||
oo_.annualized_realtime_shock_decomposition.pool(:,:,yr-nfrcst:end) - ...
|
||||
|
@ -223,8 +225,12 @@ if realtime_ && isstruct(oo_) && isfield(oo_, 'realtime_shock_decomposition')
|
|||
oo_.annualized_realtime_forecast_shock_decomposition.(['yr_' int2str(yr-my_forecast_)])(:,end,1:my_forecast_+1);
|
||||
oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(yr-my_forecast_)])(:,end,:) = ...
|
||||
oo_.annualized_realtime_shock_decomposition.pool(:,end,yr-my_forecast_:yr);
|
||||
oo_.annualized_realtime_conditional_shock_decomposition.pool(:,:,yr-my_forecast_+1) = ...
|
||||
oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(yr-my_forecast_)])(:,:,2);
|
||||
end
|
||||
end
|
||||
oo_.annualized_realtime_conditional_shock_decomposition.pool(:,:,yr-nfrcst+1) = ...
|
||||
oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(yr-nfrcst)])(:,:,2);
|
||||
end
|
||||
end
|
||||
% ztmp=oo_.realtime_shock_decomposition.pool(:,:,21:29)-oo_.realtime_forecast_shock_decomposition.time_21;
|
||||
|
@ -251,14 +257,14 @@ if realtime_ && isstruct(oo_) && isfield(oo_, 'realtime_shock_decomposition')
|
|||
if vintage_
|
||||
z = oo_.annualized_realtime_conditional_shock_decomposition.(['yr_' int2str(floor(vintage_/4))]);
|
||||
else
|
||||
error();
|
||||
z = oo_.annualized_realtime_conditional_shock_decomposition.pool;
|
||||
end
|
||||
|
||||
case 3 % forecast
|
||||
if vintage_
|
||||
z = oo_.annualized_realtime_forecast_shock_decomposition.(['yr_' int2str(floor(vintage_/4))]);
|
||||
else
|
||||
error()
|
||||
z = oo_.annualized_realtime_forecast_shock_decomposition.pool;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -299,16 +305,22 @@ for j=1:nvar
|
|||
end
|
||||
ztmp=squeeze(za(j,:,:));
|
||||
if cumfix==0
|
||||
zscale = sum(ztmp(1:end-1,:))./ztmp(end,:);
|
||||
ztmp(1:end-1,:) = ztmp(1:end-1,:)./repmat(zscale,[nterms-1,1]);
|
||||
zres = ztmp(end,:) - sum(ztmp(1:end-1,:));
|
||||
w = abs(ztmp(1:end-1,:))./sum(abs(ztmp(1:end-1,:)));
|
||||
ztmp(1:end-1,:) = ztmp(1:end-1,:) + repmat(zres,[nterms-1 1]).*w;
|
||||
% zscale = sum(ztmp(1:end-1,:))./ztmp(end,:);
|
||||
% ztmp(1:end-1,:) = ztmp(1:end-1,:)./repmat(zscale,[nterms-1,1]);
|
||||
else
|
||||
zres = ztmp(end,:)-sum(ztmp(1:end-1,:));
|
||||
ztmp(1:end-1,:) = ztmp(1:end-1,:) + repmat(zres,[nterms-1 1])/(nterms-1);
|
||||
end
|
||||
gztmp=squeeze(gza(j,:,:));
|
||||
if cumfix==0
|
||||
gscale = sum(gztmp(1:end-1,:))./ gztmp(end,:);
|
||||
gztmp(1:end-1,:) = gztmp(1:end-1,:)./repmat(gscale,[nterms-1,1]);
|
||||
gres = gztmp(end,:) - sum(gztmp(1:end-1,:));
|
||||
w = abs(gztmp(1:end-1,:))./sum(abs(gztmp(1:end-1,:)));
|
||||
gztmp(1:end-1,:) = gztmp(1:end-1,:) + repmat(gres,[nterms-1 1]).*w;
|
||||
% gscale = sum(gztmp(1:end-1,:))./ gztmp(end,:);
|
||||
% gztmp(1:end-1,:) = gztmp(1:end-1,:)./repmat(gscale,[nterms-1,1]);
|
||||
else
|
||||
gres = gztmp(end,:) - sum(gztmp(1:end-1,:));
|
||||
gztmp(1:end-1,:) = gztmp(1:end-1,:) + repmat(gres,[nterms-1 1])/(nterms-1);
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
function [y,dy] = bivmom(p,rho)
|
||||
% Computes the product moment (and its derivative with respect to standard
|
||||
% errors and correlation parameters) of X_1^{p_1}X_2^{p_2}, where X_1 and X_2
|
||||
% are standard bivariate normally distributed.
|
||||
% n : dimension of X
|
||||
% rho: correlation coefficient between X_1 and X_2
|
||||
% =========================================================================
|
||||
% INPUTS
|
||||
% p [2 by 1] powers of X_{1} and X_{2}
|
||||
% rho [1 by 1] correlation coefficient between X_1 and X_2
|
||||
% -------------------------------------------------------------------------
|
||||
% OUTPUTS
|
||||
% y [1 by 1] product moment E[X_1^{p_1}X_2^{p_2}]
|
||||
% dy [1 by 1] derivative of y wrt to rho
|
||||
% -------------------------------------------------------------------------
|
||||
% This function is based upon bivmom.m which is part of replication codes
|
||||
% of the following paper:
|
||||
% Kan, R.: "From moments of sum to moments of product." Journal of
|
||||
% Multivariate Analysis, 2008, vol. 99, issue 3, pages 542-554.
|
||||
% bivmom.m can be retrieved from http://www-2.rotman.utoronto.ca/~kan/papers/prodmom.zip
|
||||
% Further references:
|
||||
% Kotz, Balakrishnan, and Johnson (2000), Continuous Multivariate Distributions, Vol. 1, p.261
|
||||
% Note that there is a typo in Eq.(46.25), there should be an extra rho in front
|
||||
% of the equation.
|
||||
% =========================================================================
|
||||
% Copyright (C) 2008-2015 Raymond Kan <kan@chass.utoronto.ca>
|
||||
% Copyright (C) 2019-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
% =========================================================================
|
||||
s1 = p(1);
|
||||
s2 = p(2);
|
||||
rho2 = rho^2;
|
||||
if nargout > 1
|
||||
drho2 = 2*rho;
|
||||
end
|
||||
if rem(s1+s2,2)==1
|
||||
y = 0;
|
||||
return
|
||||
end
|
||||
r = fix(s1/2);
|
||||
s = fix(s2/2);
|
||||
y = 1;
|
||||
c = 1;
|
||||
if nargout > 1
|
||||
dy = 0;
|
||||
dc = 0;
|
||||
end
|
||||
odd = 2*rem(s1,2);
|
||||
for j=1:min(r,s)
|
||||
if nargout > 1
|
||||
dc = 2*dc*(r+1-j)*(s+1-j)*rho2/(j*(2*j-1+odd)) + 2*c*(r+1-j)*(s+1-j)*drho2/(j*(2*j-1+odd));
|
||||
end
|
||||
c = 2*c*(r+1-j)*(s+1-j)*rho2/(j*(2*j-1+odd));
|
||||
y = y+c;
|
||||
if nargout > 1
|
||||
dy = dy + dc;
|
||||
end
|
||||
end
|
||||
if odd
|
||||
if nargout > 1
|
||||
dy = y + dy*rho;
|
||||
end
|
||||
y = y*rho;
|
||||
end
|
||||
y = prod([1:2:s1])*prod([1:2:s2])*y;
|
||||
if nargout > 1
|
||||
dy = prod([1:2:s1])*prod([1:2:s2])*dy;
|
||||
end
|
||||
|
|
@ -2,7 +2,7 @@ function [r, g1] = block_bytecode_mfs_steadystate(y, b, y_all, exo, params, M)
|
|||
% Wrapper around the *_static.m file, for use with dynare_solve,
|
||||
% when block_mfs option is given to steady.
|
||||
|
||||
% Copyright (C) 2009-2012 Dynare Team
|
||||
% Copyright (C) 2009-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -21,4 +21,4 @@ function [r, g1] = block_bytecode_mfs_steadystate(y, b, y_all, exo, params, M)
|
|||
|
||||
indx = M.block_structure_stat.block(b).variable;
|
||||
y_all(indx) = y;
|
||||
[chk, r, g1] = bytecode( y_all, exo, params, y_all, 1, y_all, 'evaluate', 'static', ['block = ' int2str(b) ]);
|
||||
[r, g1] = bytecode( y_all, exo, params, y_all, 1, y_all, 'evaluate', 'static', ['block = ' int2str(b) ]);
|
||||
|
|
|
@ -2,7 +2,7 @@ function [r, g1] = bytecode_steadystate(y, exo, params)
|
|||
% Wrapper around the *_static.m file, for use with dynare_solve,
|
||||
% when block_mfs option is given to steady.
|
||||
|
||||
% Copyright (C) 2009-2011 Dynare Team
|
||||
% Copyright (C) 2009-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -19,4 +19,4 @@ function [r, g1] = bytecode_steadystate(y, exo, params)
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
eval('[chk, r, g1] = bytecode( y, exo, params, y, 1, exo, ''evaluate'', ''static'');');
|
||||
eval('[r, g1] = bytecode( y, exo, params, y, 1, exo, ''evaluate'', ''static'');');
|
||||
|
|
|
@ -11,7 +11,7 @@ function varargout = prior(varargin)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2015-2018 Dynare Team
|
||||
% Copyright (C) 2015-2019 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -143,7 +143,8 @@ if ismember('moments', varargin) % Prior simulations (2nd order moments).
|
|||
end
|
||||
if info
|
||||
skipline()
|
||||
fprintf('Cannot solve the model on the prior mode (info = %s, %s)\n', num2str(info(1)), interpret_resol_info(info));
|
||||
message = get_error_message(info,options_);
|
||||
fprintf('Cannot solve the model on the prior mode (info = %d, %s)\n', info(1), message);
|
||||
skipline()
|
||||
return
|
||||
end
|
||||
|
|
|
@ -13,14 +13,15 @@ function k = commutation(n, m, sparseflag)
|
|||
% k: [n by m] commutation matrix
|
||||
% -------------------------------------------------------------------------
|
||||
% This function is called by
|
||||
% * get_first_order_solution_params_deriv.m (previously getH.m)
|
||||
% * get_perturbation_params_derivs.m (previously getH.m)
|
||||
% * get_identification_jacobians.m (previously getJJ.m)
|
||||
% * pruned_state_space_system.m
|
||||
% -------------------------------------------------------------------------
|
||||
% This function calls
|
||||
% * vec (embedded)
|
||||
% =========================================================================
|
||||
% Copyright (C) 1997 Tom Minka <minka@microsoft.com>
|
||||
% Copyright (C) 2019 Dynare Team
|
||||
% Copyright (C) 2019-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -47,24 +48,12 @@ if nargin < 3
|
|||
sparseflag = 0;
|
||||
end
|
||||
|
||||
if 0
|
||||
% first method
|
||||
i = 1:(n*m);
|
||||
a = reshape(i, n, m);
|
||||
j = vec(transpose(a));
|
||||
k = zeros(n*m,n*m);
|
||||
for r = i
|
||||
k(r, j(r)) = 1;
|
||||
end
|
||||
if sparseflag
|
||||
k = reshape(kron(vec(speye(n)), speye(m)), n*m, n*m);
|
||||
else
|
||||
% second method
|
||||
k = reshape(kron(vec(eye(n)), eye(m)), n*m, n*m);
|
||||
end
|
||||
|
||||
if sparseflag ~= 0
|
||||
k = sparse(k);
|
||||
end
|
||||
|
||||
function V = vec(A)
|
||||
V = A(:);
|
||||
end
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
function [dr,info,M_,options_,oo_] =compute_decision_rules(M_,options_,oo_)
|
||||
% function [dr,info,M_,options_,oo_] =compute_decision_rules(M_,options_,oo_)
|
||||
% INPUTS
|
||||
% - M_ [structure] Matlab's structure describing the model (M_).
|
||||
% - options_ [structure] Matlab's structure describing the current options (options_).
|
||||
% - oo_ [structure] Matlab's structure containing the results (oo_).
|
||||
%
|
||||
% OUTPUTS
|
||||
% - dr [structure] Reduced form model.
|
||||
% - info [integer] scalar or vector, error code.
|
||||
% - M_ [structure] Matlab's structure describing the model (M_).
|
||||
% - options_ [structure] Matlab's structure describing the current options (options_).
|
||||
% - oo_ [structure] Matlab's structure containing the results (oo_).
|
||||
|
||||
% Copyright (C) 2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if options_.discretionary_policy
|
||||
[dr,info,M_,options_,oo_] = discretionary_policy_1(options_.instruments,M_,options_,oo_);
|
||||
else
|
||||
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||
end
|
|
@ -89,7 +89,7 @@ results_struct.rne_iid = results_vec(1,4);
|
|||
centered_window_means=window_means-total_mean;
|
||||
autocov_grouped_means=zeros(n_groups,1);
|
||||
for lag=0:n_groups-1
|
||||
autocov_grouped_means(lag+1)=centered_window_means(lag+1:n_groups,1)'*centered_window_means(1:n_groups-lag,1)/100;
|
||||
autocov_grouped_means(lag+1)=centered_window_means(lag+1:n_groups,1)'*centered_window_means(1:n_groups-lag,1)/n_groups;
|
||||
end
|
||||
|
||||
% numerical standard error with tapered autocovariance functions
|
||||
|
|
|
@ -17,7 +17,7 @@ function datatomfile (s, var_list, names)
|
|||
% provided, all the variables as defined in M_.endo_names will be saved in
|
||||
% the generated m file.
|
||||
|
||||
% Copyright (C) 2001-2018 Dynare Team
|
||||
% Copyright (C) 2001-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -68,8 +68,7 @@ for i=1:n
|
|||
ivar(i) = i_tmp;
|
||||
end
|
||||
end
|
||||
stack = dbstack;
|
||||
fprintf(fid,'%% Dataset generated by %s.\n',stack(2).file);
|
||||
fprintf(fid,'%% Dataset generated by %s.mod\n',M_.fname);
|
||||
fprintf(fid,['%% ' datestr(now,0) '\n']);
|
||||
% Save the selected data.
|
||||
for i = 1:n
|
||||
|
|
|
@ -12,7 +12,7 @@ function options_ = default_option_values(M_)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2018-2019 Dynare Team
|
||||
% Copyright (C) 2018-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -71,6 +71,7 @@ options_.huge_number = 1e7;
|
|||
% Default number of threads for parallelized mex files.
|
||||
options_.threads.kronecker.sparse_hessian_times_B_kronecker_C = num_procs;
|
||||
options_.threads.local_state_space_iteration_2 = 1;
|
||||
options_.threads.local_state_space_iteration_k = 1;
|
||||
options_.threads.perfect_foresight_problem = num_procs;
|
||||
options_.threads.k_order_perturbation = max(1, num_procs/2);
|
||||
|
||||
|
@ -154,7 +155,7 @@ options_.relative_irf = false;
|
|||
options_.ar = 5;
|
||||
options_.hp_filter = 0;
|
||||
options_.one_sided_hp_filter = 0;
|
||||
options_.hp_ngrid = 512;
|
||||
options_.filtered_theoretical_moments_grid = 512;
|
||||
options_.nodecomposition = false;
|
||||
options_.nomoments = false;
|
||||
options_.nocorr = false;
|
||||
|
@ -651,6 +652,7 @@ options_.parameter_set = [];
|
|||
options_.use_shock_groups = '';
|
||||
options_.shock_decomp.colormap = '';
|
||||
options_.shock_decomp.init_state = 0;
|
||||
options_.shock_decomp.with_epilogue = false;
|
||||
|
||||
% Shock decomposition realtime
|
||||
options_.shock_decomp.forecast = 0;
|
||||
|
@ -714,6 +716,9 @@ options_.convergence.geweke.geweke_interval=[0.2 0.5];
|
|||
options_.convergence.rafterylewis.indicator=false;
|
||||
options_.convergence.rafterylewis.qrs=[0.025 0.005 0.95];
|
||||
|
||||
%tolerance for Modified Harmonic Mean estimator
|
||||
options_.marginal_data_density.harmonic_mean.tolerance = 0.01;
|
||||
|
||||
% Options for lmmcp solver
|
||||
options_.lmmcp.status = false;
|
||||
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
function [info, oo_, options_] = discretionary_policy(M_, options_, oo_, var_list)
|
||||
function [info, oo_, options_, M_] = discretionary_policy(M_, options_, oo_, var_list)
|
||||
% function [info, oo_, options_, M_] = discretionary_policy(M_, options_, oo_, var_list)
|
||||
% INPUTS
|
||||
% - M_ [structure] Matlab's structure describing the model (M_).
|
||||
% - options_ [structure] Matlab's structure describing the current options (options_).
|
||||
% - oo_ [structure] Matlab's structure containing the results (oo_).
|
||||
% - var_list [cell] list of variables
|
||||
%
|
||||
% OUTPUTS
|
||||
% - info [integer] scalar or vector, error code.
|
||||
% - oo_ [structure] Matlab's structure containing the results (oo_).
|
||||
% - options_ [structure] Matlab's structure describing the current options (options_).
|
||||
% - M_ [structure] Matlab's structure describing the model (M_).
|
||||
|
||||
% Copyright (C) 2007-2019 Dynare Team
|
||||
% Copyright (C) 2007-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -17,15 +29,12 @@ function [info, oo_, options_] = discretionary_policy(M_, options_, oo_, var_lis
|
|||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if options_.loglinear
|
||||
% Ensure it's ok to ignore options_ returned from stoch_simul. #1197
|
||||
error('discretionary_policy is not compatible with `loglinear` option set to 1')
|
||||
end
|
||||
M_=discretionary_policy_initialization(M_,options_);
|
||||
|
||||
origorder = options_.order;
|
||||
options_.discretionary_policy = 1;
|
||||
options_.order = 1;
|
||||
[info, oo_] = stoch_simul(M_, options_, oo_, var_list);
|
||||
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, var_list);
|
||||
|
||||
if ~options_.noprint
|
||||
disp_steady_state(M_,oo_)
|
|
@ -0,0 +1,125 @@
|
|||
function [dr, info, M_, options_, oo_]=discretionary_policy_1(Instruments, M_, options_, oo_)
|
||||
% Higher-level function for solving discretionary optimal policy
|
||||
% INPUTS
|
||||
% - Instruments [cell] array containing instrument names
|
||||
% - M_ [structure] Matlab's structure describing the model (M_).
|
||||
% - options_ [structure] Matlab's structure describing the current options (options_).
|
||||
% - oo_ [structure] Matlab's structure containing the results (oo_).
|
||||
%
|
||||
% OUTPUTS
|
||||
% - dr [structure] Reduced form model.
|
||||
% - info [integer] scalar or vector, error code.
|
||||
% - M_ [structure] Matlab's structure describing the model (M_).
|
||||
% - options_ [structure] Matlab's structure describing the current options (options_).
|
||||
% - oo_ [structure] Matlab's structure containing the results (oo_).
|
||||
|
||||
% Copyright (C) 2007-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
persistent Hold
|
||||
|
||||
info = 0;
|
||||
|
||||
dr=oo_.dr; %initialize output argument
|
||||
|
||||
beta = get_optimal_policy_discount_factor(M_.params, M_.param_names);
|
||||
|
||||
%call steady_state_file if present to update parameters
|
||||
if options_.steadystate_flag
|
||||
% explicit steady state file
|
||||
[~,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ...
|
||||
options_,false);
|
||||
if info(1)
|
||||
return;
|
||||
end
|
||||
end
|
||||
[U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(M_.endo_nbr,1),[], M_.params);
|
||||
if any(any(isnan(Uy)))
|
||||
info = 64 ; %the derivatives of the objective function contain NaN
|
||||
return;
|
||||
end
|
||||
if any(any(Uy~=0))
|
||||
if options_.debug
|
||||
non_zero_derivs=find(any(Uy~=0));
|
||||
for ii=1:length(non_zero_derivs)
|
||||
non_zero_deriv_names{ii,1} = M_.endo_names{non_zero_derivs(ii)};
|
||||
end
|
||||
disp_string=[non_zero_deriv_names{1,:}];
|
||||
for ii=2:size(non_zero_deriv_names,1)
|
||||
disp_string=[disp_string,', ',non_zero_deriv_names{ii,:}];
|
||||
end
|
||||
fprintf('\nThe derivative of the objective function w.r.t. to variable(s) %s is not 0\n',disp_string);
|
||||
end
|
||||
info = 66;
|
||||
return;
|
||||
end
|
||||
|
||||
W=reshape(W,M_.endo_nbr,M_.endo_nbr);
|
||||
|
||||
klen = M_.maximum_lag + M_.maximum_lead + 1;
|
||||
iyv=M_.lead_lag_incidence';
|
||||
% Find the jacobian
|
||||
z = repmat(zeros(M_.endo_nbr,1),1,klen);
|
||||
z = z(nonzeros(iyv)) ;
|
||||
it_ = M_.maximum_lag + 1 ;
|
||||
|
||||
if M_.exo_nbr == 0
|
||||
oo_.exo_steady_state = [] ;
|
||||
end
|
||||
|
||||
[junk,jacobia_] = feval([M_.fname '.dynamic'],z, [zeros(size(oo_.exo_simul)) ...
|
||||
oo_.exo_det_simul], M_.params, zeros(M_.endo_nbr,1), it_);
|
||||
if any(junk~=0)
|
||||
info = 65; %the model must be written in deviation form and not have constant terms
|
||||
return;
|
||||
end
|
||||
|
||||
Indices={'lag','contemp','lead'};
|
||||
iter=1;
|
||||
for j=1:numel(Indices)
|
||||
A.(Indices{j})=zeros(M_.orig_eq_nbr,M_.endo_nbr);
|
||||
if strcmp(Indices{j},'contemp')||(strcmp(Indices{j},'lag') && M_.maximum_lag)||(strcmp(Indices{j},'lead') && M_.maximum_lead)
|
||||
[~,row,col]=find(M_.lead_lag_incidence(iter,:));
|
||||
A.(Indices{j})(:,row)=jacobia_(:,col);
|
||||
iter=iter+1;
|
||||
end
|
||||
end
|
||||
B=jacobia_(:,nnz(iyv)+1:end);
|
||||
|
||||
%%% MAIN ENGINE %%%
|
||||
|
||||
if ~isempty(Hold)
|
||||
[H,G,info]=discretionary_policy_engine(A.lag,A.contemp,A.lead,B,W,M_.instr_id,beta,options_.dp.maxit,options_.discretionary_tol,options_.qz_criterium,Hold);
|
||||
else
|
||||
[H,G,info]=discretionary_policy_engine(A.lag,A.contemp,A.lead,B,W,M_.instr_id,beta,options_.dp.maxit,options_.discretionary_tol,options_.qz_criterium);
|
||||
end
|
||||
|
||||
if info
|
||||
return
|
||||
else
|
||||
Hold=H; %save previous solution
|
||||
% Hold=[]; use this line if persistent command is not used.
|
||||
end
|
||||
|
||||
%write back solution to dr
|
||||
dr.ys =zeros(M_.endo_nbr,1);
|
||||
dr=set_state_space(dr,M_,options_);
|
||||
T=H(dr.order_var,dr.order_var);
|
||||
dr.ghu=G(dr.order_var,:);
|
||||
Selection=M_.lead_lag_incidence(1,dr.order_var)>0;%select state variables
|
||||
dr.ghx=T(:,Selection);
|
||||
oo_.dr = dr;
|
|
@ -0,0 +1,65 @@
|
|||
function M_=discretionary_policy_initialization(M_,options_)
|
||||
% function M_=discretionary_policy_initialization(M_,options_)
|
||||
% INPUTS
|
||||
% - M_ [structure] Matlab's structure describing the model (M_).
|
||||
% - options_ [structure] Matlab's structure describing the current options (options_).
|
||||
%
|
||||
% OUTPUTS
|
||||
% - M_ [structure] Matlab's structure describing the model (M_).
|
||||
|
||||
% Copyright (C) 2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
if options_.loglinear
|
||||
% Ensure it's ok to ignore options_ returned from stoch_simul. #1197
|
||||
error('discretionary_policy is not compatible with `loglinear` option set to 1')
|
||||
end
|
||||
|
||||
% safeguard against issues like running ramsey policy first and then running discretion
|
||||
if isfield(M_,'orig_model')
|
||||
M_.endo_nbr = M_.orig_model.endo_nbr;
|
||||
M_.endo_names = M_.orig_model.endo_names;
|
||||
M_.lead_lag_incidence = M_.orig_model.lead_lag_incidence;
|
||||
M_.maximum_lead = M_.orig_model.maximum_lead;
|
||||
M_.maximum_endo_lead = M_.orig_model.maximum_endo_lead;
|
||||
M_.maximum_lag = M_.orig_model.maximum_lag;
|
||||
M_.maximum_endo_lag = M_.orig_model.maximum_endo_lag;
|
||||
end
|
||||
|
||||
instr_nbr=M_.orig_endo_nbr-M_.orig_eq_nbr;
|
||||
|
||||
if instr_nbr==0
|
||||
error('discretionary_policy:: There are no available instruments, because the model has as many equations as variables.')
|
||||
end
|
||||
if size(options_.instruments,1)< instr_nbr
|
||||
error('discretionary_policy:: There are fewer declared instruments than omitted equations.')
|
||||
elseif size(options_.instruments,1)> instr_nbr
|
||||
error('discretionary_policy:: There are more declared instruments than omitted equations.')
|
||||
end
|
||||
|
||||
instr_id=NaN(size(options_.instruments,1),1);
|
||||
for j=1:size(options_.instruments,1)
|
||||
vj=deblank(options_.instruments{j});
|
||||
vj_id=strmatch(vj, M_.endo_names, 'exact');
|
||||
if ~isempty(vj_id)
|
||||
instr_id(j)=vj_id;
|
||||
else
|
||||
error([mfilename,':: instrument ',vj,' not found'])
|
||||
end
|
||||
end
|
||||
M_.instr_id=instr_id;
|
|
@ -1,179 +0,0 @@
|
|||
function [dr,ys,info]=discretionary_policy_1(oo_,Instruments)
|
||||
|
||||
% Copyright (C) 2007-2018 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
global M_ options_
|
||||
persistent Hold
|
||||
|
||||
dr = [];
|
||||
ys = [];
|
||||
info = 0;
|
||||
|
||||
if isempty(options_.qz_criterium)
|
||||
options_.qz_criterium = 1+1e-6;
|
||||
end
|
||||
|
||||
% safeguard against issues like running ramsey policy first and then running discretion
|
||||
if isfield(M_,'orig_model')
|
||||
orig_model = M_.orig_model;
|
||||
M_.endo_nbr = orig_model.endo_nbr;
|
||||
M_.endo_names = orig_model.endo_names;
|
||||
M_.lead_lag_incidence = orig_model.lead_lag_incidence;
|
||||
M_.maximum_lead = orig_model.maximum_lead;
|
||||
M_.maximum_endo_lead = orig_model.maximum_endo_lead;
|
||||
M_.maximum_lag = orig_model.maximum_lag;
|
||||
M_.maximum_endo_lag = orig_model.maximum_endo_lag;
|
||||
else
|
||||
M_.orig_model = M_;
|
||||
end
|
||||
|
||||
beta = get_optimal_policy_discount_factor(M_.params, M_.param_names);
|
||||
|
||||
exo_nbr = M_.exo_nbr;
|
||||
if isfield(M_,'orig_model')
|
||||
orig_model = M_.orig_model;
|
||||
endo_nbr = orig_model.endo_nbr;
|
||||
endo_names = orig_model.endo_names;
|
||||
lead_lag_incidence = orig_model.lead_lag_incidence;
|
||||
MaxLead = orig_model.maximum_lead;
|
||||
MaxLag = orig_model.maximum_lag;
|
||||
else
|
||||
endo_names = M_.endo_names;
|
||||
endo_nbr = M_.endo_nbr;
|
||||
MaxLag=M_.maximum_lag;
|
||||
MaxLead=M_.maximum_lead;
|
||||
lead_lag_incidence = M_.lead_lag_incidence;
|
||||
end
|
||||
|
||||
%call steady_state_file if present to update parameters
|
||||
if options_.steadystate_flag
|
||||
% explicit steady state file
|
||||
[~,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ...
|
||||
options_,0);
|
||||
end
|
||||
[U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(endo_nbr,1),[], M_.params);
|
||||
if any(any(isnan(Uy)))
|
||||
error(['discretionary_policy: the derivatives of the objective function contain NaN'])
|
||||
end
|
||||
if any(any(Uy~=0))
|
||||
non_zero_derivs=find(any(Uy~=0));
|
||||
for ii=1:length(non_zero_derivs)
|
||||
non_zero_deriv_names{ii,1} = M_.endo_names{non_zero_derivs(ii)};
|
||||
end
|
||||
disp_string=[non_zero_deriv_names{1,:}];
|
||||
for ii=2:size(non_zero_deriv_names,1)
|
||||
disp_string=[disp_string,', ',non_zero_deriv_names{ii,:}];
|
||||
end
|
||||
fprintf('\nThe derivative of the objective function w.r.t. to variable(s) %s is not 0\n',disp_string)
|
||||
error(['discretionary_policy: the objective function must have zero ' ...
|
||||
'first order derivatives'])
|
||||
end
|
||||
|
||||
W=reshape(W,endo_nbr,endo_nbr);
|
||||
|
||||
klen = MaxLag + MaxLead + 1;
|
||||
iyv=lead_lag_incidence';
|
||||
% Find the jacobian
|
||||
z = repmat(zeros(endo_nbr,1),1,klen);
|
||||
z = z(nonzeros(iyv)) ;
|
||||
it_ = MaxLag + 1 ;
|
||||
|
||||
if exo_nbr == 0
|
||||
oo_.exo_steady_state = [] ;
|
||||
end
|
||||
|
||||
[junk,jacobia_] = feval([M_.fname '.dynamic'],z, [zeros(size(oo_.exo_simul)) ...
|
||||
oo_.exo_det_simul], M_.params, zeros(endo_nbr,1), it_);
|
||||
if any(junk~=0)
|
||||
error(['discretionary_policy: the model must be written in deviation ' ...
|
||||
'form and not have constant terms'])
|
||||
end
|
||||
|
||||
eq_nbr= size(jacobia_,1);
|
||||
instr_nbr=endo_nbr-eq_nbr;
|
||||
|
||||
if instr_nbr==0
|
||||
error('discretionary_policy:: There are no available instruments, because the model has as many equations as variables.')
|
||||
end
|
||||
if size(Instruments,1)< instr_nbr
|
||||
error('discretionary_policy:: There are fewer declared instruments than omitted equations.')
|
||||
elseif size(Instruments,1)> instr_nbr
|
||||
error('discretionary_policy:: There are more declared instruments than omitted equations.')
|
||||
end
|
||||
|
||||
instr_id=nan(instr_nbr,1);
|
||||
for j=1:instr_nbr
|
||||
vj=deblank(Instruments{j});
|
||||
vj_id=strmatch(vj, endo_names, 'exact');
|
||||
if ~isempty(vj_id)
|
||||
instr_id(j)=vj_id;
|
||||
else
|
||||
error([mfilename,':: instrument ',vj,' not found'])
|
||||
end
|
||||
end
|
||||
|
||||
Indices={'lag','0','lead'};
|
||||
iter=1;
|
||||
for j=1:numel(Indices)
|
||||
eval(['A',Indices{j},'=zeros(eq_nbr,endo_nbr);'])
|
||||
if strcmp(Indices{j},'0')||(strcmp(Indices{j},'lag') && MaxLag)||(strcmp(Indices{j},'lead') && MaxLead)
|
||||
[~,row,col]=find(lead_lag_incidence(iter,:));
|
||||
eval(['A',Indices{j},'(:,row)=jacobia_(:,col);'])
|
||||
iter=iter+1;
|
||||
end
|
||||
end
|
||||
B=jacobia_(:,nnz(iyv)+1:end);
|
||||
|
||||
%%% MAIN ENGINE %%%
|
||||
qz_criterium = options_.qz_criterium;
|
||||
solve_maxit = options_.dp.maxit;
|
||||
discretion_tol = options_.discretionary_tol;
|
||||
|
||||
if ~isempty(Hold)
|
||||
[H,G,info]=discretionary_policy_engine(Alag,A0,Alead,B,W,instr_id,beta,solve_maxit,discretion_tol,qz_criterium,Hold);
|
||||
else
|
||||
[H,G,info]=discretionary_policy_engine(Alag,A0,Alead,B,W,instr_id,beta,solve_maxit,discretion_tol,qz_criterium);
|
||||
end
|
||||
|
||||
if info
|
||||
dr=[];
|
||||
return
|
||||
else
|
||||
Hold=H; %save previous solution
|
||||
% Hold=[]; use this line if persistent command is not used.
|
||||
end
|
||||
% set the state
|
||||
dr=oo_.dr;
|
||||
dr.ys =zeros(endo_nbr,1);
|
||||
dr=set_state_space(dr,M_,options_);
|
||||
order_var=dr.order_var;
|
||||
|
||||
T=H(order_var,order_var);
|
||||
dr.ghu=G(order_var,:);
|
||||
Selection=lead_lag_incidence(1,order_var)>0;%select state variables
|
||||
dr.ghx=T(:,Selection);
|
||||
|
||||
ys=NondistortionarySteadyState(M_);
|
||||
dr.ys=ys; % <--- dr.ys =zeros(NewEndo_nbr,1);
|
||||
|
||||
function ys=NondistortionarySteadyState(M_)
|
||||
if exist([M_.fname,'_steadystate.m'],'file')
|
||||
eval(['ys=',M_.fname,'_steadystate.m;'])
|
||||
else
|
||||
ys=zeros(M_.endo_nbr,1);
|
||||
end
|
|
@ -29,7 +29,7 @@ function disp_dr(dr,order,var_list)
|
|||
|
||||
global M_ options_
|
||||
|
||||
if M_.hessian_eq_zero && order~=1
|
||||
if order~=1 && M_.hessian_eq_zero
|
||||
order = 1;
|
||||
warning('disp_dr: using order = 1 because Hessian is equal to zero');
|
||||
end
|
||||
|
|
|
@ -23,9 +23,6 @@ function disp_identification(pdraws, ide_reducedform, ide_moments, ide_spectrum,
|
|||
% -------------------------------------------------------------------------
|
||||
% This function is called by
|
||||
% * dynare_identification.m
|
||||
% -------------------------------------------------------------------------
|
||||
% This function calls
|
||||
% * dynare_identification.m
|
||||
% =========================================================================
|
||||
% Copyright (C) 2010-2019 Dynare Team
|
||||
%
|
||||
|
@ -74,7 +71,7 @@ fprintf(' Normalize Jacobians: Yes\n');
|
|||
else
|
||||
fprintf(' Normalize Jacobians: No\n');
|
||||
end
|
||||
fprintf(' Tolerance level for rank computations: %.0d\n',options_ident.tol_rank);
|
||||
fprintf(' Tolerance level for rank computations: %s\n',num2str(options_ident.tol_rank));
|
||||
fprintf(' Tolerance level for selecting nonzero columns: %.0d\n',options_ident.tol_deriv);
|
||||
fprintf(' Tolerance level for selecting nonzero singular values: %.0d\n',options_ident.tol_sv);
|
||||
|
||||
|
@ -84,41 +81,52 @@ for jide = 1:4
|
|||
no_warning_message_display = 1;
|
||||
%% Set output strings depending on test
|
||||
if jide == 1
|
||||
strTest = 'REDUCED-FORM'; strJacobian = 'Tau'; strMeaning = 'reduced-form solution';
|
||||
strTest = 'REDUCED-FORM'; strJacobian = 'Tau'; strMeaning = 'Jacobian of steady state and reduced-form solution matrices';
|
||||
if ~no_identification_reducedform
|
||||
noidentification = 0; ide = ide_reducedform;
|
||||
if SampleSize == 1
|
||||
Jacob = ide.dTAU;
|
||||
Jacob = ide.dREDUCEDFORM;
|
||||
end
|
||||
else %skip test
|
||||
noidentification = 1; no_warning_message_display = 0;
|
||||
end
|
||||
elseif jide == 2
|
||||
strTest = 'Iskrev (2010)'; strJacobian = 'J'; strMeaning = 'moments';
|
||||
if ~no_identification_moments
|
||||
noidentification = 0; ide = ide_moments;
|
||||
strTest = 'MINIMAL SYSTEM (Komunjer and Ng, 2011)'; strJacobian = 'Deltabar'; strMeaning = 'Jacobian of steady state and minimal system';
|
||||
if options_ident.order == 2
|
||||
strMeaning = 'Jacobian of first-order minimal system and second-order accurate mean';
|
||||
elseif options_ident.order == 3
|
||||
strMeaning = 'Jacobian of first-order minimal system and third-order accurate mean';
|
||||
end
|
||||
if ~no_identification_minimal
|
||||
noidentification = 0; ide = ide_minimal;
|
||||
if SampleSize == 1
|
||||
Jacob = ide.si_J;
|
||||
Jacob = ide.dMINIMAL;
|
||||
end
|
||||
else %skip test
|
||||
noidentification = 1; no_warning_message_display = 0;
|
||||
end
|
||||
elseif jide == 3
|
||||
strTest = 'Komunjer and NG (2011)'; strJacobian = 'D'; strMeaning = 'minimal system';
|
||||
if ~no_identification_minimal
|
||||
noidentification = 0; ide = ide_minimal;
|
||||
strTest = 'SPECTRUM (Qu and Tkachenko, 2012)'; strJacobian = 'Gbar'; strMeaning = 'Jacobian of mean and spectrum';
|
||||
if options_ident.order > 1
|
||||
strTest = 'SPECTRUM (Mutschler, 2015)';
|
||||
end
|
||||
if ~no_identification_spectrum
|
||||
noidentification = 0; ide = ide_spectrum;
|
||||
if SampleSize == 1
|
||||
Jacob = ide.D;
|
||||
Jacob = ide.dSPECTRUM;
|
||||
end
|
||||
else %skip test
|
||||
noidentification = 1; no_warning_message_display = 0;
|
||||
end
|
||||
elseif jide == 4
|
||||
strTest = 'Qu and Tkachenko (2012)'; strJacobian = 'G'; strMeaning = 'spectrum';
|
||||
if ~no_identification_spectrum
|
||||
noidentification = 0; ide = ide_spectrum;
|
||||
strTest = 'MOMENTS (Iskrev, 2010)'; strJacobian = 'J'; strMeaning = 'Jacobian of first two moments';
|
||||
if options_ident.order > 1
|
||||
strTest = 'MOMENTS (Mutschler, 2015)'; strJacobian = 'Mbar';
|
||||
end
|
||||
if ~no_identification_moments
|
||||
noidentification = 0; ide = ide_moments;
|
||||
if SampleSize == 1
|
||||
Jacob = ide.G;
|
||||
Jacob = ide.si_dMOMENTS;
|
||||
end
|
||||
else %skip test
|
||||
noidentification = 1; no_warning_message_display = 0;
|
||||
|
@ -176,7 +184,7 @@ for jide = 1:4
|
|||
end
|
||||
end
|
||||
|
||||
%% display problematic parameters computed by identification_checks_via_subsets (only for debugging)
|
||||
%% display problematic parameters computed by identification_checks_via_subsets
|
||||
elseif checks_via_subsets
|
||||
if ide.rank < size(Jacob,2)
|
||||
no_warning_message_display = 0;
|
||||
|
@ -236,7 +244,7 @@ end
|
|||
%% Advanced identificaton patterns
|
||||
if SampleSize==1 && options_ident.advanced
|
||||
skipline()
|
||||
for j=1:size(ide_moments.cosnJ,2)
|
||||
for j=1:size(ide_moments.cosndMOMENTS,2)
|
||||
pax=NaN(totparam_nbr,totparam_nbr);
|
||||
fprintf('\n')
|
||||
disp(['Collinearity patterns with ', int2str(j) ,' parameter(s)'])
|
||||
|
@ -249,10 +257,10 @@ if SampleSize==1 && options_ident.advanced
|
|||
namx=[namx ' ' sprintf('%-15s','--')];
|
||||
else
|
||||
namx=[namx ' ' sprintf('%-15s',name{dumpindx})];
|
||||
pax(i,dumpindx)=ide_moments.cosnJ(i,j);
|
||||
pax(i,dumpindx)=ide_moments.cosndMOMENTS(i,j);
|
||||
end
|
||||
end
|
||||
fprintf('%-15s [%s] %14.7f\n',name{i},namx,ide_moments.cosnJ(i,j))
|
||||
fprintf('%-15s [%s] %14.7f\n',name{i},namx,ide_moments.cosndMOMENTS(i,j))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ function [dr,info,M_,options_,oo_] = dr_block(dr,task,M_,options_,oo_,varargin)
|
|||
% none.
|
||||
%
|
||||
|
||||
% Copyright (C) 2010-2017 Dynare Team
|
||||
% Copyright (C) 2010-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -71,12 +71,10 @@ else
|
|||
Size = 1;
|
||||
end
|
||||
if (options_.bytecode)
|
||||
[chck, zz, data]= bytecode('dynamic','evaluate', z, zx, M_.params, dr.ys, 1, data);
|
||||
[zz, data]= bytecode('dynamic','evaluate', z, zx, M_.params, dr.ys, 1, data);
|
||||
else
|
||||
[r, data] = feval([M_.fname '.dynamic'], options_, M_, oo_, z', zx, M_.params, dr.ys, M_.maximum_lag+1, data);
|
||||
chck = 0;
|
||||
end
|
||||
mexErrCheck('bytecode', chck);
|
||||
dr.full_rank = 1;
|
||||
dr.eigval = [];
|
||||
dr.nd = 0;
|
||||
|
@ -440,7 +438,7 @@ for i = 1:Size
|
|||
D = [[aa(row_indx,index_0m) zeros(n_dynamic,n_both) aa(row_indx,index_p)] ; [zeros(n_both, n_pred) eye(n_both) zeros(n_both, n_both + n_fwrd)]];
|
||||
E = [-aa(row_indx,[index_m index_0p]) ; [zeros(n_both, n_both + n_pred) eye(n_both, n_both + n_fwrd) ] ];
|
||||
|
||||
[err, ss, tt, w, sdim, data(i).eigval, info1] = mjdgges(E,D,options_.qz_criterium,options_.qz_zero_threshold);
|
||||
[ss, tt, w, sdim, data(i).eigval, info1] = mjdgges(E,D,options_.qz_criterium,options_.qz_zero_threshold);
|
||||
|
||||
if (verbose)
|
||||
disp('eigval');
|
||||
|
@ -591,7 +589,7 @@ for i = 1:Size
|
|||
elseif options_.sylvester_fp
|
||||
ghx_other = gensylv_fp(A_, B_, C_, D_, i, options_.sylvester_fixed_point_tol);
|
||||
else
|
||||
[err, ghx_other] = gensylv(1, A_, B_, C_, -D_);
|
||||
ghx_other = gensylv(1, A_, B_, C_, -D_);
|
||||
end
|
||||
if options_.aim_solver ~= 1
|
||||
% Necessary when using Sims' routines for QZ
|
||||
|
|
|
@ -111,11 +111,11 @@ function [fval,info,exit_flag,DLIK,Hess,SteadyState,trend_coeff,Model,DynareOpti
|
|||
%! @sp 2
|
||||
%! @strong{This function calls:}
|
||||
%! @sp 1
|
||||
%! @ref{dynare_resolve}, @ref{lyapunov_symm}, @ref{lyapunov_solver}, @ref{compute_Pinf_Pstar}, @ref{kalman_filter_d}, @ref{missing_observations_kalman_filter_d}, @ref{univariate_kalman_filter_d}, @ref{kalman_steady_state}, @ref{get_first_order_solution_params_deriv}, @ref{kalman_filter}, @ref{score}, @ref{AHessian}, @ref{missing_observations_kalman_filter}, @ref{univariate_kalman_filter}, @ref{priordens}
|
||||
%! @ref{dynare_resolve}, @ref{lyapunov_symm}, @ref{lyapunov_solver}, @ref{compute_Pinf_Pstar}, @ref{kalman_filter_d}, @ref{missing_observations_kalman_filter_d}, @ref{univariate_kalman_filter_d}, @ref{kalman_steady_state}, @ref{get_perturbation_params_deriv}, @ref{kalman_filter}, @ref{score}, @ref{AHessian}, @ref{missing_observations_kalman_filter}, @ref{univariate_kalman_filter}, @ref{priordens}
|
||||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2004-2019 Dynare Team
|
||||
% Copyright (C) 2004-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -150,7 +150,9 @@ if DynareOptions.estimation_dll
|
|||
[fval,exit_flag,SteadyState,trend_coeff,info,params,H,Q] ...
|
||||
= logposterior(xparam1,DynareDataset, DynareOptions,Model, ...
|
||||
EstimatedParameters,BayesInfo,DynareResults);
|
||||
mexErrCheck('logposterior', exit_flag);
|
||||
if exit_flag
|
||||
error('Error encountered in logposterior')
|
||||
end
|
||||
Model.params = params;
|
||||
if ~isequal(Model.H,0)
|
||||
Model.H = H;
|
||||
|
@ -455,12 +457,14 @@ switch DynareOptions.lik_init
|
|||
if kalman_algo ~= 2
|
||||
kalman_algo = 1;
|
||||
end
|
||||
try
|
||||
if isequal(H,0)
|
||||
[err,Pstar] = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(Z,mm,length(Z))));
|
||||
Pstar = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(Z,mm,length(Z))));
|
||||
else
|
||||
[err,Pstar] = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(Z,mm,length(Z))),H);
|
||||
Pstar = kalman_steady_state(transpose(T),R*Q*transpose(R),transpose(build_selection_matrix(Z,mm,length(Z))),H);
|
||||
end
|
||||
if err
|
||||
catch ME
|
||||
disp(ME.message)
|
||||
disp(['dsge_likelihood:: I am not able to solve the Riccati equation, so I switch to lik_init=1!']);
|
||||
DynareOptions.lik_init = 1;
|
||||
Pstar=lyapunov_solver(T,R,Q,DynareOptions);
|
||||
|
@ -522,11 +526,29 @@ if analytic_derivation
|
|||
else
|
||||
indparam=[];
|
||||
end
|
||||
if full_Hess
|
||||
[DT, ~, ~, DOm, DYss, ~, D2T, D2Om, D2Yss] = get_first_order_solution_params_deriv(A, B, EstimatedParameters, Model,DynareResults,DynareOptions,kron_flag,indparam,indexo,[],iv);
|
||||
else
|
||||
[DT, ~, ~, DOm, DYss] = get_first_order_solution_params_deriv(A, B, EstimatedParameters, Model,DynareResults,DynareOptions,kron_flag,indparam,indexo,[],iv);
|
||||
old_order = DynareOptions.order;
|
||||
if DynareOptions.order > 1%not sure whether this check is necessary
|
||||
DynareOptions.order = 1; fprintf('Reset order to 1 for analytical parameter derivatives.\n');
|
||||
end
|
||||
old_analytic_derivation_mode = DynareOptions.analytic_derivation_mode;
|
||||
DynareOptions.analytic_derivation_mode = kron_flag;
|
||||
if full_Hess
|
||||
DERIVS = get_perturbation_params_derivs(Model, DynareOptions, EstimatedParameters, DynareResults, indparam, indexo, [], true);
|
||||
indD2T = reshape(1:Model.endo_nbr^2, Model.endo_nbr, Model.endo_nbr);
|
||||
indD2Om = dyn_unvech(1:Model.endo_nbr*(Model.endo_nbr+1)/2);
|
||||
D2T = DERIVS.d2KalmanA(indD2T(iv,iv),:);
|
||||
D2Om = DERIVS.d2Om(dyn_vech(indD2Om(iv,iv)),:);
|
||||
D2Yss = DERIVS.d2Yss(iv,:,:);
|
||||
else
|
||||
DERIVS = get_perturbation_params_derivs(Model, DynareOptions, EstimatedParameters, DynareResults, indparam, indexo, [], false);
|
||||
end
|
||||
DT = zeros(Model.endo_nbr, Model.endo_nbr, size(DERIVS.dghx,3));
|
||||
DT(:,Model.nstatic+(1:Model.nspred),:) = DERIVS.dghx;
|
||||
DT = DT(iv,iv,:);
|
||||
DOm = DERIVS.dOm(iv,iv,:);
|
||||
DYss = DERIVS.dYss(iv,:);
|
||||
DynareOptions.order = old_order; %make sure order is reset (not sure if necessary)
|
||||
DynareOptions.analytic_derivation_mode = old_analytic_derivation_mode;%make sure analytic_derivation_mode is reset (not sure if necessary)
|
||||
else
|
||||
DT = derivatives_info.DT(iv,iv,:);
|
||||
DOm = derivatives_info.DOm(iv,iv,:);
|
||||
|
@ -629,8 +651,7 @@ singularity_has_been_detected = false;
|
|||
if ((kalman_algo==1) || (kalman_algo==3))% Multivariate Kalman Filter
|
||||
if no_missing_data_flag
|
||||
if DynareOptions.block
|
||||
[err, LIK] = block_kalman_filter(T,R,Q,H,Pstar,Y,start,Z,kalman_tol,riccati_tol, Model.nz_state_var, Model.n_diag, Model.nobs_non_statevar);
|
||||
mexErrCheck('block_kalman_filter', err);
|
||||
LIK = block_kalman_filter(T,R,Q,H,Pstar,Y,start,Z,kalman_tol,riccati_tol, Model.nz_state_var, Model.n_diag, Model.nobs_non_statevar);
|
||||
elseif DynareOptions.fast_kalman_filter
|
||||
if diffuse_periods
|
||||
%kalman_algo==3 requires no diffuse periods (stationary
|
||||
|
@ -659,7 +680,7 @@ if ((kalman_algo==1) || (kalman_algo==3))% Multivariate Kalman Filter
|
|||
end
|
||||
else
|
||||
if 0 %DynareOptions.block
|
||||
[err, LIK,lik] = block_kalman_filter(DatasetInfo.missing.aindex,DatasetInfo.missing.number_of_observations,DatasetInfo.missing.no_more_missing_observations,...
|
||||
[LIK,lik] = block_kalman_filter(DatasetInfo.missing.aindex,DatasetInfo.missing.number_of_observations,DatasetInfo.missing.no_more_missing_observations,...
|
||||
T,R,Q,H,Pstar,Y,start,Z,kalman_tol,riccati_tol, Model.nz_state_var, Model.n_diag, Model.nobs_non_statevar);
|
||||
else
|
||||
[LIK,lik] = missing_observations_kalman_filter(DatasetInfo.missing.aindex,DatasetInfo.missing.number_of_observations,DatasetInfo.missing.no_more_missing_observations,Y,diffuse_periods+1,size(Y,2), ...
|
||||
|
|
|
@ -19,7 +19,7 @@ function [nvar,vartan,NumberOfConditionalDecompFiles] = ...
|
|||
% vartan [char] array of characters (with nvar rows).
|
||||
% NumberOfConditionalDecompFiles [integer] scalar, number of prior or posterior data files (for covariance).
|
||||
|
||||
% Copyright (C) 2009-2015 Dynare Team
|
||||
% Copyright (C) 2009-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -39,10 +39,10 @@ function [nvar,vartan,NumberOfConditionalDecompFiles] = ...
|
|||
|
||||
% Get informations about the _posterior_draws files.
|
||||
if strcmpi(type,'posterior')
|
||||
DrawsFiles = dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]);
|
||||
NumberOfDrawsFiles = length(dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]));
|
||||
posterior = 1;
|
||||
elseif strcmpi(type,'prior')
|
||||
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
|
||||
NumberOfDrawsFiles = length(dir([M_.dname '/prior/draws/' type '_draws*' ]));
|
||||
CheckPath('prior/moments',M_.dname);
|
||||
posterior = 0;
|
||||
else
|
||||
|
@ -78,7 +78,6 @@ nvar = length(ivar);
|
|||
nar = options_.ar;
|
||||
options_.ar = 0;
|
||||
|
||||
NumberOfDrawsFiles = rows(DrawsFiles);
|
||||
NumberOfSavedElementsPerSimulation = nvar*M_.exo_nbr*length(Steps);
|
||||
MaXNumberOfConditionalDecompLines = ceil(options_.MaxNumberOfBytes/NumberOfSavedElementsPerSimulation/8);
|
||||
|
||||
|
@ -132,9 +131,9 @@ linea = 0;
|
|||
linea_ME = 0;
|
||||
for file = 1:NumberOfDrawsFiles
|
||||
if posterior
|
||||
load([M_.dname '/metropolis/' DrawsFiles(file).name ]);
|
||||
load([M_.dname '/metropolis/' M_.fname '_' type '_draws' num2str(file) ]);
|
||||
else
|
||||
load([M_.dname '/prior/draws/' DrawsFiles(file).name ]);
|
||||
load([M_.dname '/prior/draws/' type '_draws' num2str(file) ]);
|
||||
end
|
||||
isdrsaved = columns(pdraws)-1;
|
||||
NumberOfDraws = rows(pdraws);
|
||||
|
|
|
@ -17,7 +17,7 @@ function [nvar,vartan,CorrFileNumber] = dsge_simulated_theoretical_correlation(S
|
|||
% vartan [char] array of characters (with nvar rows).
|
||||
% CorrFileNumber [integer] scalar, number of prior or posterior data files (for correlation).
|
||||
|
||||
% Copyright (C) 2007-2017 Dynare Team
|
||||
% Copyright (C) 2007-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -38,17 +38,16 @@ nodecomposition = 1;
|
|||
|
||||
% Get informations about the _posterior_draws files.
|
||||
if strcmpi(type,'posterior')
|
||||
DrawsFiles = dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]);
|
||||
NumberOfDrawsFiles = length(dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]));
|
||||
posterior = 1;
|
||||
elseif strcmpi(type,'prior')
|
||||
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
|
||||
NumberOfDrawsFiles = length(dir([M_.dname '/prior/draws/' type '_draws*' ]));
|
||||
CheckPath('prior/moments',M_.dname);
|
||||
posterior = 0;
|
||||
else
|
||||
disp('dsge_simulated_theoretical_correlation:: Unknown type!');
|
||||
error()
|
||||
end
|
||||
NumberOfDrawsFiles = length(DrawsFiles);
|
||||
|
||||
%delete old stale files before creating new ones
|
||||
if posterior
|
||||
|
@ -95,9 +94,9 @@ CorrFileNumber = 1;
|
|||
linea = 0;
|
||||
for file = 1:NumberOfDrawsFiles
|
||||
if posterior
|
||||
load([M_.dname '/metropolis/' DrawsFiles(file).name ]);
|
||||
load([M_.dname '/metropolis/' M_.fname '_' type '_draws' num2str(file) ]);
|
||||
else
|
||||
load([M_.dname '/prior/draws/' DrawsFiles(file).name]);
|
||||
load([M_.dname '/prior/draws/' type '_draws' num2str(file) ]);
|
||||
end
|
||||
NumberOfDraws = rows(pdraws);
|
||||
isdrsaved = columns(pdraws)-1;
|
||||
|
|
|
@ -16,7 +16,7 @@ function [nvar,vartan,CovarFileNumber] = dsge_simulated_theoretical_covariance(S
|
|||
% vartan [char] array of characters (with nvar rows).
|
||||
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
|
||||
|
||||
% Copyright (C) 2007-2017 Dynare Team
|
||||
% Copyright (C) 2007-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -37,17 +37,16 @@ nodecomposition = 1;
|
|||
|
||||
% Get informations about the _posterior_draws files.
|
||||
if strcmpi(type,'posterior')
|
||||
DrawsFiles = dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]);
|
||||
NumberOfDrawsFiles = length(dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]));
|
||||
posterior = 1;
|
||||
elseif strcmpi(type,'prior')
|
||||
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
|
||||
NumberOfDrawsFiles = length(dir([M_.dname '/prior/draws/' type '_draws*' ]));
|
||||
CheckPath('prior/moments',M_.dname);
|
||||
posterior = 0;
|
||||
else
|
||||
disp('dsge_simulated_theoretical_covariance:: Unknown type!')
|
||||
error();
|
||||
end
|
||||
NumberOfDrawsFiles = length(DrawsFiles);
|
||||
|
||||
%delete old stale files before creating new ones
|
||||
if posterior
|
||||
|
@ -94,9 +93,9 @@ CovarFileNumber = 1;
|
|||
linea = 0;
|
||||
for file = 1:NumberOfDrawsFiles
|
||||
if posterior
|
||||
load([M_.dname '/metropolis/' DrawsFiles(file).name ],'pdraws');
|
||||
load([M_.dname '/metropolis/' M_.fname '_' type '_draws' num2str(file) ]);
|
||||
else
|
||||
load([M_.dname '/prior/draws/' DrawsFiles(file).name ],'pdraws');
|
||||
load([M_.dname '/prior/draws/' type '_draws' num2str(file) ]);
|
||||
end
|
||||
NumberOfDraws = rows(pdraws);
|
||||
isdrsaved = columns(pdraws)-1;
|
||||
|
|
|
@ -18,7 +18,7 @@ function [nvar,vartan,NumberOfDecompFiles] = ...
|
|||
% vartan [char] array of characters (with nvar rows).
|
||||
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
|
||||
|
||||
% Copyright (C) 2007-2017 Dynare Team
|
||||
% Copyright (C) 2007-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -39,10 +39,10 @@ nodecomposition = 0;
|
|||
|
||||
% Get informations about the _posterior_draws files.
|
||||
if strcmpi(type,'posterior')
|
||||
DrawsFiles = dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]);
|
||||
NumberOfDrawsFiles = length(dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]));
|
||||
posterior = 1;
|
||||
elseif strcmpi(type,'prior')
|
||||
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
|
||||
NumberOfDrawsFiles = length(dir([M_.dname '/prior/draws/' type '_draws*' ]));
|
||||
CheckPath('prior/moments',M_.dname);
|
||||
posterior = 0;
|
||||
else
|
||||
|
@ -81,7 +81,6 @@ options_.ar = 0;
|
|||
|
||||
nexo = M_.exo_nbr;
|
||||
|
||||
NumberOfDrawsFiles = rows(DrawsFiles);
|
||||
NumberOfSavedElementsPerSimulation = nvar*(nexo+1);
|
||||
MaXNumberOfDecompLines = ceil(options_.MaxNumberOfBytes/NumberOfSavedElementsPerSimulation/8);
|
||||
|
||||
|
@ -131,9 +130,9 @@ linea_ME = 0;
|
|||
only_non_stationary_vars=0;
|
||||
for file = 1:NumberOfDrawsFiles
|
||||
if posterior
|
||||
load([M_.dname '/metropolis/' DrawsFiles(file).name ]);
|
||||
load([M_.dname '/metropolis/' M_.fname '_' type '_draws' num2str(file) ]);
|
||||
else
|
||||
load([M_.dname '/prior/draws/' DrawsFiles(file).name ]);
|
||||
load([M_.dname '/prior/draws/' type '_draws' num2str(file) ]);
|
||||
end
|
||||
isdrsaved = columns(pdraws)-1;
|
||||
NumberOfDraws = rows(pdraws);
|
||||
|
|
|
@ -21,7 +21,7 @@ function [dr, info] = dyn_first_order_solver(jacobia, DynareModel, dr, DynareOpt
|
|||
% info=5 -> Blanchard and Kahn conditions are not satisfied: indeterminacy due to rank failure,
|
||||
% info=7 -> One of the eigenvalues is close to 0/0 (infinity of complex solutions)
|
||||
|
||||
% Copyright (C) 2001-2018 Dynare Team
|
||||
% Copyright (C) 2001-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -187,8 +187,7 @@ else
|
|||
E(row_indx_de_1,index_e1) = -aa(row_indx,index_e);
|
||||
E(row_indx_de_2,index_e2) = eye(nboth);
|
||||
|
||||
[err, ss, tt, w, sdim, dr.eigval, info1] = mjdgges(E, D, DynareOptions.qz_criterium, DynareOptions.qz_zero_threshold);
|
||||
mexErrCheck('mjdgges', err);
|
||||
[ss, tt, w, sdim, dr.eigval, info1] = mjdgges(E, D, DynareOptions.qz_criterium, DynareOptions.qz_zero_threshold);
|
||||
|
||||
if info1
|
||||
if info1 == -30
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
function dyn_latex_table(M_, options_, title, LaTeXtitle, headers, labels, values, label_width, val_width, val_precis, optional_header)
|
||||
%function dyn_latex_table(M_, options_, title, LaTeXtitle, headers, labels, values, label_width, val_width, val_precis, optional_header)
|
||||
|
||||
% Copyright (C) 2015-2019 Dynare Team
|
||||
% Copyright (C) 2015-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -42,7 +42,7 @@ if all(~isfinite(values))
|
|||
else
|
||||
values_length = max(ceil(max(max(log10(abs(values(isfinite(values))))))),1)+val_precis+1;
|
||||
end
|
||||
if any(values) < 0 %add one character for minus sign
|
||||
if any(values < 0) %add one character for minus sign
|
||||
values_length = values_length+1;
|
||||
end
|
||||
headers_length = cellofchararraymaxlength(headers(2:end));
|
||||
|
|
|
@ -18,7 +18,7 @@ function [steady_state,params,check] = dyn_ramsey_static(ys_init,M,options_,oo)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2003-2018 Dynare Team
|
||||
% Copyright (C) 2003-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -121,7 +121,12 @@ if options_.steadystate_flag
|
|||
oo.exo_det_steady_state], ...
|
||||
M,options_,~options_.steadystate.nocheck);
|
||||
if any(imag(x(1:M.orig_endo_nbr))) %return with penalty
|
||||
resids=1+sum(abs(imag(x(1:M.orig_endo_nbr)))); %return with penalty
|
||||
resids=ones(inst_nbr,1)+sum(abs(imag(x(1:M.orig_endo_nbr)))); %return with penalty
|
||||
steady_state=NaN(endo_nbr,1);
|
||||
return
|
||||
end
|
||||
if check %return
|
||||
resids=ones(inst_nbr,1)+sum(abs(x(1:M.orig_endo_nbr))); %return with penalty
|
||||
steady_state=NaN(endo_nbr,1);
|
||||
return
|
||||
end
|
||||
|
@ -156,7 +161,7 @@ Uyy = reshape(Uyy,endo_nbr,endo_nbr);
|
|||
% set multipliers and auxiliary variables that
|
||||
% depends on multipliers to 0 to compute residuals
|
||||
if (options_.bytecode)
|
||||
[chck, res, junk] = bytecode('static',xx,[oo.exo_steady_state oo.exo_det_steady_state], ...
|
||||
[res, junk] = bytecode('static',xx,[oo.exo_steady_state oo.exo_det_steady_state], ...
|
||||
params, 'evaluate');
|
||||
fJ = junk.g1;
|
||||
else
|
||||
|
@ -194,7 +199,7 @@ end
|
|||
function result = check_static_model(ys,M,options_,oo)
|
||||
result = false;
|
||||
if (options_.bytecode)
|
||||
[chck, res, ~] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
|
||||
[res, ~] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
|
||||
M.params, 'evaluate');
|
||||
else
|
||||
res = feval([M.fname '.static'],ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
|
||||
|
|
|
@ -341,8 +341,7 @@ if nargout > 1
|
|||
nu2 = exo_nbr*(exo_nbr+1)/2;
|
||||
nu3 = exo_nbr*(exo_nbr+1)*(exo_nbr+2)/3;
|
||||
M_np.NZZDerivatives = [nnz(d1_np); nnz(d2_np); nnz(d3_np)];
|
||||
[err, dynpp_derivs] = k_order_perturbation(dr_np,M_np,options,d1_np,d2_np,d3_np);
|
||||
mexErrCheck('k_order_perturbation', err);
|
||||
dynpp_derivs = k_order_perturbation(dr_np,M_np,options,d1_np,d2_np,d3_np);
|
||||
g_0 = dynpp_derivs.g_0;
|
||||
g_1 = dynpp_derivs.g_1;
|
||||
g_2 = dynpp_derivs.g_2;
|
||||
|
|
|
@ -36,7 +36,7 @@ function dr = dyn_second_order_solver(jacobia,hessian_mat,dr,M,threads_BC)
|
|||
%! @end deftypefn
|
||||
%@eod:
|
||||
|
||||
% Copyright (C) 2001-2019 Dynare Team
|
||||
% Copyright (C) 2001-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -85,29 +85,23 @@ zu = [zeros(length(ic),M.exo_nbr);
|
|||
dr.ghx(klead~=0,:)*dr.ghu(ic,:);
|
||||
eye(M.exo_nbr);
|
||||
zeros(M.exo_det_nbr,M.exo_nbr)];
|
||||
[rhs, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kk2(kk1,kk1)),zx,threads_BC); %hessian_mat: reordering to DR order
|
||||
mexErrCheck('sparse_hessian_times_B_kronecker_C', err);
|
||||
rhs = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kk2(kk1,kk1)),zx,threads_BC); %hessian_mat: reordering to DR order
|
||||
rhs = -rhs;
|
||||
[err, dr.ghxx] = gensylv(2,A,B,C,rhs);
|
||||
mexErrCheck('gensylv', err);
|
||||
dr.ghxx = gensylv(2,A,B,C,rhs);
|
||||
|
||||
|
||||
%% ghxu
|
||||
%rhs
|
||||
[rhs, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kk2(kk1,kk1)),zx,zu,threads_BC); %hessian_mat: reordering to DR order
|
||||
mexErrCheck('sparse_hessian_times_B_kronecker_C', err);
|
||||
[abcOut,err] = A_times_B_kronecker_C(dr.ghxx, dr.ghx(ic,:), dr.ghu(ic,:));
|
||||
mexErrCheck('A_times_B_kronecker_C', err);
|
||||
rhs = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kk2(kk1,kk1)),zx,zu,threads_BC); %hessian_mat: reordering to DR order
|
||||
abcOut = A_times_B_kronecker_C(dr.ghxx, dr.ghx(ic,:), dr.ghu(ic,:));
|
||||
rhs = -rhs-B*abcOut;
|
||||
%lhs
|
||||
dr.ghxu = A\rhs;
|
||||
|
||||
%% ghuu
|
||||
%rhs
|
||||
[rhs, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kk2(kk1,kk1)),zu,threads_BC); %hessian_mat: reordering to DR order
|
||||
mexErrCheck('sparse_hessian_times_B_kronecker_C', err);
|
||||
[B1, err] = A_times_B_kronecker_C(B*dr.ghxx,dr.ghu(ic,:));
|
||||
mexErrCheck('A_times_B_kronecker_C', err);
|
||||
rhs = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kk2(kk1,kk1)),zu,threads_BC); %hessian_mat: reordering to DR order
|
||||
B1 = A_times_B_kronecker_C(B*dr.ghxx,dr.ghu(ic,:));
|
||||
rhs = -rhs-B1;
|
||||
%lhs
|
||||
dr.ghuu = A\rhs;
|
||||
|
@ -120,8 +114,7 @@ LHS = zeros(M.endo_nbr,M.endo_nbr);
|
|||
LHS(:,kcurr~=0) = jacobia(:,nonzeros(kcurr));
|
||||
RHS = zeros(M.endo_nbr,M.exo_nbr^2);
|
||||
E = eye(M.endo_nbr);
|
||||
[B1, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kk2(nonzeros(klead),nonzeros(klead))), dr.ghu(klead~=0,:),threads_BC); %hessian_mat:focus only on forward variables and reorder to DR order
|
||||
mexErrCheck('sparse_hessian_times_B_kronecker_C', err);
|
||||
B1 = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kk2(nonzeros(klead),nonzeros(klead))), dr.ghu(klead~=0,:),threads_BC); %hessian_mat:focus only on forward variables and reorder to DR order
|
||||
RHS = RHS + jacobia(:,nonzeros(klead))*dr.ghuu(klead~=0,:)+B1;
|
||||
% LHS
|
||||
LHS = LHS + jacobia(:,nonzeros(klead))*(E(klead~=0,:)+[O1(klead~=0,:) dr.ghx(klead~=0,:) O2(klead~=0,:)]);
|
||||
|
|
108
matlab/dynare.m
108
matlab/dynare.m
|
@ -16,7 +16,7 @@ function dynare(fname, varargin)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2001-2019 Dynare Team
|
||||
% Copyright (C) 2001-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -45,28 +45,26 @@ if ~nargin || strcmpi(fname,'help')
|
|||
return
|
||||
end
|
||||
|
||||
% Set default local options
|
||||
change_path_flag = true;
|
||||
% The following needs to come early, to avoid spurious warnings (especially under Octave)
|
||||
warning_config;
|
||||
|
||||
% Filter out some options.
|
||||
preprocessoroutput = true;
|
||||
% Handle nopathchange option
|
||||
% Note that it is only handled if it appears on the command-line, and not at
|
||||
% the top of the .mod file (since the treatment needs to take place very early,
|
||||
% even before we make the various checks on the filename)
|
||||
change_path_flag = true;
|
||||
if nargin>1
|
||||
id = ismember(varargin, 'nopathchange');
|
||||
if any(id)
|
||||
change_path_flag = false;
|
||||
varargin(id) = [];
|
||||
end
|
||||
preprocessoroutput = ~ismember('nopreprocessoroutput', varargin);
|
||||
end
|
||||
|
||||
% Check matlab path
|
||||
check_matlab_path(change_path_flag);
|
||||
|
||||
% Detect if MEX files are present; if not, use alternative M-files
|
||||
dynareroot = dynare_config();
|
||||
|
||||
warning_config()
|
||||
|
||||
if isoctave
|
||||
% The supported_octave_version.m file is not in git nor in the source
|
||||
% package, it is manually added in binary packages distributed on dynare.org
|
||||
|
@ -78,14 +76,14 @@ if isoctave
|
|||
'of precompiled mex files and some\nfeatures, like solution ' ...
|
||||
'of models approximated at third order, will not be available.'], supported_octave_version())
|
||||
skipline()
|
||||
elseif octave_ver_less_than('4.2') % Should match the test in mex/build/octave/configure.ac
|
||||
% and in m4/ax_mexopts.m4
|
||||
elseif octave_ver_less_than('4.4') % Should match the test in mex/build/octave/configure.ac
|
||||
skipline()
|
||||
warning(['This version of Dynare has only been tested on Octave 4.2 and above. Dynare may fail to run or give unexpected result. Consider upgrading your version of Octave.'])
|
||||
warning(['This version of Dynare has only been tested on Octave 4.4 and above. Dynare may fail to run or give unexpected result. Consider upgrading your version of Octave.'])
|
||||
skipline()
|
||||
end
|
||||
else
|
||||
if matlab_ver_less_than('7.9') % Should match the test in mex/build/matlab/configure.ac
|
||||
% and in m4/ax_mexopts.m4
|
||||
skipline()
|
||||
warning('This version of Dynare has only been tested on MATLAB 7.9 (R2009b) and above. Since your MATLAB version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your MATLAB installation, or switch to Octave.');
|
||||
skipline()
|
||||
|
@ -186,6 +184,14 @@ if exist(fname(1:end-4),'dir') && exist([fname(1:end-4) filesep 'hooks'],'dir')
|
|||
run([fname(1:end-4) filesep 'hooks/priorprocessing'])
|
||||
end
|
||||
|
||||
% Parse some options, either for the command-line or from the top of the .mod file
|
||||
file_opts = parse_options_line(fname);
|
||||
preprocessoroutput = ~ismember('nopreprocessoroutput', varargin) && ...
|
||||
~ismember('nopreprocessoroutput', file_opts);
|
||||
nolog = ismember('nolog', varargin) || ismember('nolog', file_opts);
|
||||
onlymacro = ismember('onlymacro', varargin) || ismember('onlymacro', file_opts);
|
||||
onlyjson = ismember('onlyjson', varargin) || ismember('onlyjson', file_opts);
|
||||
|
||||
if ispc
|
||||
arch = getenv('PROCESSOR_ARCHITECTURE');
|
||||
else
|
||||
|
@ -204,27 +210,34 @@ else
|
|||
end
|
||||
end
|
||||
|
||||
command = ['"' dynareroot 'preprocessor' arch_ext filesep 'dynare_m" ' fname] ;
|
||||
command = [ command ' mexext=' mexext ' "matlabroot=' matlabroot '"'];
|
||||
for i=1:length(varargin)
|
||||
idx = regexp(varargin{i}, '(in|ex)clude_eqs');
|
||||
if ~isempty(idx) && idx(1) == 1
|
||||
command = [command ' "' varargin{i} '"'];
|
||||
else
|
||||
command = [command ' ' varargin{i}];
|
||||
end
|
||||
end
|
||||
|
||||
if preprocessoroutput
|
||||
fprintf(['Starting Dynare (version ' dynare_version() ').\n']);
|
||||
fprintf('Calling Dynare with arguments: ');
|
||||
if isempty(varargin)
|
||||
disp('none')
|
||||
else
|
||||
disp(strjoin(varargin));
|
||||
disp(strjoin(varargin, ' '));
|
||||
end
|
||||
end
|
||||
|
||||
command = ['"' dynareroot 'preprocessor' arch_ext filesep 'dynare_m" ' fname] ;
|
||||
command = [ command ' mexext=' mexext ' "matlabroot=' matlabroot '"'];
|
||||
% Properly quote arguments before passing them to the shell
|
||||
if ~isempty(varargin)
|
||||
varargincopy = varargin;
|
||||
% Escape backslashes and double-quotes
|
||||
varargincopy = strrep(varargincopy, '\', '\\');
|
||||
varargincopy = strrep(varargincopy, '"', '\"');
|
||||
if ~ispc
|
||||
% On GNU/Linux and macOS, also escape dollars and backquotes
|
||||
varargincopy = strrep(varargincopy, '$', '\$');
|
||||
varargincopy = strrep(varargincopy, '`', '\`');
|
||||
end
|
||||
% Finally, enclose arguments within double quotes
|
||||
dynare_varargin = ['"' strjoin(varargincopy, '" "') '"'];
|
||||
command = [command ' ' dynare_varargin];
|
||||
end
|
||||
|
||||
% Under Windows, make sure the MEX file is unloaded (in the use_dll case),
|
||||
% otherwise the preprocessor can't recompile it
|
||||
if isoctave
|
||||
|
@ -237,14 +250,14 @@ end
|
|||
if status ~= 0 || preprocessoroutput
|
||||
disp(result)
|
||||
end
|
||||
if ismember('onlymacro', varargin)
|
||||
if onlymacro
|
||||
if preprocessoroutput
|
||||
disp('Preprocessor stopped after macroprocessing step because of ''onlymacro'' option.');
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if ismember('onlyjson', varargin)
|
||||
if onlyjson
|
||||
if preprocessoroutput
|
||||
disp('Preprocessor stopped after preprocessing step because of ''onlyjson'' option.');
|
||||
end
|
||||
|
@ -257,11 +270,7 @@ if exist(fname(1:end-4),'dir') && exist([fname(1:end-4) filesep 'hooks'],'dir')
|
|||
end
|
||||
|
||||
% Save preprocessor result in logfile (if `no_log' option not present)
|
||||
fid = fopen(fname, 'r');
|
||||
firstline = fgetl(fid);
|
||||
fclose(fid);
|
||||
if ~ismember('nolog', varargin) ...
|
||||
&& isempty(regexp(firstline, '//\s*--\+\s*options:(|.*\s|.*,)nolog(|\s.*|,.*)\+--'))
|
||||
if ~nolog
|
||||
logname = [fname(1:end-4) '.log'];
|
||||
fid = fopen(logname, 'w');
|
||||
fprintf(fid, '%s', result);
|
||||
|
@ -282,3 +291,38 @@ end
|
|||
clear(['+' fname '/driver'])
|
||||
|
||||
evalin('base',[fname '.driver']) ;
|
||||
|
||||
end
|
||||
|
||||
% Looks for an options list in the first non-empty line of the .mod file
|
||||
% Should be kept in sync with the function of the same name in preprocessor/src/DynareMain.cc
|
||||
%
|
||||
% Note that separating options with commas is accepted, but is deprecated (and undocumented)
|
||||
%
|
||||
% Also, the parser does not handle correctly some corner cases: for example, it
|
||||
% will fail on something like -Dfoo="a b,c" (will split at whitespace and comma)
|
||||
function opts = parse_options_line(fname)
|
||||
opts = {};
|
||||
fid = fopen(fname, 'r');
|
||||
while true
|
||||
firstline = fgetl(fid);
|
||||
if firstline == -1
|
||||
fclose(fid);
|
||||
return
|
||||
end
|
||||
if ~isempty(firstline)
|
||||
break
|
||||
end
|
||||
end
|
||||
fclose(fid);
|
||||
t = regexp(firstline, '^\s*//\s*--\+\s*options:([^\+]*)\+--', 'tokens');
|
||||
if isempty(t)
|
||||
return
|
||||
end
|
||||
|
||||
opts = regexp(t{1}{1}, '[^,\s]+', 'match');
|
||||
|
||||
if ismember(opts, 'nopathchange')
|
||||
warning('The ''nopathchange'' option is not taken into account when it appears at the top of ''.mod'' file. You should rather pass it on the command-line.')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ function dynareroot = dynare_config(path_to_dynare)
|
|||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright (C) 2001-2019 Dynare Team
|
||||
% Copyright (C) 2001-2020 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -63,6 +63,8 @@ p = {'/distributions/' ; ...
|
|||
'/optimization/' ; ...
|
||||
'/ols/'; ...
|
||||
'/pac-tools/'; ...
|
||||
'/discretionary_policy/' ; ...
|
||||
'/accessors/' ; ...
|
||||
'/modules/dseries/src/' ; ...
|
||||
'/utilities/doc/' ; ...
|
||||
'/utilities/tests/src/' ; ...
|
||||
|
@ -87,11 +89,6 @@ if isoctave && octave_ver_less_than('5')
|
|||
p{end+1} = '/missing/ordeig';
|
||||
end
|
||||
|
||||
% corrcoef with two outputs is missing in Octave < 4.4 (ticket #796)
|
||||
if isoctave && octave_ver_less_than('4.4') && ~user_has_octave_forge_package('nan')
|
||||
p{end+1} = '/missing/corrcoef';
|
||||
end
|
||||
|
||||
%% intersect(…, 'stable') doesn't exist in Octave and in MATLAB < R2013a
|
||||
if isoctave || matlab_ver_less_than('8.1')
|
||||
p{end+1} = '/missing/intersect_stable';
|
||||
|
@ -99,10 +96,10 @@ end
|
|||
|
||||
% Replacements for functions of the MATLAB statistics toolbox
|
||||
if isoctave
|
||||
% These functions were part of Octave < 4.4, they are now in the statistics Forge package
|
||||
if ~octave_ver_less_than('4.4') && ~user_has_octave_forge_package('statistics')
|
||||
% Under Octave, these functions are in the statistics Forge package.
|
||||
% Our replacement functions don't work under Octave (because of gamrnd, see
|
||||
% #1638), hence the statistics toolbox is now a hard requirement
|
||||
if ~user_has_octave_forge_package('statistics')
|
||||
error('You must install the "statistics" package from Octave Forge, either with your distribution package manager or with "pkg install -forge statistics"')
|
||||
end
|
||||
else
|
||||
|
@ -139,7 +136,7 @@ if ~isoctave && matlab_ver_less_than('7.11')
|
|||
end
|
||||
|
||||
%% isdiag is missing in MATLAB < R2014a
|
||||
if ~isoctave && matlab_ver_less_than('8.4')
|
||||
if ~isoctave && matlab_ver_less_than('8.3')
|
||||
p{end+1} = '/missing/isdiag';
|
||||
end
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue