Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • giovanma/dynare
  • giorgiomas/dynare
  • Vermandel/dynare
  • Dynare/dynare
  • normann/dynare
  • MichelJuillard/dynare
  • wmutschl/dynare
  • FerhatMihoubi/dynare
  • sebastien/dynare
  • lnsongxf/dynare
  • rattoma/dynare
  • CIMERS/dynare
  • FredericKarame/dynare
  • SumuduK/dynare
  • MinjeJeon/dynare
  • camilomrch/dynare
  • DoraK/dynare
  • avtishin/dynare
  • selma/dynare
  • claudio_olguin/dynare
  • jeffjiang07/dynare
  • EthanSystem/dynare
  • stepan-a/dynare
  • wjgatt/dynare
  • JohannesPfeifer/dynare
  • gboehl/dynare
26 results
Show changes
Commits on Source (162)
Showing
with 1216 additions and 484 deletions
......@@ -8,6 +8,12 @@
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
# Effective configuration can be obtained with:
# clang-format --dump-config
# The RemoveParentheses and RemoveSemicolon option are not permanently set,
# because the clang-format manual (as of version 19) states that these
# options can lead to incorrect formatting and thus their result should be
# carefully reviewed.
Language: Cpp
Standard: c++20
ColumnLimit: 100
......@@ -23,7 +29,8 @@ InsertNewlineAtEOF: true
PackConstructorInitializers: NextLine
PPIndentWidth: 1
PointerAlignment: Left
RemoveSemicolon: true
# RemoveParentheses: ReturnStatement
# RemoveSemicolon: true
SpaceAfterTemplateKeyword: false
SpaceBeforeParens: ControlStatements
SpaceBeforeCpp11BracedList: true
......@@ -107,7 +107,7 @@ pkg_macOS_x86_64:
script:
# Enforce the arm64 meson for rewrite, as a workaround to https://github.com/mesonbuild/meson/issues/12282
- env PATH="/opt/homebrew/bin:$PATH" meson rewrite kwargs set project / version "$VERSION"
- ln -s ~/tarballs macOS/deps/x86_64
- ln -s ~/tarballs macOS/deps/
- make -C macOS build-x86_64
cache:
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
......@@ -127,7 +127,7 @@ pkg_macOS_arm64:
script:
# Enforce the arm64 meson for rewrite, as a workaround to https://github.com/mesonbuild/meson/issues/12282
- env PATH="/opt/homebrew/bin:$PATH" meson rewrite kwargs set project / version "$VERSION"
- ln -s ~/tarballs macOS/deps/arm64
- ln -s ~/tarballs macOS/deps/
- make -C macOS build-arm64
cache:
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
......@@ -188,7 +188,7 @@ test_clang_tidy:
stage: test
script:
# Hack needed for meson < 1.6.0 which only looks for unversioned clang-tidy
- mkdir -p ~/.local/bin && ln -s /usr/bin/clang-tidy-16 ~/.local/bin/clang-tidy
- mkdir -p ~/.local/bin && ln -s /usr/bin/clang-tidy-19 ~/.local/bin/clang-tidy
- export PATH="$HOME/.local/bin:$PATH"
- meson setup -Dbuild_for=octave build-clang-tidy
- ninja -C build-clang-tidy clang-tidy
......
Announcement for Dynare 6.3 (on 2025-02-19)
===========================================
We are pleased to announce the release of Dynare 6.3.
This maintenance release fixes various bugs.
The Windows, macOS, MATLAB online and source packages are available for
download at [the Dynare website](https://www.dynare.org/download/).
This release is compatible with MATLAB versions ranging from 9.5 (R2018b) to
24.2 (R2024b), and with GNU Octave versions ranging from 7.1.0 to 9.4.0 (NB:
the Windows package requires version 9.4.0 specifically).
Here is a list of the problems identified in version 6.2 and that have been
fixed in version 6.3:
* OccBin with option `smoother_inversion_filter` would crash the MCMC
estimation if the `filtered_variables` or `filter_step_ahead` options were
used
* OccBin with option `smoother_inversion_filter` would use the PKF if
`mh_replic>0`
* OccBin with option `smoothed_state_uncertainty` would crash Dynare if the
MCMC smoother was run after the classical one
* OccBin's smoother would crash when encountering an internal error due to the
output of the linear smoother not having been computed
* Calling `model_info` with `differentiate_forward_vars` would crash
* The `identification` command would compute the asymptotic Hessian via
simulation instead of via moments as intended
* The `identification` command would crash during prior sampling if the initial
draw did not solve the model
* The `gsa_sample_file` was broken
* Optimization algorithm `mode_compute=5` (`newrat`) would crash with
`analytic_derivation`
* The `discretionary_policy` command would crash if the model was purely
forward-looking
* The `dsample` command would crash
* The `conditional_forecast_paths` block did not accept vector inputs
* For MCMC chains with fewer than 6000 draws, the default number of `sub_draws`
used to compute posterior moments was incorrect
* Bi-annual dates (e.g. `2024S1` or `2024H1`) were not accepted within Dynare
statements
* Plotting `dseries` did not correctly show dates on the x-axis
Announcement for Dynare 6.2 (on 2024-09-25)
===========================================
......
......@@ -104,13 +104,13 @@ If you want a certain version (e.g. 5.x) , then add `--single-branch --branch 5.
If you want to compile for MATLAB, please run the following (after adapting the path to MATLAB):
```sh
meson setup -Dmatlab_path=/usr/local/MATLAB/R2023b -Dbuildtype=debugoptimized build-matlab
meson setup -Dmatlab_path=/usr/local/MATLAB/R2023b --buildtype=debugoptimized build-matlab
```
The build directory will thus be `build-matlab`.
Or for Octave:
```sh
meson setup -Dbuild_for=octave -Dbuildtype=debugoptimized build-octave
meson setup -Dbuild_for=octave --buildtype=debugoptimized build-octave
```
The build directory will thus be `build-octave`.
......@@ -273,7 +273,7 @@ Now use the following commands if using MATLAB (adapt them for Octave, see above
cd /home/$USER/dynare
git clone --recurse-submodules https://git.dynare.org/dynare/dynare.git unstable
cd unstable
meson setup -Dmatlab_path=/usr/local/MATLAB/R2023b -Dfortran_args="[ '-B', '/home/$USER/dynare/slicot']" -Dbuildtype=debugoptimized build-matlab
meson setup -Dmatlab_path=/usr/local/MATLAB/R2023b -Dfortran_args="[ '-B', '/home/$USER/dynare/slicot']" --buildtype=debugoptimized build-matlab
meson compile -C build-matlab
```
......@@ -318,7 +318,7 @@ cd dynare
```
- Configure Dynare from the source directory (adjust `matlab_path` if you use a different version than R2024a):
```sh
meson setup -Dmatlab_path=/usr/local/MATLAB/R2024a -Dbuildtype=debugoptimized build-matlab
meson setup -Dmatlab_path=/usr/local/MATLAB/R2024a --buildtype=debugoptimized build-matlab
```
- Compile:
```sh
......@@ -362,7 +362,7 @@ cd dynare
```
- Configure Dynare from the source directory:
```sh
meson setup -Dmatlab_path=<…> -Dbuildtype=debugoptimized -Dprefer_static=true -Dfortran_args="['-B','/usr/local/lib']" build-matlab
meson setup -Dmatlab_path=<…> --buildtype=debugoptimized --prefer-static -Dfortran_args="['-B','C:/msys64/usr/local/lib']" build-matlab
```
where the path of MATLAB is specified. Note that you should use
the MSYS2 notation and not put spaces in the MATLAB path, so you probably want
......@@ -520,7 +520,7 @@ If you want a certain version (e.g. 5.x) , then add `--single-branch --branch 5.
```sh
export BUILDDIR=build-matlab
export MATLABPATH=/Applications/MATLAB_R2023b.app
arch -$ARCH meson setup --native-file macOS/homebrew-native-$ARCH.ini -Dmatlab_path=$MATLABPATH -Dbuildtype=debugoptimized -Dfortran_args="['-B','$DYNAREDIR/slicot/lib']" $BUILDDIR
arch -$ARCH meson setup --native-file macOS/homebrew-native-$ARCH.ini -Dmatlab_path=$MATLABPATH --buildtype=debugoptimized -Dfortran_args="['-B','$DYNAREDIR/slicot/lib']" $BUILDDIR
```
where you need to adapt the path to MATLAB.
Similarly, if you want to compile for Octave, replace the `-Dmatlab_path` option by `-Dbuild_for=octave`, and change the build directory to `build-octave`.
......
......@@ -65,7 +65,7 @@ Bibliography
* 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.
* Kuntsevich, Alexei V. and Franz Kappel (1997): “SolvOpt - The solver for local nonlinear optimization problems (version 1.1, Matlab, C, FORTRAN)”, University of Graz, Graz, Austria.
* Laffargue, Jean-Pierre (1990): “Résolution d’un modèle macroéconomique avec anticipations rationnelles”, *Annales d’Économie et Statistique*, 17, 97–119.
* 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.
* 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, Chapter 10, 197-223.
* 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.
* Mutschler, Willi (2018): “Higher-order statistics for DSGE models”, *Econometrics and Statistics*, 6(C), 44-56.
......
# -*- coding: utf-8 -*-
# Copyright © 2018-2024 Dynare Team
# Copyright © 2018-2025 Dynare Team
#
# This file is part of Dynare.
#
......@@ -34,7 +34,7 @@ html_static_path = ['_static']
master_doc = 'index'
project = u'Dynare'
copyright = u'1996–2024 Dynare Team'
copyright = u'1996–2025 Dynare Team'
author = u'Dynare Team'
add_function_parentheses = False
......
......@@ -26,7 +26,7 @@ The following people used to be members of the team:
* Ferhat Mihoubi
* George Perendia
Copyright © 1996-2024, Dynare Team.
Copyright © 1996-2025, 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.
......
......@@ -15,7 +15,7 @@ compilation steps are necessary in that case.
In order to run Dynare, you need one of the following:
* MATLAB, any version ranging from 9.5 (R2018b) to 24.2 (R2024b);
* GNU Octave, any version ranging from 7.1.0 to 9.2.0, with the ``statistics`` package
* GNU Octave, any version ranging from 7.1.0 to 9.4.0, with the ``statistics`` package
from `Octave-Forge`_. Note however that the Dynare installer for Windows
requires a more specific version of Octave, as indicated on the download
page.
......@@ -23,8 +23,17 @@ In order to run Dynare, you need one of the following:
The following optional extensions are also useful to benefit from
extra features, but are in no way required:
* If under MATLAB: the Optimization Toolbox, the Statistics Toolbox,
the Control System Toolbox;
* If under MATLAB: the
* Optimization Toolbox (providing various optimizers
like ``fminsearch``, ``fmincon``, or ``fminunc``, used in e.g. ``mode_compute``,
``opt_algo`` or ``ALGO``),
* Statistics Toolbox (for faster and sometimes more robust implementations of
statistical distributions),
* Global Optimization Toolbox (for ``particleswarm`` and ``simulannealbnd``, used in
e.g. ``mode_compute``, ``opt_algo`` or ``ALGO``)
* Control System Toolbox (for the Lyapunov solver ``dlyapchol`` triggered with ``lyapunov=square_root_solver``)
* Parallel Computing Toolbox (to speed up the ``dime`` sampler)
* If under Octave, the following `Octave-Forge`_ packages: ``optim``, ``io``,
``control``.
......@@ -91,6 +100,18 @@ Debian, Ubuntu and Linux Mint).
On macOS
--------
.. warning::
Installing into ``/Applications/dynare`` might fail if you have older versions of Dynare already installed in ``/Applications/Dynare``.
To fix this, modify the ownership by executing the following command in Terminal.app::
sudo chown -R "$USER":staff /Applications/Dynare
Alternatively, you can modify the installation path in the automated installed using *Customize* and *Location*.
After installation, the folder will contain several sub-directories, among which are ``matlab``, ``mex``, and ``doc``.
Several versions of Dynare can coexist (by default in ``/Applications/Dynare``),
as long as you correctly adjust your path settings (see :ref:`words-warning`).
With MATLAB
^^^^^^^^^^^
......@@ -100,15 +121,6 @@ and follow the instructions.
This installation does not require administrative privileges.
If for some reason admin rights are requested, use *Change Install Location* and select *Install for me only*.
The default installation directory is ``/Applications/Dynare/x.y-arch``.
Installing into ``/Applications/dynare`` might fail if you have older versions of Dynare already installed in ``/Applications/Dynare``.
To fix this, modify the ownership by executing the following command in Terminal.app::
sudo chown -R "$USER":staff /Applications/Dynare
Alternatively, you can modify the installation path in the automated installed using *Customize* and *Location*.
After installation, the folder will contain several sub-directories, among which are ``matlab``, ``mex``, and ``doc``.
Several versions of Dynare can coexist (by default in ``/Applications/Dynare``),
as long as you correctly adjust your path settings (see :ref:`words-warning`).
It is recommended to install the Xcode Command Line Tools (this is an Apple product)
and GCC via Homebrew_ (see :ref:`prerequisites-macos`).
......@@ -133,6 +145,8 @@ once)::
octave:1> pkg install -forge io statistics control struct optim
If you want to use the `x13` functionality of `dseries`, you also need to build the `x13as` binary. [#fx13]_
On FreeBSD
----------
......@@ -325,3 +339,8 @@ Dynare unusable.
.. _Dynare wiki: https://git.dynare.org/Dynare/dynare/wikis
.. _Octave-Forge: https://octave.sourceforge.io/
.. _Homebrew: https://brew.sh
.. rubric:: Footnotes
.. [#fx13] See the instructions at `<https://forum.dynare.org/t/missing-installation-package/27350/4>`__.
\ No newline at end of file
......@@ -54,7 +54,7 @@ are introduced by ``/*`` and terminated by ``*/``.
*/
 
Note that these comment marks should not be used in native MATLAB code regions
where the `%` should be preferred instead to introduce a comment. In a
where the ``%`` should be preferred instead to introduce a comment. In a
``verbatim`` block, see :ref:`verbatim`, this would result in a crash since
``//`` is not a valid MATLAB statement).
 
......@@ -86,10 +86,10 @@ observed:
(see :ref:`macro-exp`);
* VARIABLE_NAME (sometimes VAR_NAME) indicates a variable name
starting with an alphabetical character and can’t contain:
()+-\*/^=!;:@#. or accentuated characters;
``()+-\*/^=!;:@#.`` or accentuated characters;
* PARAMETER_NAME (sometimes PARAM_NAME) indicates a parameter name
starting with an alphabetical character and can’t contain:
()+-\*/^=!;:@#. or accentuated characters;
``()+-\*/^=!;:@#.`` or accentuated characters;
* LATEX_NAME (sometimes TEX_NAME) indicates a valid
LaTeX expression in math mode (not including the
dollar signs);
......@@ -98,7 +98,13 @@ observed:
system; it is necessary to put it between quotes when specifying the
extension or if the filename contains a non-alphanumeric character;
* QUOTED_STRING indicates an arbitrary string enclosed between (single)
quotes.
quotes;
* DATE indicates a time period which can be either a year (e.g. ``2024Y`` or
``2024A``), a half-year (``2024S1`` or ``2024H1``), a quarter (``2024Q2``) or a month
(``2024M3``) (see :ref:`dates in a mod file`). Optionally, the time period can
be followed by a plus sign and a number of periods, in which case the date is
shifted accordingly (e.g. ``2023Q1+6`` is accepted and is equivalent to
``2024Q3``).
 
 
.. _var-decl:
......@@ -2585,7 +2591,7 @@ blocks.
group of three lines::
 
var VARIABLE_NAME;
periods INTEGER[:INTEGER] [[,] INTEGER[:INTEGER]]...;
periods INTEGER[:INTEGER] | DATE[:DATE] [[,] INTEGER[:INTEGER] | DATE[:DATE]]...;
values DOUBLE | (EXPRESSION) [[,] DOUBLE | (EXPRESSION) ]...;
 
It is possible to specify shocks which last several periods and
......@@ -2602,15 +2608,21 @@ blocks.
arbitrary expressions are also allowed, but you have to enclose
them inside parentheses.
 
The feasible range of ``periods`` is from 0 to the number of ``periods``
specified in ``perfect_foresight_setup``.
.. warning:: Note that the first endogenous simulation period is period 1.
Thus, a shock value specified for the initial period 0 may conflict with
(i.e. may overwrite or be overwritten by) values for the
initial period specified with ``initval`` or ``endval`` (depending on
the exact context). Users should always verify the correct setting
of ``oo_.exo_simul`` after ``perfect_foresight_setup``.
The feasible range of ``periods``, when specified as integers, is from 0 to
the number of ``periods`` specified in :comm:`perfect_foresight_setup` or
:comm:`perfect_foresight_with_expectation_errors_setup`. Alternatively, it
is possible to use real dates if the ``first_simulation_period`` and/or
``last_simulation_period`` option has been passed to the aforementioned
commands.
.. warning:: Note that the first endogenous simulation period is period 1
(when specified as an integer). Thus, a shock value specified for the
initial period 0 may conflict with (i.e. may overwrite or be
overwritten by) values for the initial period specified with
``initval`` or ``endval`` (depending on the exact context). Users
should always verify the correct setting of ``oo_.exo_simul`` after
``perfect_foresight_setup`` or
``perfect_foresight_with_expectation_errors_setup``.
 
*Example* (with scalar values)
 
......@@ -2645,6 +2657,21 @@ blocks.
values (xx);
end;
 
*Example* (with dates)
::
shocks;
var e;
periods 2023Q1;
values 0.5;
var u;
periods 2023Q2:2023Q4 2024Q1;
values 0 0.1;
end;
|br| *In stochastic context*
 
For stochastic simulations, the ``shocks`` block specifies the non
......@@ -3010,14 +3037,16 @@ Finding the steady state with Dynare nonlinear solver
``perfect_foresight_solver`` command with purely backward,
forward or static models, or with routines for semi-structural
models, and it must *not* be combined with option ``block`` of
the ``model`` block. Also note that for those models, the block
decomposition is performed as if ``mfs=3`` had been passed to
the ``model`` block, and the decomposition is slightly
different because it is computed in a time-recursive fashion
(*i.e.* in such a way that the simulation is meant to be done
with the outer loop on periods and the inner loop on blocks;
while for models with both leads and lags, the outer loop is on
blocks and the inner loop is on periods).
the :bck:`model` block or :comm:`model_options` command. Also
note that for those models, the block decomposition is
performed as if ``mfs=3`` had been passed to the :bck:`model`
block or :comm:`model_options` command, and the decomposition
is slightly different because it is computed in a
time-recursive fashion (*i.e.* in such a way that the
simulation is meant to be done with the outer loop on periods
and the inner loop on blocks; while for models with both leads
and lags, the outer loop is on blocks and the inner loop is on
periods).
 
``14``
 
......@@ -3533,14 +3562,15 @@ Getting information about the model
 
|br| Prints the equations and the Jacobian matrix of the dynamic
model stored in the bytecode binary format file. Can only be used
in conjunction with the ``bytecode`` option of the ``model``
block.
in conjunction with the ``bytecode`` option of the :bck:`model`
block or :comm:`model_options` command.
 
.. command:: print_bytecode_static_model ;
 
|br| Prints the equations and the Jacobian matrix of the static model
stored in the bytecode binary format file. Can only be used in
conjunction with the ``bytecode`` option of the ``model`` block.
conjunction with the ``bytecode`` option of the :bck:`model`
block or :comm:`model_options` command.
 
 
.. _det-simul:
......@@ -3625,7 +3655,25 @@ speed-up on large models.
 
.. option:: periods = INTEGER
 
Number of periods of the simulation.
Number of periods of the simulation. This option is mandatory, unless
both ``first_simulation_period`` and ``last_simulation_period`` options
are given.
.. option:: first_simulation_period = DATE
Assign a date to the first simulation period, i.e. the first period in
which endogenous variables are solved for. When this option is set, it
becomes possible to declare shocks using dates, and
:comm:`perfect_foresight_solver` returns the result of the simulation as
a time series object in :mvar:`Simulated_time_series`.
.. option:: last_simulation_period = DATE
Assign a date to the last simulation period, i.e. the last period in
which endogenous variables are solved for. When this option is set, it
becomes possible to declare shocks using dates, and
:comm:`perfect_foresight_solver` returns the result of the simulation as
a time series object in :mvar:`Simulated_time_series`.
 
.. option:: datafile = FILENAME
 
......@@ -3780,9 +3828,9 @@ speed-up on large models.
 
See :ref:`solve_algo <solvalg>`. Allows selecting the solver
used with ``stack_solve_algo=7``. Also used for purely backward, forward
and static models (when neither the ``block`` nor the ``bytecode`` option
of the ``model`` block is specified); for those models, the values
``12`` and ``14`` are especially relevant.
and static models (when neither the ``block`` nor the ``bytecode``
option of the :bck:`model` block or :comm:`model_options` command is specified);
for those models, the values ``12`` and ``14`` are especially relevant.
 
.. option:: no_homotopy
 
......@@ -3823,6 +3871,11 @@ speed-up on large models.
the homotopy procedure has been able to find a solution, then the approximate
solution returned is :math:`\frac{y(s^*)-y(0)}{s^*}`.
 
If linearization is triggered, the variable
:mvar:`oo_.deterministic_simulation.homotopy_linearization` is set, and
the simulation corresponding to share :math:`s^*` is stored in
:mvar:`oo_.deterministic_simulation.sim1`.
.. option:: homotopy_marginal_linearization_fallback [= DOUBLE]
 
Whenever the homotopy procedure is not able to find a solution for 100%
......@@ -3842,6 +3895,13 @@ speed-up on large models.
of :math:`\epsilon` is ``0.01`` by default, but can be modified by
passing some other value to the option.
 
If marginal linearization is triggered, the variable
:mvar:`oo_.deterministic_simulation.homotopy_marginal_linearization` is
set. Moreover, the simulation corresponding to share :math:`s^*` is
stored in :mvar:`oo_.deterministic_simulation.sim1`, and the one
corresponding to share :math:`s^*-\epsilon` is stored in
:mvar:`oo_.deterministic_simulation.sim2`.
.. option:: homotopy_max_completion_share = DOUBLE
 
Instructs Dynare, within the homotopy procedure, to not try to compute
......@@ -3851,7 +3911,7 @@ speed-up on large models.
``homotopy_marginal_linearization_fallback`` option. It is typically
used in situations where it is known that homotopy will fail to go
beyond a certain point, so as to save computing time, while at the same
time getting an approximate solution.
time getting an approximate solution. Default: ``1``.
 
.. option:: homotopy_exclude_varexo = (VARIABLE_NAME...)
 
......@@ -3958,7 +4018,7 @@ speed-up on large models.
shooting and relaxation approaches. Note that round off errors
are more important with this mixed strategy (user should check
the reported value of the maximum absolute error). Only
available with option ``stack_solve_algo==0``.
available with ``stack_solve_algo`` option equal to ``0``.
 
 
.. option:: linear_approximation
......@@ -3967,8 +4027,8 @@ speed-up on large models.
model. The model must be stationary and a steady state
needs to be provided. Linearization is conducted about the
last defined steady state, which can derive from ``initval``,
``endval`` or a subsequent ``steady``. Only available with option
``stack_solve_algo==0`` or ``stack_solve_algo==7``.
``endval`` or a subsequent ``steady``. Only available with
``stack_solve_algo`` option equal to ``0`` or ``7``.
 
.. option:: steady_solve_algo = INTEGER
 
......@@ -4003,8 +4063,15 @@ speed-up on large models.
*Output*
 
The simulated endogenous variables are available in global matrix
``oo_.endo_simul``.
:mvar:`oo_.endo_simul`.
If any of the ``first_simulation_period`` or ``last_simulation_period``
option was passed to the preceding :comm:`perfect_foresight_setup` command,
a time series object containing both endogenous and exogenous variables is
stored in the workspace variable :mvar:`Simulated_time_series`.
 
The variable :mvar:`oo_.deterministic_simulation.status` indicates whether
the simulation was successful or not.
 
.. command:: simul ;
simul (OPTIONS...);
......@@ -4021,29 +4088,36 @@ speed-up on large models.
.. matvar:: oo_.endo_simul
 
|br| This variable stores the result of a deterministic simulation
(computed by ``perfect_foresight_solver`` or ``simul``) or of a
stochastic simulation (computed by ``stoch_simul`` with the
periods option or by ``extended_path``). The variables are
arranged row by row, in order of declaration (as in
``M_.endo_names``). Note that this variable also contains initial
and terminal conditions, so it has more columns than the value of the
``periods`` option: the first simulation period is in
column ``1+M_.maximum_lag``, and the total number of columns is
(computed by ``perfect_foresight_solver`` or
``perfect_foresight_with_expectation_errors_solver``) or of a stochastic
simulation (computed by ``stoch_simul`` with the ``periods`` option or by
``extended_path``). The variables are arranged row by row, in order of
declaration (as in ``M_.endo_names``). Note that this variable also
contains initial and terminal conditions, so it has more columns than the
value of the ``periods`` option: the first simulation period is in column
``1+M_.maximum_lag``, and the total number of columns is
``M_.maximum_lag+periods+M_.maximum_lead``.
 
.. matvar:: oo_.exo_simul
 
|br| This variable stores the path of exogenous variables during a
simulation (computed by ``perfect_foresight_solver``, ``simul``,
``stoch_simul`` or ``extended_path``). The variables are arranged
in columns, in order of declaration (as in
``M_.exo_names``). Periods are in rows. Note that this convention
regarding columns and rows is the opposite of the convention for
``oo_.endo_simul``! Also note that this variable also contains initial
and terminal conditions, so it has more rows than the value of the
``periods`` option: the first simulation period is in row
``1+M_.maximum_lag``, and the total number of rows is
``M_.maximum_lag+periods+M_.maximum_lead``.
simulation (computed by ``perfect_foresight_solver``,
``perfect_foresight_with_expectation_errors_solver``, ``stoch_simul`` or
``extended_path``). The variables are arranged in columns, in order of
declaration (as in ``M_.exo_names``). Periods are in rows. Note that this
convention regarding columns and rows is the opposite of the convention for
``oo_.endo_simul``! Also note that this variable also contains initial and
terminal conditions, so it has more rows than the value of the ``periods``
option: the first simulation period is in row ``1+M_.maximum_lag``, and the
total number of rows is ``M_.maximum_lag+periods+M_.maximum_lead``.
.. matvar:: Simulated_time_series
|br| This variable stores, as a :class:`dseries` object, the path of both
endogenous and exogenous variables after a deterministic simulation
(computed by ``perfect_foresight_solver`` or
``perfect_foresight_with_expectation_errors_solver`` using the
``first_simulation_period`` and/or ``last_simulation_period`` option).
 
.. matvar:: oo_.initial_steady_state
 
......@@ -4076,6 +4150,42 @@ speed-up on large models.
variables, so in practice it is either 1 or 0 (the latter value corresponds
to a purely backward or static model).
 
.. matvar:: oo_.deterministic_simulation.status
|br| Set to ``true`` by the :comm:`perfect_foresight_solver` command if the
simulation succeeded, otherwise set to ``false``.
.. matvar:: oo_.deterministic_simulation.homotopy_linearization
|br| Set to ``true`` by the :comm:`perfect_foresight_solver` command if
linearization has been used to compute an approximate solution.
.. matvar:: oo_.deterministic_simulation.homotopy_marginal_linearization
|br| Set to ``true`` by the :comm:`perfect_foresight_solver` command if
marginal linearization has been used to compute an approximate solution.
.. matvar:: oo_.deterministic_simulation.sim1
|br| Set by the :comm:`perfect_foresight_solver` command if either
linearization or marginal linearization has been used to compute an
approximate solution. This structure contains the simulation corresponding
to the greatest share of the shocks for which an exact solution could be
computed. The subfield ``homotopy_completion_share`` contains that share.
The subfields ``endo_simul``, ``exo_simul``, ``steady_state`` and
``exo_steady_state`` respectively contain the path of endogenous, the path
of exogenous, the steady state of endogenous and the steady state of
exogenous for that simulation (with the same conventions as the fields of
of the same name in ``oo_``).
.. matvar:: oo_.deterministic_simulation.sim2
|br| Set by the :comm:`perfect_foresight_solver` command if marginal
linearization has been used to compute an approximate solution. This
structure contains the simulation corresponding to a share marginally
smaller that the one in :mvar:`oo_.deterministic_simulation.sim1`. The
subfields are the same as in :mvar:`oo_.deterministic_simulation.sim1`.
Perfect foresight with expectation errors
-----------------------------------------
 
......@@ -4097,16 +4207,16 @@ Such a scenario can be solved by Dynare using the
``perfect_foresight_with_expectation_errors_solver`` commands, alongside ``shocks``
and ``endval`` blocks which are given a special ``learnt_in`` option.
 
.. block:: shocks(learnt_in=INTEGER) ;
shocks(learnt_in=INTEGER,overwrite) ;
.. block:: shocks(learnt_in=INTEGER|DATE) ;
shocks(learnt_in=INTEGER|DATE, overwrite) ;
 
|br| The ``shocks(learnt_in=INTEGER)`` syntax can be used to specify temporary
|br| The ``shocks(learnt_in=INTEGER|DATE)`` syntax can be used to specify temporary
shocks that are learnt in a specific period. It should contain one or more
occurences of the following group of three lines, with the same semantics
as a regular :bck:`shocks` block::
 
var VARIABLE_NAME;
periods INTEGER[:INTEGER] [[,] INTEGER[:INTEGER]]...;
periods INTEGER[:INTEGER] | DATE[:DATE] [[,] INTEGER[:INTEGER] | DATE[:DATE]]...;
values DOUBLE | (EXPRESSION) [[,] DOUBLE | (EXPRESSION) ]...;
 
If the period in which information is learnt is greater or equal than 2,
......@@ -4120,8 +4230,11 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
 
The ``overwrite`` option says that this block cancels and replaces previous
``shocks`` and ``mshocks`` blocks that have the same ``learnt_in`` option.
Note that a block with an integer-valued ``learnt_in`` option never
overwrites a block with a date-valued ``learnt_in`` option, even if they
correspond to the same period.
 
Note that a ``shocks(learnt_in=1)`` block is equivalent to a regular
Also note that a ``shocks(learnt_in=1)`` block is equivalent to a regular
:bck:`shocks` block.
 
*Example*
......@@ -4156,9 +4269,20 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
- from the perspective of periods 4 (and following), ``x`` is expected to
be equal to 1.3 in period 4, and to 2.8 in period 5.
 
.. block:: endval(learnt_in=INTEGER) ;
*Example* (with dates)
::
shocks(learnt_in=2023Q1);
var x;
periods 2023Q1:2023Q2 2023Q3:2023Q4 2024Q1;
values 1 1.2 1.4;
end;
 
|br| The ``endval(learnt_in=INTEGER)`` can be used to specify terminal
.. block:: endval(learnt_in=INTEGER|DATE) ;
|br| The ``endval(learnt_in=INTEGER|DATE)`` can be used to specify terminal
conditions that are learnt in a specific period.
 
Note that an ``endval(learnt_in=1)`` block is equivalent to a regular
......@@ -4212,16 +4336,25 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
the desired behaviour, a ``shocks(learnt_in=3)`` block will have to be
added to reinstate the temporary shock.
 
.. block:: mshocks(learnt_in=INTEGER) ;
mshocks(learnt_in=INTEGER,OPTIONS...) ;
*Example* (with a date)
::
endval(learnt_in = 2024Q1);
x = 1.1;
end;
 
|br| The ``mshocks(learnt_in=INTEGER)`` syntax can be used to specify temporary
.. block:: mshocks(learnt_in=INTEGER|DATE) ;
mshocks(learnt_in=INTEGER|DATE,OPTIONS...) ;
|br| The ``mshocks(learnt_in=INTEGER|DATE)`` syntax can be used to specify temporary
shocks that are learnt in a specific period, specified in a multiplicative
way. It should contain one or more occurences of the following group of
three lines, with the same semantics as a regular :bck:`mshocks` block::
 
var VARIABLE_NAME;
periods INTEGER[:INTEGER] [[,] INTEGER[:INTEGER]]...;
periods INTEGER[:INTEGER] | DATE[:DATE] [[,] INTEGER[:INTEGER] | DATE[:DATE]]...;
values DOUBLE | (EXPRESSION) [[,] DOUBLE | (EXPRESSION) ]...;
 
As in the regular :bck:`mshocks` block (without the ``learnt_in`` option),
......@@ -4241,7 +4374,10 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
.. option:: overwrite
 
This block cancels and replaces previous ``shocks`` and ``mshocks``
blocks that have the same ``learnt_in`` option.
blocks that have the same ``learnt_in`` option. Note that a block with
an integer-valued ``learnt_in`` option never overwrites a block with a
date-valued ``learnt_in`` option, even if they correspond to the same
period.
 
.. option:: relative_to_initval
 
......@@ -4264,6 +4400,17 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
from the perspective of period 2 is used (as specified in the relevant
``endval(learnt_in=…`` block)).
 
*Example* (with dates)
::
mshocks(learnt_in=2024Q2);
var x;
periods 2024Q3:2024Q4;
values 1.1;
end;
.. command:: perfect_foresight_with_expectation_errors_setup ;
perfect_foresight_with_expectation_errors_setup (OPTIONS...);
 
......@@ -4290,6 +4437,14 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
 
Number of periods of the simulation.
 
.. option:: first_simulation_period = DATE
Same meaning as the eponymous option of :comm:`perfect_foresight_setup`.
.. option:: last_simulation_period = DATE
Same meaning as the eponymous option of :comm:`perfect_foresight_setup`.
.. option:: datafile = FILENAME
 
Used to specify the information about future shocks and their
......@@ -4421,12 +4576,14 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
By default, every time the information set changes, the simulation with
the new information set is shorter than the previous one (because the
terminal date is getting closer). When this option is set, every new
simulation has the same length (as specified by the `periods`` option
of :comm:`perfect_foresight_with_expectation_errors_setup`; as a
simulation has the same length (as specified by the ``periods`` option
of :comm:`perfect_foresight_with_expectation_errors_setup`); as a
consequence, the simulated paths as stored in ``oo_.endo_simul`` will
be longer when this option is set (if `s` is the last period in which
the information set is modified, then they will contain `s+periods-1`
periods, excluding initial and terminal conditions).
periods, excluding initial and terminal conditions). Note that this
option is not available if ``last_simulation_period`` option has been
passed to :comm:`perfect_foresight_with_expectation_errors_setup`.
 
*Output*
 
......@@ -4435,6 +4592,12 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
last period of the information set are available in ``oo_.steady_state``
and ``oo_.exo_steady_state``.
 
If any of the ``first_simulation_period`` or ``last_simulation_period``
option was passed to the preceding
:comm:`perfect_foresight_with_expectation_errors_setup` command, a time
series object containing both endogenous and exogenous variables is stored
in the workspace variable :mvar:`Simulated_time_series`.
.. matvar:: oo_.pfwee.shocks_info
 
|br| This variable stores the temporary shocks used during perfect
......@@ -4456,6 +4619,144 @@ and ``endval`` blocks which are given a special ``learnt_in`` option.
the terminal condition for exogenous indexed ``k``, as anticipated from
period ``s``, is stored in ``oo_.pfwee.terminal_info(k,s)``.
 
Controlling the path of endogenous variables
--------------------------------------------
In the usual perfect foresight problem, the user controls the path of exogenous
variables for the simulation periods and the initial and terminal
conditions for endogenous variables, while Dynare solves for the path of
endogenous variables for the simulation periods.
However, Dynare offers the possibility of controlling the value of some
endogenous variables for some simulation periods (in which case some exogenous
variables must be left free and are thus solved for by Dynare, to avoid
over-determination of the problem). This exercise is called “conditional
forecasting” in some contexts (even though one may argue that this is not
really forecasting, since perfect foresight by the agents is assumed; for the
stochastic case, see the :comm:`conditional_forecast` command).
The description of controlled endogenous variables is done using the
``perfect_foresight_controlled_paths`` block. The information given therein is
then processed by the :comm:`perfect_foresight_setup` (or
:comm:`perfect_foresight_with_expectation_errors_setup`) command, so
that the next :comm:`perfect_foresight_solver` (or
:comm:`perfect_foresight_with_expectation_errors_solver`) command
computes the simulation with controlled paths. In particular,
:mvar:`oo_.exo_simul` will contain the computed value of exogenous variables
that have been left free.
.. block:: perfect_foresight_controlled_paths ;
perfect_foresight_controlled_paths(OPTIONS...);
|br| This block is used to tell the perfect foresight solver that the value
of some endogenous variables will be controlled (in other words, they will
be exogenized). It also gives the period(s) for which this control applies,
the value(s) imposed to the endogenous variable(s), and the exogenous
variable(s) that are left free at the same period(s) (in other words,
those exogenous are endogenized).
The block should contain one or more occurrences of the following
group of four lines::
exogenize ENDOGENOUS_NAME;
periods INTEGER[:INTEGER] | DATE[:DATE] [[,] INTEGER[:INTEGER] | DATE[:DATE]]...;
values DOUBLE | (EXPRESSION) [[,] DOUBLE | (EXPRESSION) ]...;
endogenize EXOGENOUS_NAME;
Note that it is possible to have both
``perfect_foresight_controlled_paths`` and regular :bck:`shocks` blocks in
the same ``.mod`` file (assuming of course that taken together they do not
impose inconsistent constraints).
The ``perfect_foresight_controlled_paths`` block requires that the
:opt:`stack_solve_algo <stack_solve_algo = INTEGER>` option be equal to
either ``0``, ``1``, ``2``, ``3``, ``6`` or ``7``, and is incompatible with
the :opt:`block` and :opt:`bytecode` options of the :bck:`model` block and
:comm:`model_options` command.
*Options*
.. option:: learnt_in = INTEGER | DATE
Used in conjunction with
:comm:`perfect_foresight_with_expectation_errors_setup` and
:comm:`perfect_foresight_with_expectation_errors_solver` commands,
specifies the period or date at which this controlled paths block is
learnt by agents.
*Example (perfect foresight)*
::
var c k;
varexo x z;
...
shocks;
var x;
periods 1;
values 1.2;
end;
perfect_foresight_controlled_paths;
exogenize c;
periods 2 4:5;
values 1.6 1.7;
endogenize x;
exogenize k;
periods 7:9;
values 13;
endogenize z;
end;
perfect_foresight_setup(periods = 100);
perfect_foresight_solver;
In this example, the exogenous variable ``x`` is equal to 1.2 in
period 1, but in periods 2, 4 and 5 it will be endogenized so that
endogenous variable `c` is equal to 1.6 in period 2 and then 1.7 in
periods 4 and 5. Similarly, the exogenous variable ``z`` will be
endogenized in periods 7 to 9 so that the endogenous variable ``k`` is
equal to 13 over the same periods.
*Example (perfect foresight with expectation errors)*
::
var c;
varexo x;
...
perfect_foresight_controlled_paths;
exogenize c;
periods 2002Y 2003Y:2005Y;
values 1.6 1.7;
endogenize x;
end;
perfect_foresight_controlled_paths(learnt_in=2004Y);
exogenize c;
periods 2004Y:2005Y;
values 1.8;
endogenize x;
end;
perfect_foresight_with_expectation_errors_setup(periods = 30,
first_simulation_period = 2001Y);
perfect_foresight_with_expectation_errors_solver;
In this example, agents in year 2001 (at beginning of the simulation)
compute their plan under the assumption that the endogenous variable
``c`` will be equal to 1.6 in year 2002 and 1.7 from years 2003 to
2005, and that exogenous variable ``x`` will behave so as to fulfill
that constraint. Then, when 2004 arrives, they recompute their plan
under the assumption that ``c`` will be equal to 1.8 in years 2004 and
2005 (and again that ``x`` will be endogenized accordingly).
.. _stoch-sol:
 
Stochastic solution and simulation
......@@ -5182,7 +5483,7 @@ which is described below.
agents believe that there will no more shocks after period
:math:`t+S`. This is an experimental feature and can be quite
slow. A non-zero value is not compatible with the ``bytecode``
option of the ``model`` block.
option of the :bck:`model` block or :comm:`model_options` command.
Default: ``0``.
 
.. option:: hybrid
......@@ -5200,6 +5501,13 @@ which is described below.
rate or a model with irreversible investment). For specifying the
necessary complementarity conditions, see :opt:`lmmcp`.
 
.. option:: use_first_order_solution
Utilize the model simulation based on a first-order local
approximation as the initial guess for the nonlinear solver in
each period. If this is not applied, solution in previous
period is used.
 
Typology and ordering of variables
----------------------------------
......@@ -6825,13 +7133,10 @@ observed variables.
 
``11``
 
This is not strictly speaking an optimization
algorithm. The (estimated) parameters are treated as
state variables and estimated jointly with the
original state variables of the model using a
nonlinear filter. The algorithm implemented in Dynare
is described in *Liu and West (2001)*, and works with
``k`` order local approximations of the model.
Currently not in use. The Liu and West (2020) filter that
used to be available under this option value is now triggered with
``posterior_sampling_method='online'``.
 
``12``
 
......@@ -6946,9 +7251,9 @@ observed variables.
 
.. option:: prior_trunc = DOUBLE
 
Probability of extreme values of the prior density that is
Probability of extreme values of the prior density in each tail that is
ignored when computing bounds for the parameters. Default:
``1e-32``.
``1e-10`` for ``posterior_sampling_method=slice`` and ``0`` otherwise .
 
.. option:: huge_number = DOUBLE
 
......@@ -7416,7 +7721,7 @@ observed variables.
Triggers the computation of the posterior distribution of
IRFs. The length of the IRFs are controlled by the ``irf``
option. Results are stored in ``oo_.PosteriorIRF.dsge`` (see
below for a description of this variable).
below for a description of this variable). Not compatible with OccBin.
 
.. option:: relative_irf
 
......@@ -7533,6 +7838,15 @@ observed variables.
sampler proposed by *Waggoner, Wu and Zha (2016)* instead of the
standard Random-Walk Metropolis-Hastings.
 
``'online'``
Instructs Dynare to treat the (estimated) parameters as
state variables and estimate them jointly with the
original state variables of the model using a
nonlinear filter. The algorithm implemented in Dynare
is described in *Liu and West (2001)*, and works with
``k`` order local approximations of the model.
.. option:: posterior_sampler_options = (NAME, VALUE, ...)
 
A list of NAME and VALUE pairs. Can be used to set options for
......@@ -7755,7 +8069,7 @@ observed variables.
stored in ``oo_.PosteriorTheoreticalMoments`` (see
:mvar:`oo_.PosteriorTheoreticalMoments`). The number of lags in
the autocorrelation function is controlled by the ``ar``
option.
option. Not compatible with OccBin.
 
.. option:: contemporaneous_correlation
 
......@@ -7840,7 +8154,7 @@ observed variables.
the posterior mode. If a Metropolis-Hastings is computed, the
distribution of forecasts is stored in variables
``oo_.PointForecast`` and ``oo_.MeanForecast``. See
:ref:`fore`, for a description of these variables.
:ref:`fore`, for a description of these variables. Not compatible with OccBin.
 
.. option:: tex
 
......@@ -8394,7 +8708,8 @@ observed variables.
 
``'liu_west_delta'``
 
Set the value for delta for the Liu/West online filter. Default: ``0.99``.
Set the value for delta for the Liu/West online filter (``posterior_sampling_method='online'``).
Default: ``0.99``.
 
``'unscented_alpha'``
 
......@@ -9425,7 +9740,7 @@ Method of moments specific blocks
* the first column contains the names of the endogenous variables
* the second column contains the names of the exogenous variables
* the third column contains a nested cell array that contains
the list of horizons, values and weights.
the list of horizons, values and weights.
 
 
.. block:: matched_irfs_weights ;
......@@ -11557,9 +11872,9 @@ the :comm:`bvar_forecast` command.
oo_.conditional_forecast.uncond.FORECAST_MOMENT.VARIABLE_NAME
 
 
.. matvar:: forecasts.instruments
.. matvar:: oo_.conditional_forecast.instruments
 
Variable set by the ``conditional_forecast command``. Stores
Variable set by the ``conditional_forecast`` command. Stores
the names of the exogenous instruments.
 
 
......@@ -12160,7 +12475,7 @@ Optimal policy under discretion
You must ensure that your objective is quadratic. Regarding the model, it must
either be linear or solved at first order with an analytical steady state provided.
In the first case, you should set the ``linear`` option of the
``model`` block.
:bck:`model` block or :comm:`model_options` command.
 
It is possible to use the :comm:`estimation` command after the
``discretionary_policy`` command, in order to estimate the model with
......@@ -12507,8 +12822,9 @@ Performing sensitivity analysis
If equal to ``0``, ANOVA mapping (Type I error) If equal to
``1``, Screening analysis (Type II error). If equal to ``2``,
Analytic derivatives (similar to Type II error, only valid
when identification=1). Default: ``1`` when
``identification=1``, ``0`` otherwise.
when identification=1). The ANOVA mapping requires the SS-ANOVA-R MATLAB
Toolbox available at https://joint-research-centre.ec.europa.eu/system/files/2025-01/ss_anova_recurs.zip
Default: ``1`` when ``identification=1``, ``0`` otherwise.
 
.. option:: morris_nliv = INTEGER
 
......
......@@ -31,10 +31,15 @@ Dynare understands dates in a mod file. Users can declare annual, bi-annual,
quarterly, or monthly dates using the following syntax::
1990Y
1990A
1990S2
1990H2
1990Q4
1990M11
Note that there are two syntaxes for annual dates (`1990A` is equivalent to
`1990Y`), and for bi-annual dates (`1990H2` is equivalent to `1990S2`).
Behind the scene, Dynare’s preprocessor translates these expressions
into instantiations of the MATLAB/Octave’s class ``dates`` described
below. Basic operations can be performed on dates:
......@@ -54,7 +59,7 @@ below. Basic operations can be performed on dates:
Has two functions: difference and subtraction. If the second
argument is a date, calculates the difference between the first
date and the secmond date (e.g. ``1951Q2-1950Q1`` is equal to
date and the second date (e.g. ``1951Q2-1950Q1`` is equal to
``5``). If the second argument is an integer ``X``, subtracts
``X`` periods from the date (e.g. ``1951Q2-2`` is equal to
``1950Q4``).
......@@ -69,7 +74,7 @@ below. Basic operations can be performed on dates:
Can be used to create a range of dates. For instance, ``r =
1950Q1:1951Q1`` creates a ``dates`` object with five elements:
``1950Q1, 1950Q2, 1950Q3, 1950Q4`` and ``1951Q1``. By default the
``1950Q1``, ``1950Q2``, ``1950Q3``, ``1950Q4`` and ``1951Q1``. By default the
increment between each element is one period. This default can be
changed using, for instance, the following instruction:
``1950Q1:2:1951Q1`` which will instantiate a ``dates`` object with
......@@ -263,6 +268,39 @@ The dates class
do4 = dates('Q',1950, 1);
do5 = dates('D',1973, 1, 25);
|br|
A ``dates`` object with multiple elements can be considered a one-dimensional array of dates. Standard array operations can be applied to a ``dates`` object:
- square brackets can be used to concatenate dates objects::
>> A = dates('1938Q4');
>> B = dates('1945Q3');
>> C = [A, B];
- semicolons can be used to create ranges of dates::
>> A = dates('2009Q2');
>> B = A:A+2;
>> B
B = <dates: 2009Q2, 2009Q3, 2009Q4>
- objects can be indexed by an integer or a vector of integer::
>> B(1)
ans = <dates: 2009Q2>
>> B(end)
ans = <dates: 2009Q4>
>> B(1:2)
ans = <dates: 2009Q2, 2009Q3>
|br|
A list of the available methods, by alphabetical order, is given
below. Note that by default the methods do not allow in place
......@@ -301,8 +339,10 @@ The dates class
particularly useful if the methods are called in loops, since this
saves the object instantiation overhead.
|br|
.. datesmethod:: C = append (A, B)
C = append_ (A, B)
append_ (B)
|br| Appends ``dates`` object ``B``, or a string that can be
interpreted as a date, to the ``dates`` object ``A``. If ``B``
......@@ -786,8 +826,8 @@ The dates class
.. datesmethod:: C = pop (A)
C = pop (A, B)
C = pop_ (A)
C = pop_ (A, B)
pop_ ()
pop_ (B)
|br| Pop method for ``dates`` class. If only one input is
provided, the method removes the last element of a ``dates``
......@@ -810,7 +850,7 @@ The dates class
.. datesmethod:: C = remove (A, B)
C = remove_ (A, B)
remove_ (B)
|br| Remove method for ``dates`` class. Both inputs have to be ``dates`` objects, removes dates in ``B`` from ``A``.
......@@ -850,7 +890,7 @@ The dates class
.. datesmethod:: B = sort (A)
B = sort_ (A)
sort_ ()
|br| Sort method for ``dates`` objects. Returns a ``dates`` object
with elements sorted by increasing order.
......@@ -936,7 +976,7 @@ The dates class
.. datesmethod:: B = unique (A)
B = unique_ (A)
unique_ ()
|br| Overloads the MATLAB/Octave ``unique`` function. Returns
a ``dates`` object with repetitions removed (only the last
......@@ -1119,7 +1159,7 @@ The dseries class
.. dseriesmethod:: A = abs (B)
abs_ (B)
abs_ ()
|br| Overloads the ``abs()`` function for ``dseries``
objects. Returns the absolute value of the variables in
......@@ -1149,9 +1189,32 @@ The dseries class
1973Q2 | 0.51222 | 0.4948
1973Q3 | 0.99791 | 0.22677
*Example (in-place modification version)*
::
>> ts0 = dseries(randn(3,2),'1973Q1',{'A1'; 'A2'},{'A_1'; 'A_2'});
>> ts0
ts0 is a dseries object:
| A1 | A2
1973Q1 | -0.67284 | 1.4367
1973Q2 | -0.51222 | -0.4948
1973Q3 | 0.99791 | 0.22677
>> ts0.abs_();
>> ts0
ts0 is a dseries object:
| abs(A1) | abs(A2)
1973Q1 | 0.67284 | 1.4367
1973Q2 | 0.51222 | 0.4948
1973Q3 | 0.99791 | 0.22677
.. dseriesmethod:: [A, B] = align (A, B)
align_ (A, B)
align_ (B)
If ``dseries`` objects ``A`` and ``B`` are defined on
different time ranges, this function extends ``A`` and/or
......@@ -1206,8 +1269,60 @@ The dseries class
2001Q2 | 0.12801
*Example (in-place modification version)*
::
>> ts0 = dseries(rand(5,1),dates('2000Q1')); % 2000Q1 -> 2001Q1
>> ts1 = dseries(rand(3,1),dates('2000Q4')); % 2000Q4 -> 2001Q2
>> ts0
ts0 is a dseries object:
| Variable_1
2000Q1 | 0.80028
2000Q2 | 0.14189
2000Q3 | 0.42176
2000Q4 | 0.91574
2001Q1 | 0.79221
>> ts1
ts1 is a dseries object:
| Variable_1
2000Q4 | 0.95949
2001Q1 | 0.65574
2001Q2 | 0.035712
>> align_(ts0, ts1); % 2000Q1 -> 2001Q2
>> ts0
ts0 is a dseries object:
| Variable_1
2000Q1 | 0.80028
2000Q2 | 0.14189
2000Q3 | 0.42176
2000Q4 | 0.91574
2001Q1 | 0.79221
2001Q2 | NaN
>> ts1
ts1 is a dseries object:
| Variable_1
2000Q1 | NaN
2000Q2 | NaN
2000Q3 | NaN
2000Q4 | 0.95949
2001Q1 | 0.65574
2001Q2 | 0.035712
.. dseriesmethod:: C = backcast (A, B[, diff])
backcast_ (A, B[, diff])
backcast_ (B[, diff])
Backcasts ``dseries`` object ``A`` with ``dseries`` object B's
growth rates (except if the last optional argument, ``diff``,
......@@ -1215,8 +1330,8 @@ The dseries class
``dseries`` objects must have the same frequency.
.. dseriesmethod:: B = baxter_king_filter (A, hf, lf, K)
baxter_king_filter_ (A, hf, lf, K)
.. dseriesmethod:: B = baxter_king_filter (A[, hf[, lf[, K]]])
baxter_king_filter_ ([hf[, lf[, K]]])
|br| Implementation of the *Baxter and King* (1999) band pass
filter for ``dseries`` objects. This filter isolates business
......@@ -1262,7 +1377,7 @@ The dseries class
.. dseriesmethod:: B = center (A[, geometric])
center_ (A[, geometric])
center_ ([geometric])
|br| Centers variables in ``dseries`` object ``A`` around their
arithmetic means, except if the optional argument ``geometric``
......@@ -1271,7 +1386,7 @@ The dseries class
.. dseriesmethod:: C = chain (A, B)
chain_ (A, B)
chain_ (B)
|br| Merge two ``dseries`` objects along the time
dimension. The two objects must have the same number of
......@@ -1284,7 +1399,7 @@ The dseries class
::
>> ts = dseries([1; 2; 3; 4],dates(`1950Q1'))
>> ts = dseries([1; 2; 3; 4],dates('1950Q1'))
ts is a dseries object:
......@@ -1294,7 +1409,7 @@ The dseries class
1950Q3 | 3
1950Q4 | 4
>> us = dseries([3; 4; 5; 6],dates(`1950Q3'))
>> us = dseries([3; 4; 5; 6],dates('1950Q3'))
us is a dseries object:
......@@ -1316,6 +1431,25 @@ The dseries class
1951Q1 | 5
1951Q2 | 6
*Example (in-place modification version)*
::
>> ts = dseries([1; 2; 3; 4],dates('1950Q1'))
>> us = dseries([3; 4; 5; 6],dates('1950Q3'))
>> ts.chain_(us);
>> ts
ts is a dseries object:
| Variable_1
1950Q1 | 1
1950Q2 | 2
1950Q3 | 3
1950Q4 | 4
1951Q1 | 5
1951Q2 | 6
.. dseriesmethod:: [error_flag, message ] = check (A)
......@@ -1386,7 +1520,7 @@ The dseries class
.. dseriesmethod:: B = cumprod (A[, d[, v]])
cumprod_ (A[, d[, v]])
cumprod_ ([d[, v]])
|br| Overloads the MATLAB/Octave ``cumprod`` function for
``dseries`` objects. The cumulated product cannot be computed
......@@ -1449,7 +1583,7 @@ The dseries class
.. dseriesmethod:: B = cumsum (A[, d[, v]])
cumsum (A[, d[, v]])
cumsum_ ([d[, v]])
|br| Overloads the MATLAB/Octave ``cumsum`` function for
``dseries`` objects. The cumulated sum cannot be computed if
......@@ -1520,22 +1654,23 @@ The dseries class
10Y | 10.1416
.. dseriesmethod:: B = detrend (A, m)
detrend_ (A, m)
.. dseriesmethod:: B = detrend (A[, m])
detrend_ ([m])
|br| Detrends ``dseries`` object ``A`` with a fitted
polynomial of order ``m``. Note that each variable is
detrended with a different polynomial.
polynomial of order ``m``. Default value fir ``m`` is 0 (time
series are detrended by removing the average). Note that each
variable is detrended with a different polynomial.
.. dseriesmethod:: B = dgrowth (A)
dgrowth_ (A)
dgrowth_ ()
|br| Computes daily growth rates.
.. dseriesmethod:: B = diff (A)
diff_ (A)
diff_ ()
|br| Returns the first difference of ``dseries`` object ``A``.
......@@ -1625,6 +1760,29 @@ The dseries class
>> ts0 = dseries(rand(10,1));
>> ts1 = ts0.exp();
*Exemple (in-place modification version)*
::
>> ts0 = dseries(rand(3,1))
ts0 is a dseries object:
| Variable_1
1Y | 0.82953
2Y | 0.84909
3Y | 0.37253
>> ts0.exp_();
>> ts0
ts0 is a dseries object:
| Variable_1
1Y | 2.2922
2Y | 2.3375
3Y | 1.4514
.. dseriesmethod:: C = extract (A, B[, ...])
......@@ -1673,9 +1831,40 @@ The dseries class
1973Q4 | -0.03705 | -0.35899 | 0.85838 | -1.4675 | -2.1666 | -0.62032
.. dseriesmethod:: fill_(name, v)
|br| Assign the value ``v`` to the variable ``name`` in a
dseries object. If ``name`` is a character row array, it should
correspond to an existing variable within the dseries
object. When ``v`` is a scalar, its value will be applied to
all periods uniformly. If ``v`` is a vector, its length must
match the number of observations in the dseries object.You can
invoke this method for a batch of variables by providing a 1 by
n cell array of character row arrays as the first argument. When
"v" is a row vector with n elements, the method will be applied
uniformly across all periods. If "v" is a matrix, it must have
n columns, and the number of rows should correspond to the
number of periods.
*Example*
::
>> ts = dseries(rand(3,3));
>> ts.fill_({'Variable_1', 'Variable_3'}, [1 3]);
>> ts
ts is a dseries object:
| Variable_1 | Variable_2 | Variable_3
1Y | 1 | 0.91338 | 3
2Y | 1 | 0.63236 | 3
3Y | 1 | 0.09754 | 3
.. dseriesmethod:: f = firstdate (A)
|br| Returns the first period in ``dseries`` object ``A``.
|br| Returns the initial period in the ``dseries`` object ``A``.
.. dseriesmethod:: f = firstobservedperiod (A)
......@@ -1706,7 +1895,67 @@ The dseries class
4
.. dseriesmethod:: D = horzcat (A, B[, ...])
.. dseriesmethod:: l = ge (A, B)
l = gt (A, B)
|br| Overloads the ``gt`` (>) and ``ge`` (>=) binary operators. Returns a logical array.
*Example*
::
>> ts = dseries(randn(3,1))
ts is a dseries object:
| Variable_1
1Y | -1.2075
2Y | 0.71724
3Y | 1.6302
>> ts>1
ans =
3x1 logical array
0
0
1
>> ds = dseries(randn(3,1))
ds is a dseries object:
| Variable_1
1Y | 0.48889
2Y | 1.0347
3Y | 0.72689
>> ds>ts
ans =
3x1 logical array
1
1
0
.. dseriesmethod:: B = hdiff (A)
hdiff_ ()
|br| Computes bi-annual differences.
.. dseriesmethod:: B = hgrowth (A)
hgrowth_ ()
|br| Computes bi-annual growth rates.
.. dseriesmethod:: D = horzcat (A, B[, ...])
|br| Overloads the ``horzcat`` MATLAB/Octave’s method for
``dseries`` objects. Returns a ``dseries`` object ``D``
......@@ -1742,7 +1991,7 @@ The dseries class
.. dseriesmethod:: B = hpcycle (A[, lambda])
hpcycle_ (A[, lambda])
hpcycle_ ([lambda])
|br| Extracts the cycle component from a ``dseries`` ``A``
object using the *Hodrick and Prescott (1997)* filter and
......@@ -1783,7 +2032,7 @@ The dseries class
.. dseriesmethod:: B = hptrend (A[, lambda])
hptrend_ (A[, lambda])
hptrend_ ([lambda])
|br| Extracts the trend component from a ``dseries`` A object
using the *Hodrick and Prescott (1997)* filter and returns a
......@@ -1880,10 +2129,12 @@ The dseries class
.. dseriesmethod:: B = lag (A[, p])
lag_ (A[, p])
lag_ ([p])
|br| Returns lagged time series. Default value of integer scalar ``p``, the number
of lags, is ``1``.
|br| Returns lagged time series. Default value of integer
scalar ``p``, the number of lags, is ``1``. The `dseries`
class overloads the parentheses, so that `ts.lag(p)` is
equivalent to `ts(-p)`.
*Example*
......@@ -1948,7 +2199,7 @@ The dseries class
.. dseriesmethod:: l = lastdate (B)
|br| Returns the last period in ``dseries`` object ``B``.
|br| Retrieves the final period from the ``dseries`` object ``B``.
*Example*
......@@ -1962,23 +2213,76 @@ The dseries class
.. dseriesmethod:: f = lastobservedperiod (A)
|br| Returns the last period where all the variables in ``dseries`` object ``A`` are observed (non NaN).
|br| Returns the last period in which all variables of the
``dseries`` object ``A`` are fully observed (i.e., contain no
NaN values).
.. dseriesmethod:: f = lastobservedperiods (A)
|br| Returns for each variable the last period without missing
observations in ``dseries`` object ``A``. Output argument ``f`` is a
structure, each field name is the name of a variable in ``A``, each field
content is a singleton ``date`` object.
|br| Returns the last period without missing observations for
each variable in the ``dseries`` object ``A``. The output
argument ``f`` is a structure where each field name corresponds
to a variable in ``A``, and the content of each field is a
singleton ``date`` object.
.. dseriesmethod:: l = le (A, B)
l = lt (A, B)
|br| Overloads the ``gt`` (<) and ``ge`` (<=) binary operators. Returns a logical array.
*Example*
::
>> ts = dseries(randn(3,1))
ts is a dseries object:
| Variable_1
1Y | -1.2075
2Y | 0.71724
3Y | 1.6302
>> ts<1
ans =
3x1 logical array
1
1
0
>> ds = dseries(randn(3,1))
ds is a dseries object:
| Variable_1
1Y | 0.48889
2Y | 1.0347
3Y | 0.72689
>> ds<ts
ans =
3x1 logical array
0
0
1
.. dseriesmethod:: B = lead (A[, p])
lead_ (A[, p])
lead_ ([p])
|br| Returns lead time series. Default value of integer scalar
``p``, the number of leads, is ``1``. As in the ``lag``
method, the ``dseries`` class overloads the parenthesis so
that ``ts.lead(p)`` is equivalent to ``ts(p)``.
|br| Returns a lead time series. The default value for the
integer scalar ``p``, which represents the number of leads, is
``1``. Similar to the ``lag`` method, the ``dseries`` class
overloads the parentheses, making ``ts.lead(p)`` equivalent to
``ts(p)``.
*Example*
......@@ -2007,11 +2311,11 @@ The dseries class
*Remark*
The overloading of the parenthesis for ``dseries`` objects,
allows to easily create new ``dseries`` objects by
copying/pasting equations declared in the ``model`` block. For
instance, if an Euler equation is defined in the ``model``
block::
The overload of parentheses for ``dseries`` objects simplifies
the creation of new ``dseries`` instances by enabling the
direct copying and pasting of equations defined within the
``model`` block. For example, if an Euler equation is
specified in the ``model`` block,::
model;
...
......@@ -2052,7 +2356,7 @@ The dseries class
.. dseriesmethod:: B = log (A)
log_ (A)
log_ ()
|br| Overloads the MATLAB/Octave ``log`` function for
``dseries`` objects.
......@@ -2065,37 +2369,36 @@ The dseries class
>> ts1 = ts0.log();
.. dseriesmethod:: B = mdiff (A)
mdiff_ (A)
mdiff_ ()
B = mgrowth (A)
mgrowth_ (A)
mgrowth_ ()
|br| Computes monthly differences or growth rates of variables in
``dseries`` object ``A``.
|br| Calculates the monthly differences or growth rates of
variables in the ``dseries`` object ``A``.
.. dseriesmethod:: B = mean (A[, geometric])
|br| Overloads the MATLAB/Octave ``mean`` function for
``dseries`` objects. Returns the mean of each variable in
``dseries`` object ``A``. If the second argument is ``true``
the geometric mean is computed, otherwise (default) the
arithmetic mean is reported.
|br| This function overloads the MATLAB/Octave ``mean``
function specifically for ``dseries`` objects. It calculates
the mean for each variable within the ``dseries`` object
``A``. If the second argument is set to ``true``, the
geometric mean is calculated; otherwise, the arithmetic mean
is computed by default.
.. dseriesmethod:: C = merge (A, B[, legacy])
|br| Merges two ``dseries`` objects ``A`` and ``B`` in
``dseries`` object ``C``. Objects ``A`` and ``B`` need to have
common frequency but can be defined on different time
ranges. If a variable, say ``x``, is defined both in
``dseries`` objects ``A`` and ``B``, then the ``merge`` will
select the variable ``x`` as defined in the second input
argument, ``B``, except for the NaN elements in ``B`` if
corresponding elements in ``A`` (ie same periods) are well
defined numbers. This behaviour can be changed by setting the
optional argument ``legacy`` equal to true, in which case the
second variable overwrites the first one even if the second
variable has NaNs.
|br| Merges two ``dseries`` objects, ``A`` and ``B``, into a new
``dseries`` object ``C``. The objects ``A`` and ``B`` must share a
common frequency, although they can cover different time
ranges. If a variable, such as ``x``, exists in both ``dseries``
objects, the ``merge`` function will prioritize the definition
from the second input, ``B``, while retaining the values from
``A`` for any corresponding periods where ``B`` has NaN
values. This behavior can be altered by setting the optional
argument ``legacy`` to true, in which case the second variable
will replace the first, even if it contains NaN values.
*Example*
......@@ -2143,30 +2446,29 @@ The dseries class
.. dseriesmethod:: C = minus (A, B)
|br| Overloads the MATLAB/Octave ``minus`` (``-``) operator
for ``dseries`` objects, element by element subtraction. If
both ``A`` and ``B`` are ``dseries`` objects, they do not need
to be defined over the same time ranges. If ``A`` and ``B``
are ``dseries`` objects with :math:`T_A` and :math:`T_B`
for ``dseries`` objects, allowing for element-by-element
subtraction. When both ``A`` and ``B`` are ``dseries``
objects, they do not need to be defined over the same time
ranges. If ``A`` and ``B`` have :math:`T_A` and :math:`T_B`
observations and :math:`N_A` and :math:`N_B` variables, then
:math:`N_A` must be equal to :math:`N_B` or :math:`1` and
:math:`N_B` must be equal to :math:`N_A` or :math:`1`. If
:math:`T_A=T_B`, ``isequal(A.init,B.init)`` returns ``1`` and
:math:`N_A=N_B`, then the ``minus`` operator will compute for
each couple :math:`(t,n)`, with :math:`1\le t\le T_A` and
:math:`1\le n\le N_A`,
``C.data(t,n)=A.data(t,n)-B.data(t,n)``. If :math:`N_B` is
equal to :math:`1` and :math:`N_A>1`, the smaller ``dseries``
object (``B``) is “broadcast” across the larger ``dseries``
(``A``) so that they have compatible shapes, the ``minus``
operator will subtract the variable defined in ``B`` from each
variable in ``A``. If ``B`` is a double scalar, then the
method ``minus`` will subtract ``B`` from all the
observations/variables in ``A``. If ``B`` is a row vector of
length :math:`N_A`, then the ``minus`` method will subtract
``B(i)`` from all the observations of variable ``i``, for
:math:`N_A` must equal :math:`N_B` or :math:`1`, and
:math:`N_B` must equal :math:`N_A` or :math:`1`. If
:math:`T_A=T_B`, ``isequal(A.init,B.init)`` returns ``1``,
and :math:`N_A=N_B`, then the ``minus`` operator will compute
for each pair :math:`(t,n)`, where :math:`1\le t\le T_A` and
:math:`1\le n\le N_A`, the operation
``C.data(t,n)=A.data(t,n)-B.data(t,n)``. If :math:`N_B` equals
:math:`1` and :math:`N_A>1`, the smaller ``dseries`` object
(``B``) is “broadcasted” across the larger ``dseries`` (``A``),
ensuring compatible shapes for the subtraction of the variable
defined in ``B`` from each variable in ``A``. If ``B`` is a
double scalar, the ``minus`` method will subtract ``B`` from
all observations and variables in ``A``. If ``B`` is a row
vector of length :math:`N_A`, the ``minus`` method will
subtract ``B(i)`` from all observations of variable ``i``, for
:math:`i=1,...,N_A`. If ``B`` is a column vector of length
:math:`T_A`, then the ``minus`` method will subtract ``B``
from all the variables.
:math:`T_A`, the ``minus`` method will subtract ``B`` from all
the variables.
*Example*
......@@ -2213,15 +2515,16 @@ The dseries class
.. dseriesmethod:: C = mpower (A, B)
|br| Overloads the MATLAB/Octave ``mpower`` (``^``) operator for ``dseries``
objects and computes element-by-element power. ``A`` is a
|br| Overloads the MATLAB/Octave ``mpower`` (``^``) operator
for ``dseries`` objects, performing element-wise
exponentiation. Given a ``dseries`` object ``A`` with ``N``
variables and ``T`` observations, if ``B`` is a real scalar,
then ``mpower(A,B)`` yields a ``dseries`` object ``C`` where
``C.data(t,n) = A.data(t,n)^B``. If ``B`` is also a
``dseries`` object with ``N`` variables and ``T``
observations. If ``B`` is a real scalar, then ``mpower(A,B)``
returns a ``dseries`` object ``C`` with
``C.data(t,n)=A.data(t,n)^C``. If ``B`` is a ``dseries``
object with ``N`` variables and ``T`` observations then
``mpower(A,B)`` returns a ``dseries`` object ``C`` with
``C.data(t,n)=A.data(t,n)^C.data(t,n)``.
observations, then ``mpower(A,B)`` produces a ``dseries``
object ``C`` such that ``C.data(t,n) =
A.data(t,n)^{C.data(t,n)}``.
*Example*
......@@ -2249,31 +2552,31 @@ The dseries class
.. dseriesmethod:: C = mrdivide (A, B)
|br| Overloads the MATLAB/Octave ``mrdivide`` (``/``) operator for
``dseries`` objects, element by element division (like the
``./`` MATLAB/Octave operator). If both ``A`` and ``B`` are
``dseries`` objects, they do not need to be defined over the
same time ranges. If ``A`` and ``B`` are ``dseries`` objects
with :math:`T_A` and :math:`T_B` observations and :math:`N_A`
and :math:`N_B` variables, then :math:`N_A` must be equal to
:math:`N_B` or :math:`1` and :math:`N_B` must be equal to
:math:`N_A` or :math:`1`. If :math:`T_A=T_B`,
``isequal(A.init,B.init)`` returns ``1`` and :math:`N_A=N_B`,
then the ``mrdivide`` operator will compute for each couple
:math:`(t,n)`, with :math:`1\le t\le T_A` and :math:`1\le n\le
N_A`, ``C.data(t,n)=A.data(t,n)/B.data(t,n)``. If :math:`N_B`
is equal to :math:`1` and :math:`N_A>1`, the smaller
``dseries`` object (``B``) is “broadcast” across the larger
``dseries`` (``A``) so that they have compatible shapes. In
this case the ``mrdivide`` operator will divide each variable
defined in A by the variable in B, observation per
observation. If B is a double scalar, then ``mrdivide`` will
divide all the observations/variables in ``A`` by ``B``. If
``B`` is a row vector of length :math:`N_A`, then ``mrdivide``
will divide all the observations of variable ``i`` by
``B(i)``, for :math:`i=1,...,N_A`. If ``B`` is a column vector
of length :math:`T_A`, then ``mrdivide`` will perform a
division of all the variables by ``B``, element by element.
|br| Overloads the MATLAB/Octave ``mrdivide`` (``/``) operator
for ``dseries`` objects, enabling element-wise division
similar to the ``./`` operator in MATLAB/Octave. When both
``A`` and ``B`` are ``dseries`` objects, they can have
different time ranges. If ``A`` contains :math:`T_A`
observations and :math:`N_A` variables, and ``B`` has
:math:`T_B` observations and :math:`N_B` variables, then
:math:`N_A` must equal :math:`N_B` or :math:`1`, and vice
versa. If :math:`T_A=T_B` and ``isequal(A.init,B.init)``
returns ``1``, along with :math:`N_A=N_B`, the ``mrdivide``
operator calculates for each pair :math:`(t,n)`, where
:math:`1\le t\le T_A` and :math:`1\le n\le N_A`, the value of
``C.data(t,n)=A.data(t,n)/B.data(t,n)``. If :math:`N_B` equals
:math:`1` and :math:`N_A>1`, the smaller ``dseries`` object
(``B``) is “broadcast” across the larger one (``A``) to ensure
compatible shapes. In this case, the ``mrdivide`` operator
divides each variable in ``A`` by the variable in ``B``,
observation by observation. If ``B`` is a double scalar, then
``mrdivide`` will divide all observations and variables in
``A`` by ``B``. If ``B`` is a row vector of length
:math:`N_A`, then ``mrdivide`` will divide each observation of
variable ``i`` by ``B(i)``, for :math:`i=1,...,N_A`. If ``B``
is a column vector of length :math:`T_A`, then ``mrdivide``
will perform an element-wise division of all variables by
``B``.
*Example*
......@@ -2302,62 +2605,62 @@ The dseries class
.. dseriesmethod:: C = mtimes (A, B)
|br| Overloads the MATLAB/Octave ``mtimes`` (``*``) operator
for ``dseries`` objects and the Hadammard product (the .*
MATLAB/Octave operator). If both ``A`` and ``B`` are
``dseries`` objects, they do not need to be defined over the
same time ranges. If ``A`` and ``B`` are ``dseries`` objects
with :math:`T_A` and :math:`_B` observations and :math:`N_A`
and :math:`N_B` variables, then :math:`N_A` must be equal to
:math:`N_B` or :math:`1` and :math:`N_B` must be equal to
:math:`N_A` or :math:`1`. If :math:`T_A=T_B`,
``isequal(A.init,B.init)`` returns ``1`` and :math:`N_A=N_B`,
then the ``mtimes`` operator will compute for each couple
:math:`(t,n)`, with :math:`1\le t\le T_A` and :math:`1\le n\le
N_A`, ``C.data(t,n)=A.data(t,n)*B.data(t,n)``. If :math:`N_B`
is equal to :math:`1` and :math:`N_A>1`, the smaller
``dseries`` object (``B``) is “broadcast” across the larger
``dseries`` (``A``) so that they have compatible shapes,
``mtimes`` operator will multiply each variable defined in
``A`` by the variable in ``B``, observation per
observation. If ``B`` is a double scalar, then the method
``mtimes`` will multiply all the observations/variables in
for ``dseries`` objects, enabling element-wise multiplication
similar to the ``.*`` operator in MATLAB/Octave. When both
``A`` and ``B`` are ``dseries`` objects, they can have
different time ranges. If ``A`` contains :math:`T_A`
observations and :math:`N_A` variables, and ``B`` has
:math:`T_B` observations and :math:`N_B` variables, then
:math:`N_A` must equal :math:`N_B` or :math:`1`, and vice
versa. If :math:`T_A=T_B` and ``isequal(A.init,B.init)``
returns ``1``, along with :math:`N_A=N_B`, the ``mtimes``
operator calculates for each pair :math:`(t,n)`, where
:math:`1\le t\le T_A` and :math:`1\le n\le N_A`, the value of
``C.data(t,n)=A.data(t,n)*B.data(t,n)``. If :math:`N_B` equals
:math:`1` and :math:`N_A>1`, the smaller ``dseries`` object
(``B``) is “broadcasted” across the larger one (``A``) to ensure
compatible shapes. In this case, the ``mtimes`` operator
multiply each variable in ``A`` by the variable in ``B``,
observation by observation. If ``B`` is a double scalar, then
``mtimes`` will multiply all observations and variables in
``A`` by ``B``. If ``B`` is a row vector of length
:math:`N_A`, then the ``mtimes`` method will multiply all the
observations of variable ``i`` by ``B(i)``, for
:math:`i=1,...,N_A`. If ``B`` is a column vector of length
:math:`T_A`, then the ``mtimes`` method will perform a
multiplication of all the variables by ``B``, element by
element.
:math:`N_A`, then ``mtimes`` will multiply each observation of
variable ``i`` by ``B(i)``, for :math:`i=1,...,N_A`. If ``B``
is a column vector of length :math:`T_A`, then ``mtimes``
will perform an element-wise multiplication of all variables by
``B``.
.. dseriesmethod:: B = nanmean (A[, geometric])
|br| Overloads the MATLAB/Octave ``nanmean`` function for
``dseries`` objects. Returns the mean of each variable in
``dseries`` object ``A`` ignoring the NaN values. If the
second argument is ``true`` the geometric mean is computed,
otherwise (default) the arithmetic mean is reported.
``dseries`` objects. Computes the mean of each variable in the
``dseries`` object ``A``, excluding NaN values. If the second
argument is ``true``, the geometric mean is calculated;
otherwise, the default is to report the arithmetic mean.
.. dseriesmethod:: B = nanstd (A[, geometric])
|br| Overloads the MATLAB/Octave ``nanstd`` function for
``dseries`` objects. Returns the standard deviation of each
variable in ``dseries`` object ``A`` ignoring the NaN
values. If the second argument is ``true`` the geometric std
is computed, default value of the second argument is
``dseries`` objects. This function calculates the standard
deviation for each variable within the ``dseries`` object
``A``, while disregarding any NaN values. If the second
argument is set to ``true``, the geometric standard deviation
will be computed; the default value for the second argument is
``false``.
.. dseriesmethod:: C = ne (A, B)
|br| Overloads the MATLAB/Octave ``ne`` (not equal, ``~=``)
operator. ``dseries`` objects ``A`` and ``B`` must have the
same number of observations (say, :math:`T`) and variables
(:math:`N`). The returned argument is a :math:`T` by :math:`N`
matrix of zeros and ones. Element :math:`(i,j)` of ``C`` is
equal to ``1`` if and only if observation :math:`i` for
variable :math:`j` in ``A`` and ``B`` are not equal.
operator. The ``dseries`` objects ``A`` and ``B`` must contain
the same number of observations (denoted as :math:`T`) and
variables (denoted as :math:`N`). The output is a :math:`T` by
:math:`N` matrix consisting of zeros and ones. The element
:math:`(i,j)` of the matrix ``C`` is equal to ``1`` if and
only if observation :math:`i` for variable :math:`j` in ``A``
and ``B`` are not equal.
*Example*
......@@ -2394,25 +2697,25 @@ The dseries class
.. dseriesmethod:: B = onesidedhpcycle (A[, lambda[, init]])
onesidedhpcycle_ (A[, lambda[, init]])
onesidedhpcycle_ ([lambda[, init]])
|br| Extracts the cycle component from a ``dseries`` ``A``
object using a one sided HP filter (with a Kalman filter) and
returns a ``dseries`` object, ``B``. The default value for
``lambda``, the smoothing parameter, is ``1600``. By default,
if ``ìnit`` is not provided, the initial value is based on the
first two observations.
object using a one-sided HP filter (implemented with a Kalman
filter) and returns a ``dseries`` object, ``B``. The default
value for ``lambda``, the smoothing parameter, is set to
``1600``. By default, if ``init`` is not provided, the initial
value is determined from the first two observations.
.. dseriesmethod:: B = onesidedhptrend (A[, lambda[, init]])
onesidedhptrend_ (A[, lambda[, init]])
|br| Extracts the trend component from a ``dseries`` ``A``
object using a one sided HP filter (with a Kalman filter) and
returns a ``dseries`` object, ``B``. The default value for
``lambda``, the smoothing parameter, is ``1600``. By default,
if ``ìnit`` is not provided, the initial value is based on the
first two observations.
object using a one-sided HP filter (implemented with a Kalman
filter) and returns a ``dseries`` object, ``B``. The default
value for ``lambda``, the smoothing parameter, is set to
``1600``. By default, if ``init`` is not provided, the initial
value is derived from the first two observations.
.. dseriesmethod:: h = plot (A)
......@@ -2420,27 +2723,28 @@ The dseries class
h = plot (A[, ...])
h = plot (A, B[, ...])
|br| Overloads MATLAB/Octave’s ``plot`` function for
``dseries`` objects. Returns a MATLAB/Octave plot handle, that
can be used to modify the properties of the plotted time
series. If only one ``dseries`` object, ``A``, is passed as
argument, then the plot function will put the associated dates
on the x-abscissa. If this ``dseries`` object contains only
one variable, additional arguments can be passed to modify the
properties of the plot (as one would do with the
MATLAB/Octave’s version of the plot function). If ``dseries``
object ``A`` contains more than one variable, it is not
possible to pass these additional arguments and the properties
of the plotted time series must be modified using the returned
plot handle and the MATLAB/Octave ``set`` function (see
example below). If two ``dseries`` objects, ``A`` and ``B``,
are passed as input arguments, the plot function will plot the
variables in ``A`` against the variables in ``B`` (the number
of variables in each object must be the same otherwise an
error is issued). Again, if each object contains only one
variable, additional arguments can be passed to modify the
properties of the plotted time series, otherwise the
MATLAB/Octave ``set`` command has to be used.
|br| Overloads the MATLAB/Octave ``plot`` function for
``dseries`` objects. This function returns a MATLAB/Octave
plot handle, which can be utilized to modify the properties of
the plotted time series. If a single ``dseries`` object,
``A``, is provided as an argument, the plot function will
place the corresponding dates on the x-axis. If this
``dseries`` object contains only one variable, additional
arguments can be included to adjust the plot properties,
similar to how one would with MATLAB/Octave's original plot
function. However, if the ``dseries`` object ``A`` has more
than one variable, additional arguments cannot be passed, and
modifications to the plotted time series properties must be
done using the returned plot handle alongside the
MATLAB/Octave ``set`` function (refer to the example
below). When two ``dseries`` objects, ``A`` and ``B``, are
passed as input arguments, the plot function will display the
variables in ``A`` against those in ``B`` (it is essential
that both objects contain the same number of variables;
otherwise, an error will occur). Once more, if each object
includes only one variable, additional arguments can be
utilized to alter the plotted time series properties;
otherwise, the MATLAB/Octave ``set`` command must be employed.
*Example*
......@@ -2481,7 +2785,7 @@ The dseries class
.. dseriesmethod:: C = plus (A, B)
|br| Overloads the MATLAB/Octave ``plus`` (``+``) operator for
``dseries`` objects, element by element addition. If both
``dseries`` objects, allowing for element-wise addition. When both
``A`` and ``B`` are ``dseries`` objects, they do not need to
be defined over the same time ranges. If ``A`` and ``B`` are
``dseries`` objects with :math:`T_A` and :math:`T_B`
......@@ -2490,28 +2794,28 @@ The dseries class
:math:`N_B` must be equal to :math:`N_A` or :math:`1`. If
:math:`T_A=T_B`, ``isequal(A.init,B.init)`` returns ``1`` and
:math:`N_A=N_B`, then the ``plus`` operator will compute for
each couple :math:`(t,n)`, with :math:`1\le t\le T_A` and
each pair :math:`(t,n)`, with :math:`1\le t\le T_A` and
:math:`1\le n\le N_A`,
``C.data(t,n)=A.data(t,n)+B.data(t,n)``. If :math:`N_B` is
equal to :math:`1` and :math:`N_A>1`, the smaller ``dseries``
object (``B``) is “broadcast” across the larger ``dseries``
(``A``) so that they have compatible shapes, the plus operator
object (``B``) is “broadcasted” across the larger ``dseries``
(``A``) to ensure compatible shapes, the plus operator
will add the variable defined in ``B`` to each variable in
``A``. If ``B`` is a double scalar, then the method ``plus``
will add ``B`` to all the observations/variables in ``A``. If
``B`` is a row vector of length :math:`N_A`, then the ``plus``
method will add ``B(i)`` to all the observations of variable
``i``, for :math:`i=1,...,N_A`. If ``B`` is a column vector of
``i``, for :math:`i=1,\ldots,N_A`. If ``B`` is a column vector of
length :math:`T_A`, then the ``plus`` method will add ``B`` to
all the variables.
.. dseriesmethod:: C = pop (A[, B])
pop_ (A[, B])
pop_ ([B])
|br| Removes variable ``B`` from ``dseries`` object ``A``. By
default, if the second argument is not provided, the last
variable is removed.
|br| Removes the variable ``B`` from the ``dseries`` object
``A``. By default, if the second argument is not specified, the
last variable is removed.
*Example*
......@@ -2530,26 +2834,25 @@ The dseries class
.. dseriesmethod:: A = projection (A, info, periods)
|br| Projects variables in dseries object ``A``. ``info`` is
is a :math:`n \times 3` cell array. Each row provides
informations necessary to project a variable. The first column
contains the name of variable (row char array). the second
column contains the name of the method used to project the
associated variable (row char array), possible values are
``'Trend'``, ``'Constant'``, and ``'AR'``. Last column
provides quantitative information about the projection. If the
second column value is ``'Trend'``, the third column value is
the growth factor of the (exponential) trend. If the second
column value is ``'Constant'``, the third column value is the
level of the variable. If the second column value is ``'AR'``,
the third column value is the autoregressive parameter. The
variables can be projected with an AR(p) model, if the third
column contains a 1×p vector of doubles. The stationarity of
the AR(p) model is not tested. The case of the constant
projection, using the last value of the variable, is covered
with 'Trend' and a growth factor equal to 1, or 'AR' with an
autoregressive parameter equal to one (random walk). This
projection routine only deals with exponential trends.
|br| Projects variables in the dseries object ``A``. The
``info`` variable is a :math:`n \times 3` cell array, where
each row contains essential information for projecting a
variable. The first column holds the variable name (as a
character array), while the second column indicates the
projection method used (also a character array). The possible
values for this column are ``'Trend'``, ``'Constant'``, and
``'AR'``. The third column provides quantitative details
related to the projection: if the second column is
``'Trend'``, the third column specifies the growth factor of
the (exponential) trend; if ``'Constant'``, it indicates the
variable's level; and if ``'AR'``, it denotes the
autoregressive parameter. Variables can be projected using an
AR(p) model if the third column contains a 1×p vector of
doubles. Note that the stationarity of the AR(p) model is not
tested. For constant projections, one can use either `'Trend'`
with a growth factor of 1 or `'AR'` with an autoregressive
parameter of one (indicating a random walk). This projection
routine solely addresses exponential trends.
*Example*
......@@ -2563,8 +2866,8 @@ The dseries class
.. dseriesmethod:: B = qdiff (A)
B = qgrowth (A)
qdiff_ (A)
qgrowth_ (A)
qdiff_ ()
qgrowth_ ()
|br| Computes quarterly differences or growth rates.
......@@ -2598,12 +2901,14 @@ The dseries class
.. dseriesmethod:: C = remove (A, B)
remove_ (A, B)
remove_ (B)
|br| If ``B`` is a row char array, the name of a variable, these methods
are aliases for ``pop`` and ``pop_`` methods with two arguments. They
remove variable ``B`` from ``dseries`` object ``A``. To remove more than
one variable, one can pass a cell of row char arrays for ``B``.
|br| If ``B`` is a row character array representing the name
of a variable, these methods serve as aliases for the ``pop``
and ``pop_`` methods that accept two arguments. They remove
the variable ``B`` from the ``dseries`` object ``A``. To
remove multiple variables, you can pass a cell array of row
character arrays for ``B``.
*Example*
......@@ -2619,11 +2924,11 @@ The dseries class
2Y | 1 | 1
3Y | 1 | 1
A shorter syntax is available: ``remove(ts,'Variable_2')``
is equivalent to ``ts{'Variable_2'} = []`` (``[]`` can be
replaced by any empty object). This alternative syntax is
useful if more than one variable has to be removed. For
instance::
A more concise syntax is available: ``remove(ts,
'Variable_2')``, which is equivalent to ``ts{'Variable_2'}
= []`` (where ``[]`` can be substituted with any empty
object). This alternative syntax proves useful when
removing multiple variables. For example::
ts{'Variable_@2,3,4@'} = [];
......@@ -2634,12 +2939,13 @@ The dseries class
.. dseriesmethod:: B = rename (A, oldname, newname)
rename_ (A, oldname, newname)
rename_ (oldname, newname)
|br| Rename variable ``oldname`` to ``newname`` in ``dseries``
object ``A``. Returns a ``dseries`` object. If more than one
variable needs to be renamed, it is possible to pass cells of
char arrays as second and third arguments.
|br| Renames the variable ``oldname`` to ``newname`` in the
``dseries`` object ``A``. This function returns a ``dseries``
object. If multiple variables need to be renamed, you can
provide cell arrays of row character arrays as the second and
third arguments.
*Example*
......@@ -2656,12 +2962,12 @@ The dseries class
.. dseriesmethod:: C = rename (A, newname)
rename_ (A, newname)
rename_ (newname)
|br| Replace the names in ``A`` with those passed in the cell
string array ``newname``. ``newname`` must have the same
number of elements as ``dseries`` object ``A`` has
variables. Returns a ``dseries`` object.
|br| Replace the names in ``A`` with those specified in the
cell of row character arrays ``newname``. The cell ``newname`` must contain
the same number of elements as there are variables in the
``dseries`` object ``A``.
*Example*
......@@ -2688,12 +2994,12 @@ The dseries class
.. dseriesmethod:: B = round (A[, n])
round_ (A[, n])
round_ ([n])
|br| Rounds to the nearest decimal or integer. ``n`` is the
precision parameter (number of decimals), default value is 0
meaning that that by default the method rounds to the nearest
integer.
|br| Rounds each value to the nearest decimal or integer. The
parameter ``n`` specifies the precision (number of decimal
places), with a default value of 0, indicating that the method
will round to the nearest integer by default.
*Example*
......@@ -2717,11 +3023,12 @@ The dseries class
.. dseriesmethod:: save (A, basename[, format])
|br| Overloads the MATLAB/Octave ``save`` function and saves
``dseries`` object ``A`` to disk. Possible formats are ``mat``
(this is the default), ``m`` (MATLAB/Octave script), and
``csv`` (MATLAB binary data file). The name of the file
without extension is specified by ``basename``.
|br| Overloads the MATLAB/Octave ``save`` function to save the
``dseries`` object ``A`` to disk. The available formats
include ``mat`` (default, MATLAB binary data file), ``m``
(MATLAB/Octave script), and ``csv`` (comma-separated values
file). The base name of the file, excluding the extension, is
specified by ``basename``.
*Example*
......@@ -2768,13 +3075,14 @@ The dseries class
.. dseriesmethod:: B = set_names(A, s1, s2, ...)
|br| Renames variables in ``dseries`` object ``A`` and returns
a ``dseries`` object ``B`` with new names ``s1``, ``s2``,
... The number of input arguments after the first one
(``dseries`` object ``A``) must be equal to ``A.vobs`` (the
number of variables in ``A``). ``s1`` will be the name of the
first variable in ``B``, ``s2`` the name of the second
variable in ``B``, and so on.
|br| Renames the variables in the ``dseries`` object ``A`` and
returns a new ``dseries`` object ``B`` with the updated names
``s1``, ``s2``, and so forth. The number of input arguments
following the first one (the ``dseries`` object ``A``) must be
equal to ``A.vobs`` (the total number of variables in
``A``). The name ``s1`` will correspond to the first variable
in ``B``, ``s2`` to the second variable in ``B``, and this
pattern continues for the remaining variables.
*Example*
......@@ -2791,13 +3099,13 @@ The dseries class
.. dseriesmethod:: [T, N ] = size(A[, dim])
Overloads the MATLAB/Octave’s ``size`` function. Returns the
number of observations in ``dseries`` object ``A``
(i.e. ``A.nobs``) and the number of variables
(i.e. ``A.vobs``). If a second input argument is passed, the
``size`` function returns the number of observations if
``dim=1`` or the number of variables if ``dim=2`` (for all
other values of ``dim`` an error is issued).
Overloads the MATLAB/Octave ``size`` function to return the
number of observations in the ``dseries`` object ``A`` (i.e.,
``A.nobs``) as well as the number of variables (i.e.,
``A.vobs``). If a second input argument is provided, the
``size`` function will return the number of observations when
``dim=1`` or the number of variables when ``dim=2``. An error
will be issued for any other values of ``dim``.
*Example*
......@@ -2814,18 +3122,20 @@ The dseries class
.. dseriesmethod:: B = std (A[, geometric])
|br| Overloads the MATLAB/Octave ``std`` function for
``dseries`` objects. Returns the standard deviation of each
variable in ``dseries`` object ``A``. If the second argument
is ``true`` the geometric standard deviation is computed
(default value of the second argument is ``false``).
``dseries`` objects. This function returns the standard
deviation of each variable within the ``dseries`` object
``A``. If the second argument is set to ``true``, the
geometric standard deviation is calculated (the default value
for the second argument is ``false``).
.. dseriesmethod:: B = subsample (A, d1, d2)
|br| Returns a subsample, for periods between ``dates`` ``d1``
and ``d2``. The same can be achieved by indexing a
``dseries`` object with a ``dates`` object, but the
``subsample`` method is easier to use programmatically.
|br| Returns a subsample for the period between ``d1`` and
``d2``. While you can achieve the same result by indexing a
``dseries`` object with a ``dates`` object, the ``subsample``
method offers a more straightforward approach for programmatic
use.
*Example*
......@@ -2844,7 +3154,7 @@ The dseries class
.. dseriesmethod:: A = tag (A, a[, b, c])
|br| Add a tag to a variable in ``dseries`` object ``A``.
|br| Adds a tag to a variable in ``dseries`` object ``A``.
*Example*
......@@ -2859,23 +3169,24 @@ The dseries class
.. dseriesmethod:: B = tex_rename (A, name, newtexname)
B = tex_rename (A, newtexname)
tex_rename_ (A, name, newtexname)
tex_rename_ (A, newtexname)
tex_rename_ (name, newtexname)
tex_rename_ (newtexname)
|br| Redefines the tex name of variable ``name`` to
``newtexname`` in ``dseries`` object ``A``. Returns a
``dseries`` object.
|br| Updates the TeX name of the variable ``name`` to
``newtexname`` in the ``dseries`` object ``A``. Returns an
updated ``dseries`` object.
With only two arguments ``A`` and ``newtexname``, it redefines
the tex names of the ``A`` to those contained in
``newtexname``. Here, ``newtexname`` is a cell string array
with the same number of entries as variables in ``A``.
With just two arguments, ``A`` and ``newtexname``, this
function redefines the TeX names of the entries in ``A`` to
those specified in ``newtexname``. The ``newtexname`` argument
must be a cell row character arrays containing the same number of
entries as there are variables in ``A``.
.. dseriesmethod:: B = uminus(A)
|br| Overloads ``uminus`` (``-``, unary minus) for ``dseries``
object.
|br| Overloads the ``uminus`` operator (``-``, unary minus)
for the ``dseries`` object.
*Example*
......@@ -2898,13 +3209,13 @@ The dseries class
.. dseriesmethod:: D = vertcat (A, B[, ...])
|br| Overloads the ``vertcat`` MATLAB/Octave method for
``dseries`` objects. This method is used to append more
observations to a ``dseries`` object. Returns a ``dseries``
object ``D`` containing the variables in ``dseries`` objects
passed as inputs. All the input arguments must be ``dseries``
objects with the same variables defined on different time
ranges.
|br| Overloads the ``vertcat`` method in MATLAB/Octave for
``dseries`` objects. This method facilitates the appending of
additional observations to a ``dseries`` object. It returns a
new ``dseries`` object, ``D``, which contains the variables
from the input ``dseries`` objects. All input arguments must
be ``dseries`` objects that share the same variables but are
defined over different time ranges.
*Example*
......@@ -2925,8 +3236,7 @@ The dseries class
.. dseriesmethod:: B = vobs (A)
|br| Returns the number of variables in ``dseries`` object
``A``.
|br| Returns the count of variables in the ``dseries`` object ``A``.
*Example*
......@@ -2942,10 +3252,10 @@ The dseries class
.. dseriesmethod:: B = ydiff (A)
B = ygrowth (A)
ydiff_ (A)
ygrowth_ (A)
ydiff_ ()
ygrowth_ ()
|br| Computes yearly differences or growth rates.
|br| Calculates annual differences or growth rates.
.. _x13-members:
......@@ -3207,10 +3517,10 @@ X-13 ARIMA-SEATS interface
The above example shows how to remove a seasonal pattern from a time series.
``o.transform('function','auto','savelog','atr')`` instructs the subsequent
``o.automdl()`` command to check whether an additional or a multiplicative
pattern fits the data better and to save the result. The result is saved in
`o.results.autotransform`, which in the present example indicates that a
``o.transform('function','auto','savelog','atr')`` instructs the subsequent
``o.automdl()`` command to check whether an additional or a multiplicative
pattern fits the data better and to save the result. The result is saved in
`o.results.autotransform`, which in the present example indicates that a
log transformation, i.e. a multiplicative model was preferred. The ``o.automdl('savelog','all')`` automatically selects a fitting
ARIMA model and saves all relevant output to the .log-file. The ``o.x11('save','(d11, d10)')`` instructs
``x11`` to save both the final seasonally adjusted series ``d11`` and the final seasonal factor ``d10``
......
......@@ -97,7 +97,7 @@ class DynObject(ObjectDescription):
self.state_machine.reporter.warning(
'duplicate object description of %s, ' % fullname +
'other instance in ' +
self.env.doc2path(objects[fullname][0]),line=self.lineno)
str(self.env.doc2path(objects[fullname][0])),line=self.lineno)
objects[fullname] = (self.env.docname, self.objtype)
indextext = self.get_index_text(fullname,name_obj)
......@@ -242,7 +242,7 @@ class DynSimpleObject(ObjectDescription):
self.state_machine.reporter.warning(
'duplicate object description of %s, ' % fullname +
'other instance in ' +
self.env.doc2path(objects[fullname][0]), line=self.lineno)
str(self.env.doc2path(objects[fullname][0])), line=self.lineno)
objects[fullname] = self.env.docname, self.objtype
indextext = self.get_index_text(fullname,name_obj)
......
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Dynare
Upstream-Contact: Dynare Team, whose members in 2024 are:
Upstream-Contact: Dynare Team, whose members in 2025 are:
- Stéphane Adjemian <stephane.adjemian@univ-lemans.fr>
- Michel Juillard <michel.juillard@mjui.fr>
- Frédéric Karamé <frederic.karame@univ-lemans.fr>
......@@ -23,7 +23,7 @@ Upstream-Contact: Dynare Team, whose members in 2024 are:
Source: https://www.dynare.org
Files: *
Copyright: 1996-2024 Dynare Team
Copyright: 1996-2025 Dynare Team
License: GPL-3+
Files: matlab/+occbin/IVF_core.m
......@@ -97,7 +97,7 @@ License: GPL-3+
Files: matlab/optimization/cmaes.m
Copyright: 2001-2012 Nikolaus Hansen
2012-2017 Dynare Team
2012-2023 Dynare Team
License: GPL-3+
Files: matlab/optimization/solvopt.m
......@@ -173,7 +173,7 @@ Comment: The author gave authorization to redistribute
Files: matlab/+gsa/Morris_Measure_Groups.m
matlab/+gsa/Sampling_Function_2.m
Copyright: 2005 European Commission
2012-2013 Dynare Team
2012-2023 Dynare Team
License: GPL-3+
Comment: Written by Jessica Cariboni and Francesca Campolongo
Joint Research Centre, The European Commission,
......@@ -220,14 +220,14 @@ License: GPL-3+
Files: matlab/missing/stats/quantile.m
Copyright: 2014-2016 Christopher Hummersone
2016-2017 Dynare Team
2016-2023 Dynare Team
License: GPL-3+
Files: matlab/missing/stats/corr.m
Copyright: 1993-1996 Kurt Hornik
1996-2015 John W. Eaton
2013-2015 Julien Bect
2016-2017 Dynare Team
2016-2023 Dynare Team
License: GPL-3+
Files: matlab/lmmcp/catstruct.m
......@@ -260,7 +260,7 @@ Copyright: 2000-2022 Frank Schorfheide
License: CC-BY-SA-4.0
Files: doc/*.rst doc/*.tex doc/*.svg doc/*.pdf doc/*.bib
Copyright: 1996-2022 Dynare Team
Copyright: 1996-2025 Dynare Team
License: GFDL-NIV-1.3+
Files: doc/dr.tex doc/dr.bib
......@@ -278,14 +278,14 @@ License: GPL-3+
Files: scripts/dynare.el
Copyright: 2010 Yannick Kalantzis
2019-2023 Dynare Team
2019-2025 Dynare Team
License: GPL-3+
Files: mex/sources/gensylv/gensylv.cc
mex/sources/libkorder/kord/* mex/sources/libkorder/sylv/*
mex/sources/libkorder/tl/* mex/sources/libkorder/utils/*
Copyright: 2004-2011 Ondra Kamenik
2019-2023 Dynare Team
2019-2025 Dynare Team
License: GPL-3+
Files: mex/sources/sobol/sobol.f08
......@@ -294,11 +294,11 @@ Copyright: 2004-2009 John Burkardt
License: LGPL-3+
Files: preprocessor/doc/macroprocessor/*
Copyright: 2008-2021 Dynare Team
Copyright: 2008-2024 Dynare Team
License: CC-BY-SA-4.0
Files: preprocessor/doc/preprocessor/*
Copyright: 2007-2019 Dynare Team
Copyright: 2007-2023 Dynare Team
License: CC-BY-SA-4.0
Files: contrib/ms-sbvar/utilities_dw/*
......
......@@ -70,7 +70,7 @@ ln -s "$BREWDIR"/opt/gcc/lib/gcc/"$GCC_VERSION"/libquadmath.a "$QUADMATH_DIR"
cd "$ROOTDIR"
# NB: the addition of -Wl,-ld_classic is a workaround for https://github.com/mesonbuild/meson/issues/12282 (see also the native file)
common_meson_opts=(-Dbuild_for=matlab -Dbuildtype=release -Dprefer_static=true -Dfortran_args="[ '-B', '$LIB64/Slicot/' ]" \
common_meson_opts=(-Dbuild_for=matlab --buildtype=release --prefer-static -Dfortran_args="[ '-B', '$LIB64/Slicot/' ]" \
-Dc_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" -Dcpp_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" -Dfortran_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" \
--native-file macOS/homebrew-native-$PKG_ARCH.ini)
......
......@@ -360,7 +360,7 @@ if options_gsa.redform && ~isempty(options_gsa.namendo)
if isempty(options_gsa.threshold_redform) && ~(exist('gsa_sdp','file')==6 || exist('gsa_sdp','file')==2)
fprintf('\nThe "SS-ANOVA-R: MATLAB Toolbox for the estimation of Smoothing Spline ANOVA models with Recursive algorithms" is missing.\n')
fprintf('To obtain it, go to:\n\n')
fprintf('https://ec.europa.eu/jrc/en/macro-econometric-statistical-software/ss-anova-r-downloads \n\n')
fprintf('https://joint-research-centre.ec.europa.eu/system/files/2025-01/ss_anova_recurs.zip \n\n')
fprintf('and follow the instructions there.\n')
fprintf('After obtaining the files, you need to unpack them and set a Matlab Path to those files.\n')
error('SS-ANOVA-R Toolbox missing!')
......
......@@ -92,6 +92,10 @@ xparam1=[];
[~,~,~,lb,ub] = set_prior(estim_params_,M_,options_); %Prepare bounds
if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0)
% Set prior bounds
if options_.prior_trunc==0
fprintf('\nstability_mapping: GSA with priors requires bounded support. Setting options_.prior_trunc=1e-10.\n')
options_.prior_trunc=1e-10;
end
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
bounds.lb = max(bounds.lb,lb);
bounds.ub = min(bounds.ub,ub);
......
......@@ -297,6 +297,15 @@ if info(1) == 0 %no errors in solution
options_.analytic_derivation = -2; %this sets asy_Hess=1 in dsge_likelihood.m
[info, oo_, options_, M_] = stoch_simul(M_, options_, oo_, options_.varobs);
dataset_ = dseries(oo_.endo_simul(options_.varobs_id,100+1:end)',dates('1Q1'), options_.varobs); %get information on moments
% set info on missing data
if dataset_info.missing.state
[dataset_info.missing.aindex, dataset_info.missing.number_of_observations, dataset_info.missing.no_more_missing_observations, dataset_info.missing.vindex] = ...
describe_missing_data(dataset_.data);
else
dataset_info.missing.aindex = num2cell(transpose(repmat(1:dataset_.vobs,dataset_.nobs,1)),1);
dataset_info.missing.no_more_missing_observations = 1;
end
derivatives_info.no_DLIK = 1;
bounds = prior_bounds(bayestopt_, options_.prior_trunc); %reset bounds as lb and ub must only be operational during mode-finding
%note that for order>1 we do not provide any information on DT,DYss,DOM in derivatives_info, such that dsge_likelihood creates an error. Therefore the computation will be based on simulated_moment_uncertainty for order>1.
......
......@@ -240,7 +240,7 @@ end
% check for external draws, i.e. set pdraws0 for a gsa analysis
if options_ident.gsa_sample_file
GSAFolder = checkpath('gsa',dname);
GSAFolder = CheckPath('gsa',dname);
if options_ident.gsa_sample_file==1
load([GSAFolder,filesep,fname,'_prior'],'lpmat','lpmat0','istable');
elseif options_ident.gsa_sample_file==2
......@@ -300,6 +300,11 @@ options_.analytic_derivation=options_ident.analytic_derivation;
% 1: analytic derivation of gradient and hessian of likelihood in dsge_likelihood.m, only works for stationary models, i.e. kalman_algo<3
options_ = set_default_option(options_,'datafile','');
options_.mode_compute = 0;
if strcmp('slice',options_.posterior_sampler_options.posterior_sampling_method)
if strfind(options_.posterior_sampler_options.sampling_opt,'slice_initialize_with_mode'',1')
options_.posterior_sampler_options.sampling_opt=strrep(options_.posterior_sampler_options.sampling_opt,'slice_initialize_with_mode'',1','slice_initialize_with_mode'',0') % reset option to prevent crash in check_posterior_sampler_options.m if mode_compute is set to 0, see https://git.dynare.org/Dynare/dynare/-/issues/1957
end
end
options_.plot_priors = 0;
options_.smoother = 1;
options_.options_ident = [];
......@@ -485,7 +490,7 @@ if iload <=0
kk=0;
while kk<50 && info(1)
kk=kk+1;
params = Prior.draw();
params = Prior.draw()'; %column vector is expected
options_ident.tittxt = 'Random_prior_params'; %title text for graphs and figures
% perform identification analysis
[ide_moments_point, ide_spectrum_point, ide_minimal_point, ide_hess_point, ide_reducedform_point, ide_dynamic_point, ~, info, error_indicator_point] = ...
......@@ -504,7 +509,10 @@ if iload <=0
else
% found a (random) point that solves the model
fprintf('Found a random draw from the priors that solves the model:\n');
disp(params);
labels = name;
headers = {'Name', 'Value'};
lh = cellofchararraymaxlength(labels)+2;
dyntable(options_, 'Feasible draw', headers, labels, params', lh, 10, 6);
fprintf('Identification now continues for this draw.');
parameters = 'Random_prior_params';
parameters_TeX = 'Random prior parameter draw';
......
......@@ -85,7 +85,7 @@ if options_.occbin.smoother.linear_smoother && nargin==12
oo_.occbin.linear_smoother.alphahat0=alphahat0;
oo_.occbin.linear_smoother.state_uncertainty0=state_uncertainty0;
fprintf('\nOccbin: linear smoother done.\n')
disp_verbose('Occbin: linear smoother done.',options_.verbosity)
options_.occbin.smoother.status=true;
end
% if init_mode
......@@ -123,22 +123,20 @@ occbin_options.opts_simul = opts_simul; % this builds the opts_simul options fie
occbin_options.opts_regime.binding_indicator = options_.occbin.smoother.init_binding_indicator;
occbin_options.opts_regime.regime_history=options_.occbin.smoother.init_regime_history;
error_indicator=false;
options_.noprint = true;
try
%blanket try-catch should be replaced be proper error handling, see https://git.dynare.org/Dynare/dynare/-/merge_requests/2226#note_20318
[alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK,T0,R0,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_,alphahat0,state_uncertainty0] = DsgeSmoother(xparam1,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_,occbin_options);% T1=TT;
catch ME
error_indicator=true;
disp(ME.message)
for iter = 1:numel(ME.stack)
ME.stack(iter)
end
[alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK,T0,R0,P,PK,decomp,Trend,state_uncertainty,oo_,bayestopt_,alphahat0,state_uncertainty0,~,error_indicator] = DsgeSmoother(xparam1,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_,occbin_options);% T1=TT;
if error_indicator(1) || isempty(alphahat0)
if ~options_.occbin.smoother.linear_smoother || nargin~=12 %make sure linear smoother results are set before using them
options_.occbin.smoother.status=false;
[~,etahat,~,~,~,~,~,~,~,~,~,~,~,~,~,~,alphahat0] = ...
DsgeSmoother(xparam1,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
options_.occbin.smoother.status=true;
else
etahat= oo_.occbin.linear_smoother.etahat;
alphahat0= oo_.occbin.linear_smoother.alphahat0;
end
if error_indicator || isempty(alphahat0)
etahat= oo_.occbin.linear_smoother.etahat;
alphahat0= oo_.occbin.linear_smoother.alphahat0;
base_regime = struct();
if M_.occbin.constraint_nbr==1
base_regime.regime = 0;
......@@ -173,7 +171,7 @@ occbin_options.first_period_occbin_update = inf;
opts_regime.binding_indicator=[];
regime_history0 = regime_history;
fprintf('Occbin smoother iteration 1.\n')
disp_verbose('Occbin smoother iteration 1.',options_.verbosity)
opts_simul.SHOCKS = [etahat(:,1:end)'; zeros(1,M_.exo_nbr)];
opts_simul.exo_pos = 1:M_.exo_nbr;
opts_simul.endo_init = alphahat0(oo_.dr.inv_order_var,1);
......@@ -182,8 +180,7 @@ opts_simul.periods = size(opts_simul.SHOCKS,1);
options_.occbin.simul=opts_simul;
[~, out, ss] = occbin.solver(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
if out.error_flag
fprintf('Occbin smoother:: simulation within smoother did not converge.\n')
print_info(out.error_flag, options_.noprint, options_)
disp_verbose('Occbin smoother:: simulation within smoother did not converge.',options_.verbosity)
oo_.occbin.smoother.error_flag=321;
return;
end
......@@ -226,7 +223,7 @@ end
while is_changed && maxiter>iter && ~is_periodic
iter=iter+1;
fprintf('Occbin smoother iteration %u.\n', iter)
disp_verbose(sprintf('Occbin smoother iteration %u.', iter),options_.verbosity)
occbin_options.opts_regime.regime_history=regime_history;
[alphahat,etahat,epsilonhat,~,SteadyState,trend_coeff,~,T0,R0,P,~,decomp,Trend,state_uncertainty,oo_,bayestopt_,alphahat0,state_uncertainty0]...
= DsgeSmoother(xparam1,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_,occbin_options,TT,RR,CC);
......@@ -245,8 +242,7 @@ while is_changed && maxiter>iter && ~is_periodic
options_.occbin.simul=opts_simul;
[~, out, ss] = occbin.solver(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state);
if out.error_flag
fprintf('Occbin smoother:: simulation within smoother did not converge.\n')
print_info(out.error_flag, false, options_)
disp_verbose('Occbin smoother:: simulation within smoother did not converge.',options_.verbosity)
oo_.occbin.smoother.error_flag=321;
return;
end
......@@ -300,13 +296,13 @@ while is_changed && maxiter>iter && ~is_periodic
eee(:,k) = eig(TT(:,:,k));
end
if options_.debug
err_eig(iter-1) = max(max(abs(sort(eee)-sort(sto_eee))));
err_alphahat(iter-1) = max(max(max(abs(alphahat-sto_alphahat))));
err_etahat(iter-1) = max(max(max(abs(etahat-sto_etahat{iter-1}))));
err_CC(iter-1) = max(max(max(abs(CC-sto_CC))));
err_RR(iter-1) = max(max(max(abs(RR-sto_RR))));
err_TT(iter-1) = max(max(max(abs(TT-sto_TT))));
end
err_eig(iter-1) = max(max(abs(sort(eee)-sort(sto_eee))));
err_alphahat(iter-1) = max(max(max(abs(alphahat-sto_alphahat))));
err_etahat(iter-1) = max(max(max(abs(etahat-sto_etahat{iter-1}))));
err_CC(iter-1) = max(max(max(abs(CC-sto_CC))));
err_RR(iter-1) = max(max(max(abs(RR-sto_RR))));
err_TT(iter-1) = max(max(max(abs(TT-sto_TT))));
end
end
if occbin_smoother_debug || is_periodic
......@@ -391,22 +387,22 @@ if occbin_smoother_debug
end
if (maxiter==iter && is_changed) || is_periodic
disp('occbin.DSGE_smoother: smoother did not converge.')
fprintf('occbin.DSGE_smoother: The algorithm did not reach a fixed point for the smoothed regimes.\n')
disp_verbose('occbin.DSGE_smoother: smoother did not converge.',options_.verbosity)
disp_verbose('occbin.DSGE_smoother: The algorithm did not reach a fixed point for the smoothed regimes.',options_.verbosity)
if is_periodic
oo_.occbin.smoother.error_flag=0;
fprintf('occbin.DSGE_smoother: For the periods indicated above, regimes loops between the "regime_" and the "regime_new_" pattern displayed above.\n')
fprintf('occbin.DSGE_smoother: We provide smoothed shocks consistent with "regime_" in oo_.\n')
disp_verbose('occbin.DSGE_smoother: For the periods indicated above, regimes loops between the "regime_" and the "regime_new_" pattern displayed above.',options_.verbosity)
disp_verbose('occbin.DSGE_smoother: We provide smoothed shocks consistent with "regime_" in oo_.',options_.verbosity)
else
fprintf('occbin.DSGE_smoother: The respective fields in oo_ will be left empty.\n')
disp_verbose('occbin.DSGE_smoother: The respective fields in oo_ will be left empty.',options_.verbosity)
oo_.occbin.smoother=[];
oo_.occbin.smoother.error_flag=322;
end
else
disp('occbin.DSGE_smoother: smoother converged.')
disp_verbose('occbin.DSGE_smoother: smoother converged.',options_.verbosity)
oo_.occbin.smoother.error_flag=0;
if occbin_smoother_fast && is_changed_start
disp('occbin.DSGE_smoother: WARNING: fast algo is used, regime duration was not forced to converge')
disp_verbose('occbin.DSGE_smoother: WARNING: fast algo is used, regime duration was not forced to converge',options_.verbosity)
end
end
if (~is_changed || occbin_smoother_debug) && nargin==12
......@@ -484,9 +480,9 @@ if (~is_changed || occbin_smoother_debug) && nargin==12
fprintf(fidTeX,'\\label{Fig:smoothedshocks_occbin:%s}\n',int2str(ifig));
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
end
end
end
end
if mod(j1,9)~=0 && j==M_.exo_nbr
......
......@@ -109,6 +109,7 @@ if info==0
newstart = regx(1).regimestart(end);
diffstart = newstart-oldstart;
regname = 'regimestart';
reg_string = 'regime';
else
newstart1 = regx(1).regimestart1(end);
newstart2 = regx(1).regimestart2(end);
......@@ -118,11 +119,13 @@ if info==0
switch diffregime
case 1
regname = 'regimestart1';
reg_string = 'regime1';
case 2
regname = 'regimestart2';
reg_string = 'regime2';
end
end
end
end
if options_.occbin.filter.use_relaxation && diffstart>options_.occbin.filter.use_relaxation
guess_regime = [base_regime base_regime];
options_.occbin.filter.guess_regime = true;
......@@ -132,9 +135,15 @@ if options_.occbin.filter.use_relaxation && diffstart>options_.occbin.filter.use
% we reduce length until the converged regime does not change
guess_regime(1).(regname)(end) = regx2(1).(regname)(end)-1;
if guess_regime(1).(regname)(end-1)==guess_regime(1).(regname)(end)
guess_regime(1).(regname)(end-1) = guess_regime(1).(regname)(end-1)-1;
end
if guess_regime(1).(regname)(end)==1
% make sure we enforce base regime
guess_regime(1).(regname)=guess_regime(1).(regname)(end);
guess_regime(1).(reg_string)=0;
else
if guess_regime(1).(regname)(end-1)==guess_regime(1).(regname)(end)
guess_regime(1).(regname)(end-1) = guess_regime(1).(regname)(end-1)-1;
end
end
if is_multivariate
[ax2, a1x2, Px2, P1x2, vx2, Tx2, Rx2, Cx2, regx2, info2, M_2, likx2, etahat2, alphahat2, V2] = occbin.kalman_update_algo_1(a0,a1,P0,P1,data_index,Z,vv,Y,H,Qt,T0,R0,TT,RR,CC,guess_regime,M_,dr,endo_steady_state,exo_steady_state,exo_det_steady_state,options_,occbin_options);
else
......
......@@ -12,7 +12,7 @@ function options_ = default_option_values(M_)
% SPECIAL REQUIREMENTS
% none
% Copyright © 2018-2024 Dynare Team
% Copyright © 2018-2025 Dynare Team
%
% This file is part of Dynare.
%
......@@ -195,8 +195,7 @@ ep.use_bytecode = 0;
% Initialization of the perfect foresight equilibrium paths
% * init=0, previous solution is used.
% * init=1, a path generated with the first order reduced form is used.
% * init=2, mix of cases 0 and 1.
ep.init = 0;
ep.use_first_order_solution_as_initial_guess = false;
% Maximum number of iterations for the deterministic solver.
ep.maxit = 500;
% Number of periods for the perfect foresight model.
......@@ -289,9 +288,6 @@ particle.resampling.number_of_partitions = 200;
particle.mixture_state_variables = 5 ;
particle.mixture_structural_shocks = 1 ;
particle.mixture_measurement_shocks = 1 ;
% Online approach
particle.liu_west_delta = 0.99 ;
particle.liu_west_max_resampling_tries = 5000;
% Options for setting the weights in conditional particle filters.
particle.cpf_weights_method.amisanotristani = true;
particle.cpf_weights_method.murrayjonesparslow = false;
......@@ -329,6 +325,8 @@ options_.minimal_solving_periods = 1;
options_.endogenous_terminal_period = false;
options_.no_homotopy = false;
options_.simul.endval_steady = false;
options_.simul.first_simulation_period = dates();
options_.simul.last_simulation_period = dates();
options_.simul.homotopy_max_completion_share = 1;
options_.simul.homotopy_min_step_size = 1e-3;
......@@ -454,7 +452,7 @@ options_.mh_posterior_mode_estimation = false;
options_.smc_posterior_mode_estimation = false;
options_.prefilter = 0;
options_.presample = 0;
options_.prior_trunc = 1e-10;
options_.prior_trunc = 0;
options_.smoother = false;
options_.smoother_redux = false;
options_.posterior_max_subsample_draws = 1200;
......@@ -515,6 +513,11 @@ options_.posterior_sampler_options.dsmh.particles = 20000 ;
options_.posterior_sampler_options.dsmh.alpha0 = 0.2 ;
options_.posterior_sampler_options.dsmh.alpha1 = 0.3 ;
options_.posterior_sampler_options.dsmh.tau = 10 ;
% Liu and West online Sampler
options_.posterior_sampler_options.online.particles= 5000 ;
options_.posterior_sampler_options.online.liu_west_delta = 0.99 ;
options_.posterior_sampler_options.online.liu_west_max_resampling_tries = 5000 ;
options_.posterior_sampler_options.online.second_resampling = false;
options_.trace_plot_ma = 200;
options_.mh_autocorrelation_function_size = 30;
......@@ -658,6 +661,12 @@ particleswarm.UseParallel = false;
particleswarm.UseVectorized = false;
options_.particleswarm = particleswarm;
% One step
one_step.gradient = [] ;
one_step.hessian = [] ;
one_step.outer_product = 0 ;
options_.one_step= one_step ;
% prior analysis
options_.prior_mc = 20000;
......