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
Select Git revision
  • 4.3
  • 4.4
  • 4.5
  • 4.6
  • 5.x
  • 6.x
  • asm
  • aux_func
  • clang+openmp
  • dates-and-dseries-improvements
  • declare_vars_in_model_block
  • dmm
  • dragonfly
  • dynare_minreal
  • eigen
  • error_msg_undeclared_model_vars
  • estim_params
  • exo_steady_state
  • gpm-optimal-policy
  • julia
  • madysson
  • master
  • mex-GetPowerDeriv
  • penalty
  • separateM_
  • slice
  • sphinx-doc-experimental
  • static_aux_vars
  • time-varying-information-set
  • various_fixes
  • 3.062
  • 3.063
  • 4.0.0
  • 4.0.1
  • 4.0.2
  • 4.0.3
  • 4.0.4
  • 4.1-alpha1
  • 4.1-alpha2
  • 4.1.0
  • 4.1.1
  • 4.1.2
  • 4.1.3
  • 4.2.0
  • 4.2.1
  • 4.2.2
  • 4.2.3
  • 4.2.4
  • 4.2.5
  • 4.3.0
  • 4.3.1
  • 4.3.2
  • 4.3.3
  • 4.4-beta1
  • 4.4.0
  • 4.4.1
  • 4.4.2
  • 4.4.3
  • 4.5.0
  • 4.5.1
  • 4.5.2
  • 4.5.3
  • 4.5.4
  • 4.5.5
  • 4.5.6
  • 4.5.7
  • 4.6-beta1
  • 4.6.0
  • 4.6.0-rc1
  • 4.6.0-rc2
  • 4.6.1
  • 4.6.2
  • 4.6.3
  • 4.6.4
  • 4.7-beta1
  • 4.7-beta2
  • 4.7-beta3
  • 5.0
  • 5.0-rc1
  • 5.1
  • 5.2
  • 5.3
  • 5.4
  • 5.5
  • 6-beta1
  • 6-beta2
  • 6.0
  • 6.1
  • 6.2
  • 6.3
  • 6.4
91 results

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
  • ebenetce/dynare
  • chskcau/dynare-doc-fixes
28 results
Select Git revision
  • 4.3
  • 4.4
  • 4.5
  • 4.6
  • 5.x
  • aux_func
  • clang+openmp
  • dates-and-dseries-improvements
  • declare_vars_in_model_block
  • dmm
  • dragonfly
  • dynamic-striated
  • dynare_minreal
  • eigen
  • error_msg_undeclared_model_vars
  • estim_params
  • exceptions
  • exo_steady_state
  • filter_initial_state
  • gpm-optimal-policy
  • julia
  • master
  • mex-GetPowerDeriv
  • new_solve_algo_12_14
  • occbin
  • penalty
  • rmExtraExo
  • separateM_
  • slice
  • sphinx-doc-experimental
  • static_aux_vars
  • time-varying-information-set
  • various_fixes
  • 3.062
  • 3.063
  • 4.0.0
  • 4.0.1
  • 4.0.2
  • 4.0.3
  • 4.0.4
  • 4.1-alpha1
  • 4.1-alpha2
  • 4.1.0
  • 4.1.1
  • 4.1.2
  • 4.1.3
  • 4.2.0
  • 4.2.1
  • 4.2.2
  • 4.2.3
  • 4.2.4
  • 4.2.5
  • 4.3.0
  • 4.3.1
  • 4.3.2
  • 4.3.3
  • 4.4-beta1
  • 4.4.0
  • 4.4.1
  • 4.4.2
  • 4.4.3
  • 4.5.0
  • 4.5.1
  • 4.5.2
  • 4.5.3
  • 4.5.4
  • 4.5.5
  • 4.5.6
  • 4.5.7
  • 4.6-beta1
  • 4.6.0
  • 4.6.0-rc1
  • 4.6.0-rc2
  • 4.6.1
  • 4.6.2
  • 4.6.3
  • 4.6.4
  • 4.7-beta1
  • 4.7-beta2
  • 4.7-beta3
  • 5.0
  • 5.0-rc1
  • 5.1
  • 5.2
  • 5.3
85 results
Show changes
Showing
with 15870 additions and 8447 deletions
doc/manual/source/_static/report.png

87 KiB

......@@ -9,3 +9,7 @@
{% endfor %}
</ul>
{% endif %}
<hr />
<ul>
<li class="toctree-l1"><a href="{{pathto('genindex.html', 1)}}">Index</a></li>
</ul>
......@@ -6,68 +6,87 @@ Bibliography
* Abramowitz, Milton and Irene A. Stegun (1964): “Handbook of Mathematical Functions”, Courier Dover Publications.
* Adjemian, Stéphane, Matthieu Darracq Parriès and Stéphane Moyen (2008): “Towards a monetary policy evaluation framework”, *European Central Bank Working Paper*, 942.
* Adjemian, Stéphane and Michel Juillard (2025): “Stochastic Extended Path”, *Dynare Working Papers*, 84, CEPREMAP.
* Aguiar, Mark and Gopinath, Gita (2004): “Emerging Market Business Cycles: The Cycle is the Trend,” *NBER* Working Paper, 10734.
* Amisano, Gianni and Tristani, Oreste (2010): “Euro area inflation persistence in an estimated nonlinear DSGE model”, *Journal of Economic Dynamics and Control*, 34(10), 1837–1858.
* Andreasen, Martin M., Jesús Fernández-Villaverde, and Juan Rubio-Ramírez (2018): “The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications,” *Review of Economic Studies*, 85(1), pp. 1-49.
* Andreasen, Martin M., Jesús Fernández-Villaverde, and Juan Rubio-Ramírez (2018): “The Pruned State-Space System for Non-Linear DSGE Models: Theory and Empirical Applications,” *Review of Economic Studies*, 85(1), 1-49.
* Andrle, Michal and Miroslav Plašil (2018): “Econometrics with system priors,” *Economics Letters*, 172, 134-137.
* Andrews, Donald W.K (1991): “Heteroskedasticity and autocorrelation consistent covariance matrix estimation”, *Econometrica*, 59(3), 817–858.
* Backus, David K., Patrick J. Kehoe, and Finn E. Kydland (1992): “International Real Business Cycles,” *Journal of Political Economy*, 100(4), 745–775.
* Baxter, Marianne and Robert G. King (1999): “Measuring Business Cycles: Approximate Band-pass Filters for Economic Time Series,” *Review of Economics and Statistics*, 81(4), 575–593.
* Bini, Dario A., Guy Latouche, and Beatrice Meini (2002): “Solving matrix polynomial equations arising in queueing problems,” *Linear Algebra and its Applications*, 340, 225–244.
* Boehl, Gregor (2022): “DIME MCMC: A Swiss Army Knife for Bayesian Inference”, *SSRN No. 4250395*
* Born, Benjamin and Johannes Pfeifer (2014): “Policy risk and the business cycle”, *Journal of Monetary Economics*, 68, 68-85.
* Boucekkine, Raouf (1995): “An alternative methodology for solving nonlinear forward-looking models,” *Journal of Economic Dynamics and Control*, 19, 711–734.
* Brayton, Flint and Peter Tinsley (1996): “A Guide to FRB/US: A Macroeconomic Model of the United States,” *Finance and Economics Discussion Series*, 1996-42.
* Brayton, Flint, Morris Davis and Peter Tulip (2000): “Polynomial Adjustment Costs in FRB/US,” *Unpublished manuscript*.
* Brooks, Stephen P., and Andrew Gelman (1998): “General methods for monitoring convergence of iterative simulations,” *Journal of Computational and Graphical Statistics*, 7, pp. 434–455.
* Cardoso, Margarida F., R. L. Salcedo and S. Feyo de Azevedo (1996): “The simplex simulated annealing approach to continuous non-linear optimization,” *Computers & Chemical Engineering*, 20(9), 1065-1080.
* Chib, Siddhartha and Srikanth Ramamurthy (2010): “Tailored randomized block MCMC methods with application to DSGE models,” *Journal of Econometrics*, 155, 19–38.
* Christiano, Lawrence J., Martin Eichenbaum and Charles L. Evans (2005): “Nominal Rigidities and the Dynamic Effects of a Shock to Monetary Policy,” *Journal of Political Economy*, 113(1), 1–45.
* Christiano, Lawrence J., Mathias Trabandt, and Karl Walentin (2010): “DSGE Models for Monetary Policy Analysis,” In: *Handbook of Monetary Economics 3*, 285–367.
* Christiano, Lawrence J., Mathias Trabandt and Karl Walentin (2011): “Introducing financial frictions and unemployment into a small open economy model,” *Journal of Economic Dynamics and Control*, 35(12), 1999–2041.
* Christoffel, Kai, Günter Coenen and Anders Warne (2010): “Forecasting with DSGE models,” *ECB Working Paper Series*, 1185.
* Collard, Fabrice (2001): “Stochastic simulations with Dynare: A practical guide”.
* Collard, Fabrice and Michel Juillard (2001a): “Accuracy of stochastic perturbation methods: The case of asset pricing models,” *Journal of Economic Dynamics and Control*, 25, 979–999.
* Collard, Fabrice and Michel Juillard (2001b): “A Higher-Order Taylor Expansion Approach to Simulation of Stochastic Forward-Looking Models with an Application to a Non-Linear Phillips Curve,” *Computational Economics*, 17, 125–139.
* Corona, Angelo, M. Marchesi, Claudio Martini, and Sandro Ridella (1987): “Minimizing multimodal functions of continuous variables with the “simulated annealing” algorithm”, *ACM Transactions on Mathematical Software*, 13(3), 262–280.
* Del Negro, Marco and Franck Schorfheide (2004): “Priors from General Equilibrium Models for VARs”, *International Economic Review*, 45(2), 643–673.
* Corana, Angelo, M. Marchesi, Claudio Martini, and Sandro Ridella (1987): “Minimizing multimodal functions of continuous variables with the “simulated annealing” algorithm”, *ACM Transactions on Mathematical Software*, 13(3), 262–280.
* Cuba-Borda, Pablo, Luca Guerrieri, Matteo Iacoviello, and Molin Zhong (2019): “Likelihood evaluation of models with occasionally binding constraints,” Journal of Applied Econometrics, 34(7), 1073-1085
* Del Negro, Marco and Frank Schorfheide (2004): “Priors from General Equilibrium Models for VARs”, *International Economic Review*, 45(2), 643–673.
* Dennis, Richard (2007): “Optimal Policy In Rational Expectations Models: New Solution Algorithms”, *Macroeconomic Dynamics*, 11(1), 31–55.
* Duffie, Darrel and Kenneth J. Singleton (1993): “Simulated Moments Estimation of Markov Models of Asset Prices”, *Econometrica*, 61(4), 929-952.
* Durbin, J. and S. J. Koopman (2012), *Time Series Analysis by State Space Methods*, Second Revised Edition, Oxford University Press.
* Fair, Ray and John Taylor (1983): “Solution and Maximum Likelihood Estimation of Dynamic Nonlinear Rational Expectation Models,” *Econometrica*, 51, 1169–1185.
* Fernández-Villaverde, Jesús (2010): “The econometrics of DSGE models,” *SERIEs*, 1, 3–49.
* Fernández-Villaverde, Jesús and Juan Rubio-Ramírez (2004): “Comparing Dynamic Equilibrium Economies to Data: A Bayesian Approach,” *Journal of Econometrics*, 123, 153–187.
* Fernández-Villaverde, Jesús and Juan Rubio-Ramírez (2005): “Estimating Dynamic Equilibrium Economies: Linear versus Nonlinear Likelihood,” *Journal of Applied Econometrics*, 20, 891–910.
* Fernández-Villaverde, Jesús (2010): “The econometrics of DSGE models,” *SERIEs*, 1, 3–49.
* Ferris, Michael C. and Todd S. Munson (1999): “Interfaces to PATH 3.0: Design, Implementation and Usage”, *Computational Optimization and Applications*, 12(1), 207–227.
* Galí, Jordi (2015): “Monetary Policy, Inflation, and the Business Cycle,” 2nd Edition, Princeton University Press, Princeton.
* Geweke, John (1992): “Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments,” in J.O. Berger, J.M. Bernardo, A.P. Dawid, and A.F.M. Smith (eds.) Proceedings of the Fourth Valencia International Meeting on Bayesian Statistics, pp. 169–194, Oxford University Press.
* Geweke, John (1999): “Using simulation methods for Bayesian econometric models: Inference, development and communication,” *Econometric Reviews*, 18(1), 1–73.
* Giovannini, Massimo, Philipp Pfeiffer, and Marco Ratto (2021), “Efficient and robust inference of models with occasionally binding constraints,” Working Papers 2021-03, Joint Research Centre, European Commission
* Giordani, Paolo, Michael Pitt, and Robert Kohn (2011): “Bayesian Inference for Time Series State Space Models” in: *The Oxford Handbook of Bayesian Econometrics*, ed. by John Geweke, Gary Koop, and Herman van Dijk, Oxford University Press, 61–124.
* Guerrieri, Luca and Matteo Iacoviello (2015): “OccBin: A toolkit for solving dynamic models with occasionally binding constraints easily,” *Journal of Monetary Economics*, 70, 22–38.
* Goffe, William L., Gary D. Ferrier, and John Rogers (1994): “Global Optimization of Statistical Functions with Simulated Annealing,” *Journal of Econometrics*, 60(1/2), 65–100.
* Hansen, Lars P. (1982): “Large sample properties of generalized method of moments estimators,” Econometrica, 50(4), 1029–1054.
* Hansen, Nikolaus and Stefan Kern (2004): “Evaluating the CMA Evolution Strategy on Multimodal Test Functions”. In: *Eighth International Conference on Parallel Problem Solving from Nature PPSN VIII*, Proceedings, Berlin: Springer, 282–291.
* Harvey, Andrew C. and Garry D.A. Phillips (1979): “Maximum likelihood estimation of regression models with autoregressive-moving average disturbances,” *Biometrika*, 66(1), 49–58.
* Herbst, Edward and Schorfheide, Frank (2014): “Sequential Monte Carlo Sampling for DSGE Models,” *Journal of Applied Econometrics*, 29, 1073-1098.
* Herbst, Edward (2015): “Using the “Chandrasekhar Recursions” for Likelihood Evaluation of DSGE Models,” *Computational Economics*, 45(4), 693–705.
* Ireland, Peter (2004): “A Method for Taking Models to the Data,” *Journal of Economic Dynamics and Control*, 28, 1205–26.
* Iskrev, Nikolay (2010): “Local identification in DSGE models,” *Journal of Monetary Economics*, 57(2), 189–202.
* Judd, Kenneth (1996): “Approximation, Perturbation, and Projection Methods in Economic Analysis”, in *Handbook of Computational Economics*, ed. by Hans Amman, David Kendrick, and John Rust, North Holland Press, 511–585.
* Juillard, Michel (1996): “Dynare: A program for the resolution and simulation of dynamic models with forward variables through the use of a relaxation algorithm,” CEPREMAP, *Couverture Orange*, 9602.
* Kim, Jinill and Sunghyun Kim (2003): “Spurious welfare reversals in international business cycle models,” *Journal of International Economics*, 60, 471–500.
* Kanzow, Christian and Stefania Petra (2004): “On a semismooth least squares formulation of complementarity problems with gap reduction,” *Optimization Methods and Software*, 19, 507–525.
* Kim, Jinill and Sunghyun Kim (2003): “Spurious welfare reversals in international business cycle models,” *Journal of International Economics*, 60, 471–500.
* Kim, Jinill, Sunghyun Kim, Ernst Schaumburg, and Christopher A. Sims (2008): “Calculating and using second-order accurate solutions of discrete time dynamic equilibrium models,” *Journal of Economic Dynamics and Control*, 32(11), 3397–3414.
* Komunjer, Ivana and Ng, Serena (2011): ”Dynamic identification of dynamic stochastic general equilibrium models”, *Econometrica*, 79, 1995–2032.
* Koop, Gary (2003), *Bayesian Econometrics*, John Wiley & Sons.
* Koopman, S. J. and J. Durbin (2000): “Fast Filtering and Smoothing for Multivariate State Space Models,” *Journal of Time Series Analysis*, 21(3), 281–296.
* Koopman, S. J. and J. Durbin (2003): “Filtering and Smoothing of State Vector for Diffuse State Space Models,” *Journal of Time Series Analysis*, 24(1), 85–98.
* 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.
* Lubik, Thomas and Frank Schorfheide (2007): “Do Central Banks Respond to Exchange Rate Movements? A Structural Investigation,” *Journal of Monetary Economics*, 54(4), 1069–1087.
* 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.
* Pearlman, Joseph, David Currie, and Paul Levine (1986): “Rational expectations models with partial information,” *Economic Modelling*, 3(2), 90–105.
* Planas, Christophe, Marco Ratto and Alessandro Rossi (2015): “Slice sampling in Bayesian estimation of DSGE models”.
* Pfeifer, Johannes (2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models”.
* Pfeifer, Johannes (2014): “An Introduction to Graphs in Dynare”.
* Rabanal, Pau and Juan Rubio-Ramirez (2003): “Comparing New Keynesian Models of the Business Cycle: A Bayesian Approach,” Federal Reserve of Atlanta, *Working Paper Series*, 2003-30.
* Qu, Zhongjun and Tkachenko, Denis (2012): “Identification and frequency domain quasi-maximum likelihood estimation of linearized dynamic stochastic general equilibrium models“, *Quantitative Economics*, 3, 95–132.
* Rabanal, Pau and Juan Rubio-Ramírez (2003): “Comparing New Keynesian Models of the Business Cycle: A Bayesian Approach,” Federal Reserve of Atlanta, *Working Paper Series*, 2003-30.
* Raftery, Adrian E. and Steven Lewis (1992): “How many iterations in the Gibbs sampler?,” in *Bayesian Statistics, Vol. 4*, ed. J.O. Berger, J.M. Bernardo, A.P. * Dawid, and A.F.M. Smith, Clarendon Press: Oxford, pp. 763-773.
* Ratto, Marco (2008): “Analysing DSGE models with global sensitivity analysis”, *Computational Economics*, 31, 115–139.
* Schorfheide, Frank (2000): “Loss Function-based evaluation of DSGE models,” *Journal of Applied Econometrics*, 15(6), 645–670.
* Ratto, Marco and Iskrev, Nikolay (2011): “Identification Analysis of DSGE Models with DYNARE.“, *MONFISPOL* 225149.
* Ruge-Murcia, Francisco J. (2012): “Estimating nonlinear DSGE models by the simulated method of moments: With an application to business cycles“, *Journal of Economic Dynamics and Control*, 36, 914-938.
* Schmitt-Grohé, Stephanie and Martin Uríbe (2004): “Solving Dynamic General Equilibrium Models Using a Second-Order Approximation to the Policy Function,” *Journal of Economic Dynamics and Control*, 28(4), 755–775.
* Schnabel, Robert B. and Elizabeth Eskow (1990): “A new modified Cholesky algorithm,” *SIAM Journal of Scientific and Statistical Computing*, 11, 1136–1158.
* Schorfheide, Frank (2000): “Loss Function-based evaluation of DSGE models,” *Journal of Applied Econometrics*, 15(6), 645–670.
* Sims, Christopher A., Daniel F. Waggoner and Tao Zha (2008): “Methods for inference in large multiple-equation Markov-switching models,” *Journal of Econometrics*, 146, 255–274.
* Skoeld, Martin and Gareth O. Roberts (2003): “Density Estimation for the Metropolis-Hastings Algorithm,” *Scandinavian Journal of Statistics*, 30, 699–718.
* Smets, Frank and Rafael Wouters (2003): “An Estimated Dynamic Stochastic General Equilibrium Model of the Euro Area,” *Journal of the European Economic Association*, 1(5), 1123–1175.
* Stock, James H. and Mark W. Watson (1999). “Forecasting Inflation,”, *Journal of Monetary Economics*, 44(2), 293–335.
* Uhlig, Harald (2001): “A Toolkit for Analysing Nonlinear Dynamic Stochastic Models Easily,” in *Computational Methods for the Study of Dynamic Economies*, Eds. Ramon Marimon and Andrew Scott, Oxford University Press, 30–61.
* U.S. Census Bureau (2020): “X-13 ARIMA-SEATS Reference Manual, Version 1.1”, Center for Statistical Research and Methodology, U.S. Census Bureau, https://www.census.gov/data/software/x13as.html
* Villemot, Sébastien (2011): “Solving rational expectations models at first order: what Dynare does,” *Dynare Working Papers*, 2, CEPREMAP.
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2019 Dynare Team
# Copyright © 2018-2025 Dynare Team
#
# This file is part of Dynare.
#
......@@ -15,7 +15,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
# along with Dynare. If not, see <https://www.gnu.org/licenses/>.
import os
import sys
......@@ -31,20 +31,14 @@ templates_path = ['_templates']
html_static_path = ['_static']
mathjax_path = 'mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
master_doc = 'index'
project = u'Dynare'
copyright = u'2019, Dynare Team'
copyright = u'1996–2025 Dynare Team'
author = u'Dynare Team'
add_function_parentheses = False
# See ../utils/version.py, which is generated by autoconf
from version import version
from version import release
language = 'en'
exclude_patterns = []
......@@ -77,11 +71,15 @@ latex_elements = {
warningBorderColor={RGB}{255,50,50},OuterLinkColor={RGB}{34,139,34}, \
InnerLinkColor={RGB}{51,51,255},TitleColor={RGB}{51,51,255}',
'papersize': 'a4paper',
# Add support for the perpendicular symbol input as UTF-8
'preamble': r'''
\DeclareUnicodeCharacter{27C2}{\ensuremath{\perp}}
'''
}
latex_documents = [
(master_doc, 'dynare-manual.tex', u'Dynare Reference Manual',
u'Dynare team', 'manual'),
u'Dynare Team', 'manual'),
]
man_pages = [
......@@ -92,5 +90,5 @@ man_pages = [
def setup(app):
from dynare_dom import DynareDomain
from dynare_lex import DynareLexer
app.add_lexer("dynare", DynareLexer())
app.add_lexer("dynare", DynareLexer)
app.add_domain(DynareDomain)
......@@ -8,11 +8,25 @@
Dynare misc commands
####################
.. matcomm:: send_endogenous_variables_to_workspace ;
Puts the simulation results for the endogenous variables stored in ``oo_.endo_simul``
into vectors with the same name as the respective variables into the base workspace.
.. matcomm:: send_exogenous_variables_to_workspace ;
Puts the simulation results for the exogenous variables stored in ``oo_.exo_simul``
into vectors with the same name as the respective variables into the base workspace.
.. matcomm:: send_irfs_to_workspace ;
Puts the IRFs stored in ``oo_.irfs`` into vectors with the same name into the base workspace.
.. command:: prior_function(OPTIONS);
|br| Executes a user-defined function on parameter draws from the prior
Executes a user-defined function on parameter draws from the prior
distribution. Dynare returns the results of the computations for
all draws in an $ndraws$ by $n$ cell array named
all draws in an `ndraws` by :math:`n` cell array named
``oo_.prior_function_results``.
*Options*
......@@ -30,9 +44,11 @@ Dynare misc commands
Number of draws used for sampling. Default: 500.
|br|
.. command:: posterior_function(OPTIONS);
|br| Same as the :comm:`prior_function` command but for the
Same as the :comm:`prior_function` command but for the
posterior distribution. Results returned in
``oo_.posterior_function_results``.
......@@ -46,18 +62,23 @@ Dynare misc commands
See :opt:`prior_function_sampling_draws <sampling_draws = INTEGER>`.
|br|
.. command:: generate_trace_plots(CHAIN_NUMBER);
|br| Generates trace plots of the MCMC draws for all estimated
parameters and the posterior density in the specified Markov Chain
``CHAIN_NUMBER``.
Generates trace plots of the MCMC draws for all estimated
parameters and the posterior density for the specified Markov Chain(s)
``CHAIN_NUMBER``. If ``CHAIN_NUMBER`` is a vector of integers, the trace plots
will plot contains separate lines for each chain.
|br|
.. matcomm:: internals FLAG ROUTINENAME[.m]|MODFILENAME
|br| Depending on the value of ``FLAG``, the ``internals`` command
can be used to run unitary tests specific to a Matlab/Octave
Depending on the value of ``FLAG``, the ``internals`` command
can be used to run unitary tests specific to a MATLAB/Octave
routine (if available), to display documentation about a
Matlab/Octave routine, or to extract some informations about the
MATLAB/Octave routine, or to extract some informations about the
state of Dynare.
*Flags*
......@@ -79,27 +100,6 @@ Dynare misc commands
>> internals --test ../matlab/fr/ROUTINENAME
``--info``
Prints on screen the internal documentation of ROUTINENAME (if
this routine exists and if this routine has a texinfo internal
documentation header). The path to ``ROUTINENAME`` has to be
provided, if the routine is not in the current directory.
*Example*
::
>> internals --doc ../matlab/fr/ROUTINENAME
At this time, will work properly for only a small number
of routines. At the top of the (available) Matlab/Octave
routines a commented block for the internal documentation
is written in the GNU texinfo documentation format. This
block is processed by calling texinfo from
MATLAB. Consequently, texinfo has to be installed on your
machine.
``--display-mh-history``
Displays information about the previously saved MCMC draws
......@@ -114,7 +114,7 @@ Dynare misc commands
``--load-mh-history``
|br| Loads into the Matlab/Octave’s workspace informations
Loads into the MATLAB/Octave’s workspace informations
about the previously saved MCMC draws generated by a ``.mod``
file named MODFILENAME.
......@@ -167,24 +167,28 @@ Dynare misc commands
A ``1*Nblck`` array of doubles. Current acceptance ratios.
.. matcomm:: prior [options[, ...]];
|br|
.. matcomm:: prior [OPTIONS[ ...]];
Prints various informations about the prior distribution depending
on the options. If no options are provided, the command returns
the list of available options. Following options are available:
Prints information about the prior distribution given the provided
options. If no options are provided, the command returns the list of
available options.
``table``
*Options*
.. option:: table
Prints a table describing the marginal prior distributions
(mean, mode, std., lower and upper bounds, HPD interval).
``moments``
.. option:: moments
Computes and displays first and second order moments of the
endogenous variables at the prior mode (considering the
linearized version of the model).
``moments(distribution)``
.. option:: moments(distribution)
Computes and displays the prior mean and prior standard
deviation of the first and second moments of the endogenous
......@@ -193,7 +197,7 @@ Dynare misc commands
stored in the ``prior`` subfolder in a
``_endogenous_variables_prior_draws.mat`` file.
``optimize``
.. option:: optimize
Optimizes the prior density (starting from a random initial
guess). The parameters such that the steady state does not
......@@ -203,7 +207,7 @@ Dynare misc commands
defined over such regions, the optimization algorithm may fail
to converge to the true solution (the prior mode).
``simulate``
.. option:: simulate
Computes the effective prior mass using a Monte-Carlo. Ideally
the effective prior mass should be equal to 1, otherwise
......@@ -215,6 +219,148 @@ Dynare misc commands
:math:`p_A\neq p_B \leq 1` so that the prior mass of the
compared models are identical.
``plot``
.. option:: plot
Plots the marginal prior density.
|br|
.. matcomm:: search VARIABLENAME[ OPTION]
Searches all occurrences of a variable in a model, and prints the
equations where the variable appear in the command line window. If OPTION is
set to `withparamvalues`, the values of the parameters (if available) are
displayed instead of the name of the parameters. Requires the `json` command
line option to be set.
*Example*
Assuming that we already ran a `.mod` file and that the workspace has not
been cleaned after, we can search for all the equations containing variable `X`
::
>> search X
Y = alpha*X/(1-X)+e;
diff(X) = beta*(X(-1)-mX) + gamma1*Z + gamma2*R + u;
To replace the parameters with estimated or calibrated parameters:
::
>> search X withparamvalues
Y = 1.254634*X/(1-X)+e;
diff(X) = -0.031459*(X(-1)-mX) + 0.1*Z - 0.2*R + u;
|br|
.. matcomm:: dplot [OPTION VALUE[ ...]]
Plot expressions extracting data from different dseries objects.
*Options*
.. option:: --expression EXPRESSION
``EXPRESSION`` is a mathematical expression involving variables
available in the dseries objects, dseries methods, numbers or
parameters. All the referenced objects are supposed to be
available in the calling workspace.
.. option:: --dseries NAME
``NAME`` is the name of a dseries object from which the
variables involved in ``EXPRESSION`` will be extracted.
.. option:: --range DATE1:DATE2
This option is not mandatory and allows to plot the expressions
only over a sub-range. ``DATE1`` and ``DATE2`` must be dates as
defined in :ref:`dates in a mod file`.
.. option:: --style MATLAB_SCRIPT_NAME
Name of a Matlab script (without extension) containing Matlab
commands to customize the produced figure.
.. option:: --title MATLAB_STRING
Adds a title to the figure.
.. option:: --with-legend
Prints a legend below the produced plot.
*Remarks*
- More than one --expression argument is allowed, and they must come first.
- For each dseries object we plot all the expressions. We use two
nested loops, the outer loop is over the dseries objects and the
inner loop over the expressions. This determines the ordering of
the plotted lines.
- All dseries objects must be defined in the calling workspace, if a
dseries object is missing the routine throws a warning (we only
build the plots for the available dseries objects), if all dseries
objects are missing the routine throws an error.
- If the range is not provided, the expressions cannot involve leads or lags.
*Example*
::
>> toto = dseries(randn(100,3), dates('2000Q1'), {'x','y','z'});
>> noddy = dseries(randn(100,3), dates('2000Q1'), {'x','y','z'});
>> b = 3;
>> dplot --expression 2/b*cumsum(x/y(-1)-1) --dseries toto --dseries noddy --range 2001Q1:2024Q1 --title 'This is my plot'
will produce plots for ``2/b*cumsum(x/y(-1)-1)``, where ``x`` and
``y`` are variables in dseries objects ``toto`` and ``noddy``, in
the same figure.
.. command:: set_dynare_threads(NAME_OF_MEX_FILE,INTEGER);
A NAME_OF_MEX_FILE and INTEGER pair that can be used to set the number of
parallel threads employed during the execution of .mex files. To get the number
of logical cores `n` available, you can run ``n=numprocs``.
Available NAME_OF_MEX_FILE options are:
``'sparse_hessian_times_B_kronecker_C'``
.mex file used during computation of second-order solutions and in
`identification`. Default number of threads: number of logical cores.
``'local_state_space_iteration_2'``
.mex file used during nonlinear filtering at `order=2` without
`k_order_solver` or with `pruning`. Default number of threads:
number of logical cores.
``'local_state_space_iteration_3'``
.mex file used during nonlinear filtering at `order=3` without
`k_order_solver` or with `pruning`. Default number of threads:
number of logical cores.
``'local_state_space_iteration_k'``
.mex file used during nonlinear filtering at `order>3` (without `pruning`)
or at `order=3` with `k_order_solver` and without `pruning`. Default number of threads: 1.
``'perfect_foresight_problem'``
.mex file used during perfect foresight simulations. Default number of threads:
number of logical cores.
``'k_order_perturbation'``
.mex file used for perturbation solutions with `k_order_solver`. Default number of threads:
half the number of logical cores, but at least 1.
......@@ -51,8 +51,38 @@ description, please refer to the comments inside the files themselves.
Small open economy RBC model with shocks to the growth trend,
presented in *Aguiar and Gopinath (2004)*.
``Gali_2015.mod``
Basic New Keynesian model of *Galí (2015)*, Chapter 3 showing how to
i) use "system prior"-type prior restrictions as in *Andrle and Plašil (2018)*
and ii) run prior/posterior-functions.
``NK_baseline.mod``
Baseline New Keynesian Model estimated in *Fernández-Villaverde
(2010)*. It demonstrates how to use an explicit steady state file
to update parameters and call a numerical solver.
``Occbin_example.mod``
RBC model with two occasionally binding constraints. Demonstrates
how to set up Occbin.
``Ramsey_Example.mod``
File demonstrating how to conduct optimal policy experiments in a
simple New Keynesian model either under commitment (Ramsey) or using
optimal simple rules (OSR)
``Ramsey_steady_file.mod``
File demonstrating how to conduct optimal policy experiments in a
simple New Keynesian model under commitment (Ramsey) with a user-defined
conditional steady state file
``rbc_irf_matching.mod``
Baseline RBC model with government spending shocks estimated via impulse response function (IRF) matching.
Both Frequentist (Maximum Likelihood) and Bayesian (Slice Sampling) approaches are presented.
Additionally, it is shown how to estimate an AR(2)-process
by working with the roots of the autoregressive process instead of the coefficients
The Dynare Reference Manual, version 4.6-unstable.
==================================================
The Dynare Reference Manual, version |version|
==============================================
Currently the development team of Dynare is composed of:
* Stéphane Adjemian
* Stéphane Adjemian (Le Mans Université, Gains)
* Michel Juillard (Banque de France)
* Sumudu Kankanamge (Le Mans Université and CEPREMAP)
* Frédéric Karamé (Le Mans Université, Gains and CEPREMAP)
* Junior Maih (Norges Bank)
* Willi Mutschler (University of Tübingen)
* Johannes Pfeifer (University of the Bundeswehr Munich)
* Marco Ratto (European Commission, Joint Research Centre - JRC)
* Normann Rion (CEPREMAP)
* Sébastien Villemot (CEPREMAP)
The following people used to be members of the team:
* Houtan Bastani
* Michel Juillard
* Frédéric Karamé
* Junior Maih
* Abdeljabar Benzougar
* Alejandro Buesa
* Fabrice Collard
* Assia Ezzeroug
* Dóra Kocsis
* Stéphane Lhuissier
* Ferhat Mihoubi
* Willi Mutschler
* Johannes Pfeifer
* Marco Ratto
* Sébastien Villemot
* George Perendia
Copyright © 1996-2019, 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.
A copy of the license can be found at `http://www.gnu.org/licenses/fdl.txt <http://www.gnu.org/licenses/fdl.txt>`_.
Table of contents:
A copy of the license can be found at `https://www.gnu.org/licenses/fdl.txt <https://www.gnu.org/licenses/fdl.txt>`__.
.. toctree::
:numbered:
......
......@@ -7,24 +7,36 @@ Installation and configuration
Software requirements
=====================
Packaged versions of Dynare are available for Windows 7/8/10,
`Debian GNU/Linux <http://www.debian.org/>`_, `Ubuntu`_ and macOS 10.8
or later. Dynare should work on other systems, but some compilation
steps are necessary in that case.
Packaged versions of Dynare are available for Windows (10 and 11), several
GNU/Linux distributions (Debian, Ubuntu, Linux Mint, Arch Linux), macOS (15
“Sequoia”), and FreeBSD. Dynare should work on other systems, but some
compilation steps are necessary in that case.
In order to run Dynare, you need one of the following:
* MATLAB version 7.9 (R2009b) or above;
* GNU Octave version 4.2.1 or above, with the statistics package from `Octave-Forge`_.
* MATLAB, any version ranging from 9.8 (R2020a) to 25.1 (R2025a);
* GNU Octave, any version ranging from 7.1.0 to 10.2.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.
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
* If under GNU Octave, the following `Octave-Forge`_ packages: ``optim, io,
control``.
* 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``.
Installation of Dynare
......@@ -40,9 +52,9 @@ worry about your own files.
On Windows
----------
Execute the automated installer called ``dynare-4.x.y-win.exe`` (where
``4.x.y`` is the version number), and follow the instructions. The
default installation directory is ``c:\dynare\4.x.y``.
Execute the automated installer called ``dynare-x.y-win.exe`` (where
``x.y`` is the version number), and follow the instructions. The
default installation directory is ``c:\dynare\x.y``.
After installation, this directory will contain several
sub-directories, among which are ``matlab``, ``mex`` and ``doc``.
......@@ -54,41 +66,99 @@ Note that you can have several versions of Dynare coexisting (for
example in ``c:\dynare``), as long as you correctly adjust your path
settings (see see :ref:`words-warning`).
Also note that it is possible to do a silent installation, by passing the
``/S`` flag to the installer on the command line. This can be useful when
doing an unattended installation of Dynare on a computer pool.
On GNU/Linux
------------
On Debian, Ubuntu and Linux Mint, the Dynare package can be installed with:
``apt install dynare``. This will give a fully-functional Dynare installation
usable with Octave. If you have MATLAB installed, you should also do: ``apt
install dynare-matlab`` (under Debian, this package is in the ``contrib``
section). Documentation can be installed with ``apt install dynare-doc``. The
status of those packages can be checked at those pages:
* `Package status in Debian`_
* `Package status in Ubuntu`_
* `Package status in Linux Mint`_
On Debian GNU/Linux and Ubuntu
------------------------------
On Arch Linux, the Dynare package is not in the official repositories, but is
available in the `Arch User Repository`_. The needed sources can be
downloaded from the `package status in Arch Linux`_.
Please refer to the `Dynare wiki`_ for detailed instructions.
There is also a Dynare package for openSUSE, see the `package status in
openSUSE`_.
Dynare will be installed under ``/usr/lib/dynare``. Documentation will
be under ``/usr/share/doc/dynare-doc``.
Dynare will be installed under ``/usr/lib/dynare`` (or ``/usr/lib64/dynare`` on
openSUSE). Documentation will be under ``/usr/share/doc/dynare`` (only on
Debian, Ubuntu and Linux Mint).
On macOS
--------
To install Dynare for use with Matlab, execute the automated installer
called ``dynare-4.x.y.pkg`` (where *4.x.y* is the version number), and
follow the instructions. The default installation directory is
``/Applications/Dynare/4.x.y`` (please refer to the `Dynare wiki`_ for
detailed instructions).
.. warning::
After installation, this directory will contain several
sub-directories, among which are ``matlab``, ``mex`` and ``doc``.
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
^^^^^^^^^^^
To install Dynare for use with MATLAB, execute the automated installer called
``dynare-x.y-arch.pkg`` (where *x.y* is the version number and *arch* is either arm64 for Apple Silicon or x86_64 for Intel architectures),
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``.
It is recommended to install the Xcode Command Line Tools (this is an Apple product)
and GCC via Homebrew_ (see :ref:`prerequisites-macos`).
To deinstall Dynare, simply delete the folder where you installed the program. The package installer does
not put any files anywhere else in the system.
With Octave
^^^^^^^^^^^
We don’t provide Dynare packages for macOS with Octave support, but there is a
Dynare package with Octave support in Homebrew_.
Once Homebrew_ is installed, run a terminal and install Dynare (and Octave) by
typing the following::
brew install dynare
Note that several versions of Dynare can coexist (by default in
``/Applications/Dynare``), as long as you correctly adjust your path
settings (see :ref:`words-warning`).
Then open Octave by running the following in the same terminal::
To install Dynare for Octave, first install Homebrew following the
instructions on their site: `https://brew.sh/
<https://brew.sh/>`_. Then install Octave, issuing the command ``brew
install octave`` at the Terminal prompt. You can then install the
latest stable version of Dynare by typing ``brew install dynare`` at
the Terminal prompt. You can also pass options to the installation
command. These options can be viewed by typing ``brew info dynare`` at
the Terminal prompt.
octave --gui
Finally, at the Octave prompt, install some add-ons (you only have to do it
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
----------
A `FreeBSD port for Dynare <https://www.freshports.org/science/dynare/>`__ is
available. It can be installed with::
pkg install dynare
For other systems
-----------------
......@@ -98,7 +168,7 @@ unpack it somewhere.
Then you will need to recompile the pre-processor and the dynamic
loadable libraries. Please refer to `README.md
<https://git.dynare.org/Dynare/dynare/blob/master/README.md>`_.
<https://git.dynare.org/Dynare/dynare/blob/master/README.md>`__.
.. _compil-install:
......@@ -108,29 +178,60 @@ Compiler installation
Prerequisites on Windows
------------------------
There is no prerequisites on Windows. Dynare now ships a compilation
There are no prerequisites on Windows. Dynare now ships a compilation
environment that can be used with the :opt:`use_dll` option.
Prerequisites on Debian GNU/Linux and Ubuntu
--------------------------------------------
Prerequisites on GNU/Linux
--------------------------
Users of MATLAB under GNU/Linux need a working compilation
environment installed. If not already present, it can be installed via
``apt install build-essential``.
Users of MATLAB under GNU/Linux need a working compilation environment
installed. Under Debian, Ubuntu or Linux Mint, it can be installed via ``apt
install build-essential``.
Users of Octave under GNU/Linux should install the package for MEX file
compilation (under Debian or Ubuntu, it is called ``liboctave-dev``).
compilation (under Debian, Ubuntu or Linux Mint, it can be done via ``apt
install liboctave-dev``).
.. _prerequisites-macos:
Prerequisites on macOS
----------------------
[TO BE UPDATED]
With MATLAB
^^^^^^^^^^^
Dynare now ships a compilation environment that can be used with the
:opt:`use_dll` option. To install this environment correctly, the Dynare
installer ensures that the Xcode Command Line Tools (an Apple product) have
been installed on a system folder. To install the Xcode Command Line Tools
yourself, simply type ``xcode-select --install`` into the terminal
(``/Applications/Utilities/Terminal.app``) prompt.
Additionally, to make MATLAB aware that you agree to the terms of Xcode, run the following two commands in the Terminal prompt::
CLT_VERSION=$(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version | awk '{print $2}' | cut -d'.' -f1-2)
defaults write com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense "${CLT_VERSION}"
defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense
Otherwise you will see a warning that Xcode is installed, but its license has not been accepted.
You can check this e.g. by running the following command in the MATLAB command window::
If you are using MATLAB under macOS, you should install the latest
version of XCode: `see instructions on the Dynare wiki
<https://git.dynare.org/Dynare/dynare/wikis/Install-on-MacOS>`_.
mex -setup
Moreover, we recommend making use of optimized compilation flags when using :opt:`use_dll` and for this you need to install GCC via Homebrew_::
brew install gcc
If you already have installed GCC, Dynare will automatically prefer it for :opt:`use_dll`
if the binaries are either in ``/opt/homebrew/bin`` on Apple Silicon (arm64) or in ``/usr/local/bin`` on Intel (x86_64) systems.
Otherwise, it will fall back to Clang in ``/usr/bin/clang``, which works both on arm64 and x86_64 systems.
With Octave
^^^^^^^^^^^
The compiler can be installed via Homebrew_. In a terminal, run::
brew install gcc
Configuration
=============
......@@ -147,20 +248,20 @@ installation to MATLAB path. You have two options for doing that:
* Using the ``addpath`` command in the MATLAB command window:
Under Windows, assuming that you have installed Dynare in the
standard location, and replacing ``4.x.y`` with the correct version
standard location, and replacing ``x.y`` with the correct version
number, type::
>> addpath c:/dynare/4.x.y/matlab
>> addpath c:/dynare/x.y/matlab
Under Debian GNU/Linux or Ubuntu, type::
Under GNU/Linux, type::
>> addpath /usr/lib/dynare/matlab
Under macOS, assuming that you have installed Dynare in the standard
location, and replacing ``4.x.y`` with the correct version number,
location, and replacing ``x.y`` with the correct version number,
type::
>> addpath /Applications/Dynare/4.x.y/matlab
>> addpath /Applications/Dynare/x.y/matlab
MATLAB will not remember this setting next time you run it, and you
will have to do it again.
......@@ -174,26 +275,27 @@ installation to MATLAB path. You have two options for doing that:
MATLAB will remember this setting next time you run it.
For GNU Octave
--------------
For Octave
----------
You need to add the ``matlab`` subdirectory of your Dynare
installation to Octave path, using the ``addpath`` at the Octave
command prompt.
Under Windows, assuming that you have installed Dynare in the standard
location, and replacing “*4.x.y*” with the correct version number,
location, and replacing “*x.y*” with the correct version number,
type::
octave:1> addpath c:/dynare/4.x.y/matlab
octave:1> addpath c:/dynare/x.y/matlab
Under Debian, Ubuntu or Linux Mint, there is no need to use the ``addpath``
command; the packaging does it for you. Under Arch Linux, you need to do::
Under Debian GNU/Linux or Ubuntu, there is no need to use the
``addpath`` command; the packaging does it for you.
octave:1> addpath /usr/lib/dynare/matlab
Under macOS, assuming that you have installed Dynare and Octave via
Homebrew, type::
Under macOS, assuming you have installed Dynare via Homebrew_::
octave:1> addpath /usr/local/opt/dynare/lib/dynare/matlab
octave:1> addpath /usr/local/lib/dynare/matlab
If you don’t want to type this command every time you run Octave, you
can put it in a file called ``.octaverc`` in your home directory
......@@ -232,7 +334,18 @@ Dynare unusable.
end up with a non optimal or un-usable installation of Dynare.
.. _Ubuntu: http://www.ubuntu.com/
.. _Package status in Debian: https://packages.debian.org/sid/dynare
.. _Package status in Ubuntu: https://launchpad.net/ubuntu/+source/dynare
.. _Package status in Linux Mint: https://community.linuxmint.com/software/view/dynare
.. _Package status in Arch Linux: https://aur.archlinux.org/packages/dynare/
.. _Package status in openSUSE: https://software.opensuse.org/package/dynare
.. _Arch User Repository: https://wiki.archlinux.org/index.php/Arch_User_Repository
.. _Dynare website: https://www.dynare.org/
.. _Dynare wiki: https://git.dynare.org/Dynare/dynare/wikis
.. _Octave-Forge: http://octave.sourceforge.io/
.. _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>`__.
......@@ -62,16 +62,9 @@ to bear the concomitant performance loss.
The development of Dynare is mainly done at `CEPREMAP`_ by a core team
of researchers who devote part of their time to software
development. Currently the development team of Dynare is composed of
Stéphane Adjemian (Université du Maine, Gains and Cepremap), Houtan
Bastani (Cepremap), Michel Juillard (Banque de France), Frédéric
Karamé (Université du Maine, Gains and Cepremap), Junior Maih (Norges
Bank), Ferhat Mihoubi (Université Paris-Est Créteil, Érudite and
Cepremap), Johannes Pfeifer (University of Cologne), Marco Ratto
(European Commission, Joint Research Centre - JRC) and Sébastien
Villemot (Cepremap). Increasingly, the developer base is expanding, as
tools developed by researchers outside of Cepremap are integrated into
Dynare. Financial support is provided by Cepremap, Banque de France
development. Increasingly, the developer base is expanding, as
tools developed by researchers outside of CEPREMAP are integrated into
Dynare. Financial support is provided by CEPREMAP, Banque de France
and DSGE-net (an international research network for DSGE modeling).
Interaction between developers and users of Dynare is central to the
......@@ -101,25 +94,24 @@ Citing Dynare in your research
You should cite Dynare if you use it in your research. The
recommended way todo this is to cite the present manual, as:
Stéphane Adjemian, Houtan Bastani, Michel Juillard, Frédéric
Karamé, Junior Maih, Ferhat Mihoubi, George Perendia, Johannes Pfeifer, Marco
Ratto and Sébastien Villemot (2011), “Dynare: Reference Manual,
Version 4,” *Dynare Working Papers*, 1, CEPREMAP
Stéphane Adjemian, Michel Juillard, Frédéric Karamé, Willi Mutschler,
Johannes Pfeifer, Marco Ratto, Normann Rion and Sébastien Villemot (2024),
“Dynare: Reference Manual, Version 6,” *Dynare Working Papers*, 80, CEPREMAP
For convenience, you can copy and paste the following into your BibTeX file:
.. code-block:: bibtex
@TechReport{Adjemianetal2011,
author = {Adjemian, St\'ephane and Bastani, Houtan and Juillard, Michel and
Karam\'e, Fr\'ederic and Maih, Junior and Mihoubi, Ferhat and
Perendia, George and Pfeifer, Johannes and Ratto, Marco and
Villemot, S\'ebastien},
title = {Dynare: Reference Manual Version 4},
year = {2011},
@TechReport{Adjemianetal2024,
author = {Adjemian, St\'ephane and Juillard, Michel and
Karam\'e, Fr\'ederic and Mutschler, Willi and
Pfeifer, Johannes and Ratto, Marco and
Rion, Normann and Villemot, S\'ebastien},
title = {Dynare: Reference Manual, Version 6},
year = {2024},
institution = {CEPREMAP},
type = {Dynare Working Papers},
number = {1},
number = {80},
}
If you want to give a URL, use the address of the Dynare website:
......@@ -127,11 +119,11 @@ https://www.dynare.org.
.. _MATLAB: http://www.mathworks.com/products/matlab/
.. _GNU Octave: http://www.octave.org/
.. _CEPREMAP: http://www.cepremap.fr/
.. _MATLAB: https://www.mathworks.com/products/matlab/
.. _GNU Octave: https://www.octave.org/
.. _CEPREMAP: https://www.cepremap.fr/
.. _web forum: https://forum.dynare.org/
.. _official Dynare website: http://www.dynare.org/
.. _official Dynare website: https://www.dynare.org/
.. _Dynare wiki: https://git.dynare.org/Dynare/dynare/wikis
.. _Dynare forums: https://forum.dynare.org/
.. _Git repository: https://git.dynare.org/Dynare/dynare
......@@ -19,8 +19,7 @@ paper. Though Dynare provides a subset of options available through
using the options available in the ``PGFPLOTS/TikZ`` manual. You can
either do this manually or by passing the options to
:opt:`miscTikzAxisOptions <miscTikzAxisOptions, STRING>` or
:opt:`graphMiscTikzAddPlotOptions <graphMiscTikzAddPlotOptions,
STRING>`.
:opt:`graphMiscTikzAddPlotOptions <graphMiscTikzAddPlotOptions, STRING>`.
Reports are created and modified by calling methods on class
objects. The objects are hierarchical, with the following order (from
......@@ -28,7 +27,7 @@ highest to lowest): ``Report``, ``Page``, ``Section``,
``Graph/Table/Vspace``, ``Series``. For simplicity of syntax, we
abstract away from these classes, allowing you to operate directly on
a ``Report`` object, while maintaining the names of these classes in
the ``Report`` Class methods you will use.
the ``Report`` class methods you will use.
The report is created sequentially, command by command, hence the
order of the commands matters. When an object of a certain hierarchy
......@@ -39,8 +38,8 @@ added to this ``Page`` until another ``Page`` is added to the report
(via :repmeth:`addPage`). This will become more clear with the example
at the end of the section.
Options to the methods are passed differently than those to Dynare
commands. They take the form of named options to Matlab functions
Options to methods are passed differently than those to Dynare
commands. They take the form of named options to MATLAB functions
where the arguments come in pairs
(e.g. ``function_name(`option_1_name', `option_1_value',
`option_2_name', `option_2_value', ...)``, where ``option_X_name`` is
......@@ -69,6 +68,11 @@ and a clarifying example.
* Windows: the result of findtexmf ``--file-type=exe pdflatex``.
* macOS and Linux: the result of ``which pdflatex``.
.. option:: directory, FILENAME
The path to the directory you want the report created in. Default:
current directory.
.. option:: showDate, BOOLEAN
Display the date and time when the report was
......@@ -83,6 +87,11 @@ and a clarifying example.
The valid :math:`\text{\LaTeX}` code to be included in the report before
``\begin{document}``. Default: ``empty``.
.. option:: maketoc, BOOLEAN
Whether or not to make the table of contents. One entry is made per
page containing a title. Default: ``false``.
.. option:: margin, DOUBLE
The margin size. Default: ``2.5``.
......@@ -99,6 +108,15 @@ and a clarifying example.
Paper size. Default: ```a4'``.
.. option:: reportDirName, FILENAME
The name of the folder in which to store the component parts of the
report (preamble, document, end). Default: ``tmpRepDir``.
.. option:: showDate, BOOLEAN
Display the date and time when the report was compiled. Default: true.
.. option:: showOutput, BOOLEAN
Print report creation progress to screen. Shows you the page
......@@ -127,18 +145,19 @@ and a clarifying example.
page. Alows the user to create a page to be included in the
report by passing :math:`\text{\LaTeX}` code directly. If this option is
passed, the page itself will be saved in the :opt:`pageDirName
<pageDirName, STRING>` directory in the form ``page_X.tex``
<pageDirName, FILENAME>` directory in the form ``page_X.tex``
where X refers to the page number. Default: ``empty``.
.. option:: orientation, `landscape' | `portrait'
See :opt:`orientation <orientation, `landscape' | `portrait'>`.
.. option:: pageDirName, STRING
.. option:: pageDirName, FILENAME
The name of the folder in which to store this page. Only used
when the :opt:`latex <latex, STRING>` command is
passed. Default: ``tmpRepDir``.
The name of the folder in which to store this page. Directory given is
relative to the `directory` option of the report class. Only used when
the :opt:`latex <latex, STRING>` command is passed. Default:
``tmpRepDir``.
.. option:: paper, `a4' | `letter'
......@@ -201,9 +220,10 @@ and a clarifying example.
graphed line(s). 'L'`` means that there is an axis to the left
and bottom of the graphed line(s). Default: ```box'``.
.. option:: graphDirName, STRING
.. option:: graphDirName, FILENAME
The name of the folder in which to store this figure. Default:
The name of the folder in which to store this figure. Directory given
is relative to the `directory` option of the report class. Default:
``tmpRepDir``.
.. option:: graphName, STRING
......@@ -224,17 +244,18 @@ and a clarifying example.
Whether or not to display the legend.
Unless you use the :opt:`graphLegendName <graphLegendName,
STRING>` option, the name displayed in the legend is the tex
Unless you use the :opt:`graphLegendName <graphLegendName, STRING>`
option, the name displayed in the legend is the tex
name associated with the ``dseries``. You can modify this tex
name by using :dsermeth:`tex_rename <B =
tex_rename>`. Default: ``false``.
name by using :dsermeth:`tex_rename <B = tex_rename>`.
Default: ``false``.
.. option:: legendAt, NUMERICAL_VECTOR
The coordinates for the legend location. If this option is
passed, it overrides the :opt:`legendLocation <legendLocation,
OPTION>` option. Must be of size ``2``. Default: ``empty``.
passed, it overrides the :opt:`legendLocation
<legendLocation, OPTION>` option. Must be of size ``2``.
Default: ``empty``.
.. option:: showLegendBox, BOOLEAN
......@@ -353,7 +374,7 @@ and a clarifying example.
Whether or not to write a CSV file with only the plotted
data. The file will be saved in the directory specified by
:opt:`graphDirName <graphDirName, STRING>` with the same base
:opt:`graphDirName <graphDirName, FILENAME>` with the same base
name as specified by :opt:`graphName <graphName, STRING>` with
the ending ``.csv``. Default: ``false``.
......@@ -376,8 +397,8 @@ and a clarifying example.
.. option:: xTicks, NUMERICAL_VECTOR
Used only in conjunction with :opt:`xTickLabels <xTickLabels,
CELL_ARRAY_STRINGS | `ALL'>`, this option denotes the
Used only in conjunction with :opt:`xTickLabels
<xTickLabels, CELL_ARRAY_STRINGS | `ALL'>`, this option denotes the
numerical position of the label along the x-axis. The
positions begin at ``1``. Default: the indices associated with
the first and last dates of the ``dseries`` and, if passed,
......@@ -393,7 +414,7 @@ and a clarifying example.
.. option:: xTickLabelAnchor, STRING
Where to anchor the x tick label. Default: ```south'``.
Where to anchor the x tick label. Default: ```east'``.
.. option:: xTickLabelRotation, DOUBLE
......@@ -414,11 +435,11 @@ and a clarifying example.
.. option:: yTickLabelFixed, BOOLEAN
Round the y tick labels to a fixed number of decimal places,
given by ``yTickLabelPrecision``. Default: ``.true``.
given by ``yTickLabelPrecision``. Default: ``true``.
.. option:: yTickLabelPrecision, INTEGER
The precision with which to report the ``yTickLabel``. Default: ``1``.
The precision with which to report the ``yTickLabel``. Default: ``0``.
.. option:: yTickLabelScaled, BOOLEAN
......@@ -480,9 +501,10 @@ and a clarifying example.
See :opt:`seriesToUse <seriesToUse, CELL_ARRAY_STRINGS>`.
.. option:: tableDirName, STRING
.. option:: tableDirName, FILENAME
The name of the folder in which to store this table. Default:
The name of the folder in which to store this table. Directory given is
relative to the `directory` option of the report class. Default:
``tmpRepDir``.
.. option:: tableName, STRING
......@@ -496,8 +518,8 @@ and a clarifying example.
.. option:: titleFormat, STRING
Same as :opt:`titleFormat <titleFormat, STRING |
CELL_ARRAY_STRINGS>`, just for tables. Default: ``\large``.
Same as :opt:`titleFormat <titleFormat, STRING | CELL_ARRAY_STRINGS>`,
just for tables. Default: ``\large``.
.. option:: vlineAfter, dates | CELL_ARRAY_DATES
......@@ -519,8 +541,9 @@ and a clarifying example.
Whether or not to write a CSV file containing the data
displayed in the table. The file will be saved in the
directory specified by :opt:`tableDirName <tableDirName,
STRING>` with the same base name as specified by
directory specified by :opt:`tableDirName
<tableDirName, FILENAME>` with the same base name as
specified by
:opt:`tableName <tableName, STRING>` with the ending
``.csv``. Default: ``false``.
......@@ -680,9 +703,10 @@ and a clarifying example.
.. option:: tableShowMarkers, BOOLEAN
In a Table, if ``true``, surround each cell with brackets and
color it according to :opt:`tableNegColor <tableNegColor,
LATEX_COLOR>` and :opt:`tablePosColor <tablePosColor,
LATEX_COLOR>`. No effect for graphs. Default: ``false``.
color it according to :opt:`tableNegColor
<tableNegColor, LATEX_COLOR>` and :opt:`tablePosColor
<tablePosColor, LATEX_COLOR>`. No effect for graphs.
Default: ``false``.
.. option:: tableAlignRight, BOOLEAN
......@@ -708,8 +732,8 @@ and a clarifying example.
.. option:: tablePrecision, INTEGER
The number of decimal places to report in the table
data. Default: the value set by :opt:`precision <precision,
INTEGER>`.
data. Default: the value set by :opt:`precision
<precision, INTEGER>`.
.. option:: tablePosColor, LATEX_COLOR
......@@ -790,8 +814,8 @@ and a clarifying example.
|br| Compiles the report written by ``write`` into a ``pdf``
file. If the report has not already been written (determined by
the existence of the file specified by :opt:`filename <fileName,
FILENAME>`, ``write`` is called.
the existence of the file specified by :opt:`filename
<fileName, FILENAME>`, ``write`` is called.
*Options*
......@@ -807,13 +831,13 @@ and a clarifying example.
Print the compiler output to the screen. Useful for debugging
your code as the :math:`\text{\LaTeX}` compiler hangs if there is a
problem. Default: the value of :opt:`showOutput <showOutput,
BOOLEAN>`.
problem. Default: the value of :opt:`showOutput
<showOutput, BOOLEAN>`.
.. option:: showReport, BOOLEAN
Open the compiled report (works on Windows and macOS on
Matlab). Default: ``true``.
MATLAB). Default: ``true``.
*Example*
......@@ -831,41 +855,46 @@ bottom of the page displays a centered table::
rep = report();
%% Page 1
rep = rep.addPage(`title', {`My Page Title', `My Page Subtitle'}, ...
`titleFormat', {`\large\bfseries', `\large'});
rep.addPage('title', {'My Page Title', 'My Page Subtitle'}, ...
'titleFormat', {'\large\bfseries', '\large'});
% Section 1
rep = rep.addSection(`cols', 2);
rep = rep.addGraph(`title', `Graph (1,1)', `showLegend', true, ...
`xrange', dates(`2007q1'):dates(`2013q4'), ...
`shade', dates(`2012q2'):dates(`2013q4'));
rep = rep.addSeries(`data', dsq{`SERIES1'}, `graphLineColor', `blue', ...
`graphLineWidth', 1);
rep = rep.addSeries(`data', dsq{`SERIES2'}, `graphLineColor', `green', ...
`graphLineStyle', '--', `graphLineWidth', 1.5);
rep = rep.addGraph(`title', `Graph (1,2)', `showLegend', true, ...
`xrange', dates(`2007q1'):dates(`2013q4'), ...
`shade', dates(`2012q2'):dates(`2013q4'));
rep = rep.addSeries(`data', dsq{`SERIES3'}, `graphLineColor', `blue', ...
`graphLineWidth', 1);
rep = rep.addSeries(`data', dsq{`SERIES4'}, `graphLineColor', `green', ...
`graphLineStyle', '--', `graphLineWidth', 1.5);
rep.addSection('cols', 2);
rep.addGraph('title', 'Graph Column 1', 'showLegend', true, ...
'xrange', dates('2007q1'):dates('2013q4'), ...
'shade', dates('2012q2'):dates('2013q4'));
rep.addSeries('data', dsq{'GROWTH_US'}, 'graphLineColor', 'blue', ...
'graphLineStyle', 'loosely dashed', 'graphLineWidth', 1);
rep.addSeries('data', dsq{'GROWTH_EU'}, 'graphLineColor', 'green', ...
'graphLineWidth', 1.5);
rep.addGraph('title', 'Graph Column 2', 'showLegend', true, ...
'xrange', dates('2007q1'):dates('2013q4'), ...
'shade', dates('2012q2'):dates('2013q4'));
rep.addSeries('data', dsq{'GROWTH_JA'}, 'graphLineColor', 'blue', ...
'graphLineWidth', 1);
rep.addSeries('data', dsq{'GROWTH_RC6'}, 'graphLineColor', 'green', ...
'graphLineStyle', 'dashdotdotted', 'graphLineWidth', 1.5);
% Section 2
rep = rep.addSection();
rep = rep.addTable(`title', `Table 1', ...
`range', dates(`2012Y'):dates(`2014Y'));
shortNames = {`US', `EU'};
longNames = {`United States', `Euro Area'};
rep.addVspace('number', 15);
rep.addSection();
rep.addTable('title', 'Table 1', 'range', dates('2012Y'):dates('2014Y'));
shortNames = {'US', 'EU'};
longNames = {'United States', 'Euro Area'};
for i=1:length(shortNames)
rep = rep.addSeries(`data', dsa{[`GDP_' shortNames{i}]});
delta = dsa{[`GDP_' shortNames{i}]}-dsca{[`GDP_' shortNames{i}]};
delta = delta.tex_rename(`$\Delta$');
rep = rep.addSeries(`data', delta, ...
`tableShowMarkers', true, ...
`tableAlignRight', true);
rep.addSeries('data', dsa{['GROWTH_' shortNames{i}]});
delta = dsa{['GROWTH_' shortNames{i}]}-dsca{['GROWTH_' shortNames{i}]};
delta.tex_rename_('$\Delta$');
rep.addSeries('data', delta, ...
'tableShowMarkers', true, 'tableAlignRight', true);
end
%% Write & Compile Report
rep.write();
rep.compile();
Once compiled, the report looks like:
.. image:: _static/report.png
......@@ -22,7 +22,7 @@ command at the MATLAB or Octave prompt (with the filename of the
In practice, the handling of the model file is done in two steps: in
the first one, the model and the processing instructions written by
the user in a *model file* are interpreted and the proper MATLAB or
GNU Octave instructions are generated; in the second step, the program
Octave instructions are generated; in the second step, the program
actually runs the computations. Both steps are triggered automatically
by the ``dynare`` command.
......@@ -36,7 +36,7 @@ by the ``dynare`` command.
first line of the ``.mod`` file itself (see below).
dynare begins by launching the preprocessor on the ``.mod
file``. By default (unless ``use_dll`` option has been given to
file``. By default (unless the :opt:`use_dll` option has been given to
``model``), the preprocessor creates three intermediary files:
- ``+FILENAME/driver.m``
......@@ -104,27 +104,41 @@ by the ``dynare`` command.
Octave, it also means that the ``.mod`` file cannot be named
``test.mod`` or ``example.mod``.
.. _quote-note:
.. note::
Note on Quotes
When passing command line options that contains a space (or, under
Octave, a double quote), you must surround the entire option (keyword
and argument) with single quotes, as in the following example.
*Example*
Call Dynare with options containing spaces
.. code-block:: matlab
>> dynare <<modfile.mod>> '-DA=[ i in [1,2,3] when i > 1 ]' 'conffile=C:\User\My Documents\config.txt'
*Options*
.. option:: noclearall
By default, ``dynare`` will issue a ``clear all`` command to
MATLAB (<R2015b) or Octave, thereby deleting all workspace
variables and functions; this option instructs ``dynare`` not
to clear the workspace. Note that starting with Matlab 2015b
``dynare`` only deletes the global variables and the functions
using persistent variables, in order to benefit from the JIT
(Just In Time) compilation. In this case the option instructs
``dynare`` not to clear the globals and functions.
By default, ``dynare`` deletes all the global variables and the
functions using persistent variables, in order to benefit from the JIT
(just-in-time) compilation. This option instructs ``dynare`` not to
clear those.
.. option:: onlyclearglobals
By default, ``dynare`` will issue a ``clear all`` command to
MATLAB versions before 2015b and to Octave, thereby deleting
all workspace variables; this option instructs ``dynare`` to
clear only the global variables (i.e. ``M_, options_, oo_,
estim_params_, bayestopt_``, and ``dataset_``), leaving the
other variables in the workspace.
By default, ``dynare`` deletes all the global variables and the
functions using persistent variables, in order to benefit from the JIT
(just-in-time) compilation. This option instructs ``dynare`` to clear
only its own global variables (*i.e.* ``M_, options_, oo_,
estim_params_, bayestopt_``, ``dataset_``, ``dataset_info`` and
``estimation_info``), leaving the other variables in the workspace, and
not clearing functions using persistent variables.
.. option:: debug
......@@ -140,10 +154,11 @@ by the ``dynare`` command.
.. option:: savemacro[=FILENAME]
Instructs ``dynare`` to save the intermediary file which is
obtained after macro processing (see :ref:`macro-proc-lang`);
the saved output will go in the file specified, or if no file
is specified in ``FILENAME-macroexp.mod``
Instructs ``dynare`` to save the intermediary file which is obtained
after macro processing (see :ref:`macro-proc-lang`); the saved output
will go in the file specified, or if no file is specified in
``FILENAME_macroexp.mod``. See the :ref:`note on quotes<quote-note>`
for info on passing a ``FILENAME`` argument containing spaces.
.. option:: onlymacro
......@@ -152,19 +167,12 @@ by the ``dynare`` command.
debugging purposes or for using the macro processor
independently of the rest of Dynare toolbox.
.. option:: nolinemacro
Instructs the macro preprocessor to omit line numbering
information in the intermediary ``.mod`` file created after
the macro processing step. Useful in conjunction with
:opt:`savemacro <savemacro[=FILENAME]>` when one wants that to reuse the intermediary
``.mod`` file, without having it cluttered by line numbering
directives.
.. option:: linemacro
.. option:: noemptylinemacro
Passing this option removes all empty from the macro expanded
mod file created when the :opt:`savemacro <savemacro[=FILENAME]>` option is used.
Instructs the macro preprocessor include ``@#line`` directives
specifying the line on which macro directives were encountered and
expanded from. Only useful in conjunction with :opt:`savemacro
<savemacro[=FILENAME]>`.
.. option:: onlymodel
......@@ -180,10 +188,23 @@ by the ``dynare`` command.
Instructs Dynare to no create a logfile of this run in
``FILENAME.log.`` The default is to create the logfile.
.. option:: output=first|second|third
Instructs the preprocessor to output derivatives of the dynamic model at
least up to the given order. The `first` option is useful in
larger models when debugging steady state computation, because it allows
overriding the default computation and output of dynamic second order derivatives
in case of the mod-file not containing commands for further computations.
.. option:: language=matlab|julia
Instructs the preprocessor to write output for MATLAB or Julia. Default:
MATLAB
.. option:: params_derivs_order=0|1|2
When :comm:`identification`, :comm:`dynare_sensitivity` (with
identification), or :ref:`estimation_cmd <estim-comm>` are
identification), or :ref:`estimation <estim-comm>` are
present, this option is used to limit the order of the
derivatives with respect to the parameters that are calculated
by the preprocessor. 0 means no derivatives, 1 means first
......@@ -193,14 +214,34 @@ by the ``dynare`` command.
Suppresses all warnings.
.. option:: json = parse|transform|compute
.. option:: notime
Do not print the total computing time at the end of the driver, and do
not save that total computing time to ``oo_.time``.
Causes the preprocessor to output a version of the ``.mod``
file in JSON format.
.. option:: transform_unary_ops
If ``parse`` is passed, the output will be written after the
parsing of the ``.mod`` file to a file called
``FILENAME.json``.
Transform the following operators in the model block into auxiliary
variables: ``exp``, ``log``, ``log10``, ``cos``, ``sin``, ``tan``,
``acos``, ``asin``, ``atan``, ``cosh``, ``sinh``, ``tanh``, ``acosh``,
``asinh``, ``atanh``, ``sqrt``, ``cbrt``, ``abs``, ``sign``,
``erf``. Default: no obligatory transformation
.. option:: json = parse|check|transform|compute
Causes the preprocessor to output a version of the ``.mod`` file in
JSON format to ``<<M_.fname>>/model/json/``.
When the JSON output is created depends on the value
passed. These values represent various steps of processing in the
preprocessor.
If ``parse`` is passed, the output will be written after the parsing of
the ``.mod`` file to a file called ``FILENAME.json`` but before file
has been checked (e.g. if there are unused exogenous in the model
block, the JSON output will be created before the preprocessor exits).
If ``check`` is passed, the output will be written to a file called
``FILENAME.json`` after the model has been checked.
If ``transform`` is passed, the JSON output of the transformed
model (maximum lead of 1, minimum lag of -1, expectation
......@@ -218,7 +259,8 @@ by the ``dynare`` command.
.. option:: jsonstdout
Instead of writing output requested by ``json`` to files,
write to standard out.
write to standard out, i.e. to the MATLAB/Octave command window
(and the log-file).
.. option:: onlyjson
......@@ -249,6 +291,7 @@ by the ``dynare`` command.
computations.
.. option:: nograph
:noindex:
Activate the ``nograph`` option (see :opt:`nograph`), so that
Dynare will not produce any graph.
......@@ -259,20 +302,20 @@ by the ``dynare`` command.
.. option:: nopathchange
By default Dynare will change Matlab/Octave’s path if
By default Dynare will change MATLAB/Octave’s path if
``dynare/matlab`` directory is not on top and if Dynare’s
routines are overriden by routines provided in other
toolboxes. If one wishes to override Dynare’s routines, the
``nopathchange`` options can be used. Alternatively, the path
can be temporarly modified by the user at the top of the
``.mod`` file (using Matlab/Octave’s ``addpath`` command).
``.mod`` file (using MATLAB/Octave’s ``addpath`` command).
.. option:: nopreprocessoroutput
Prevent Dynare from printing the output of the steps leading up to the
preprocessor as well as the preprocessor output itself.
.. option:: mexext=mex|mexw32|mexw64|mexmaci64|mexa64
.. option:: mexext=mex|mexw64|mexmaci64|mexmaca64|mexa64
The mex extension associated with your platform to be used
when compiling output associated with :opt:`use_dll`.
......@@ -281,9 +324,10 @@ by the ``dynare`` command.
.. option:: matlabroot=<<path>>
The path to the Matlab installation for use with
:opt:`use_dll`. Dynare is able to set this automatically,
so you should not need to set it yourself.
The path to the MATLAB installation for use with :opt:`use_dll`. Dynare
is able to set this automatically, so you should not need to set it
yourself. See the :ref:`note on quotes<quote-note>` for info on
passing a ``<<path>>`` argument containing spaces.
.. option:: parallel[=CLUSTER_NAME]
......@@ -296,13 +340,15 @@ by the ``dynare`` command.
.. option:: conffile=FILENAME
Specifies the location of the configuration file if it differs
from the default. See :ref:`conf-file`, for more information
about the configuration file and its default location.
Specifies the location of the configuration file if it differs from the
default. See :ref:`conf-file`, for more information about the
configuration file and its default location. See the :ref:`note on
quotes<quote-note>` for info on passing a ``FILENAME`` argument
containing spaces.
.. option:: parallel_slave_open_mode
.. option:: parallel_follower_open_mode
Instructs Dynare to leave the connection to the slave node
Instructs Dynare to leave the connection to the follower node
open after computation is complete, closing this connection
only when Dynare finishes processing.
......@@ -312,20 +358,43 @@ by the ``dynare`` command.
without executing the ``.mod`` file. See :ref:`conf-file`, for
more information about the configuration file.
.. option:: -DMACRO_VARIABLE=MACRO_EXPRESSION
.. option:: parallel_use_psexec=true|false
Defines a macro-variable from the command line (the same
effect as using the Macro directive ``@#define`` in a model
file, see :ref:`macro-proc-lang`).
For local execution under Windows operating system,
set ``parallel_use_psexec=false`` to use ``start``
instead of ``psexec``, to properly allocate affinity when there are
more than 32 cores in the local machine. This option is also helpful if
``psexec`` cannot be executed due to missing admininstrator privileges. [default=true]
.. option:: -DMACRO_VARIABLE[=MACRO_EXPRESSION]
Defines a macro-variable from the command line (the same effect as
using the Macro directive ``@#define`` in a model file, see
:ref:`macro-proc-lang`). See the :ref:`note on quotes<quote-note>` for
info on passing a ``MACRO_EXPRESSION`` argument containing spaces. Note
that an expression passed on the command line can reference variables
defined before it. If ``MACRO_EXPRESSION`` is omitted, the variable is
assigned the ``true`` logical value. Strings assigned to a macro variable
need to be enclosed in double quoted strings. This also allows for passing
single quotes within the strings.
*Example*
Call dynare with command line defines
.. code-block:: matlab
>> dynare <<modfile.mod>> -DA=true '-DB="A string with space"' -DC=[1,2,3] '-DD=[ i in C when i > 1 ]' -DE -Ddatafile_name="'my_data_file.mat'"
.. option:: -I<<path>>
Defines a path to search for files to be included by the
macro processor (using the ``@#include`` command). Multiple
``-I`` flags can be passed on the command line. The paths will
be searched in the order that the ``-I`` flags are passed and
the first matching file will be used. The flags passed here
take priority over those passed to ``@#includepath``.
Defines a path to search for files to be included by the macro
processor (using the ``@#include`` command). Multiple ``-I`` flags can
be passed on the command line. The paths will be searched in the order
that the ``-I`` flags are passed and the first matching file will be
used. The flags passed here take priority over those passed to
``@#includepath``. See the :ref:`note on quotes<quote-note>` for info
on passing a ``<<path>>`` argument containing spaces.
.. option:: nostrict
......@@ -340,9 +409,11 @@ by the ``dynare`` command.
.. option:: fast
Only useful with model option ``use_dll``. Don’t recompile the
MEX files when running again the same model file and the lists
of variables and the equations haven’t changed. We use a 32
Don’t rewrite the output files otherwise written to the disk by the preprocessor
when re-running the same model file while the lists of variables and the equations
haven’t changed. Note that the whole model still needs to be preprocessed. This option
is most useful with model option :opt:`use_dll`, because
the time-consuming compilation of the MEX files will be skipped. We use a 32
bit checksum, stored in ``<model filename>/checksum``. There
is a very small probability that the preprocessor misses a
change in the model. In case of doubt, re-run without the fast
......@@ -369,17 +440,113 @@ by the ``dynare`` command.
understands by default that the model to be solved is
deterministic.
.. _exclude_eqs:
.. option:: exclude_eqs=<<equation_tags_to_exclude>>
Tells Dynare to exclude all equations specified by the argument. As a
``.mod`` file must have the same number of endogenous variables as
equations, when `exclude_eqs` is passed, certain rules are followed for
excluding endogenous variables. If the ``endogenous`` tag has been set
for the excluded equation, the variable it specifies is
excluded. Otherwise, if the left hand side of the excluded equation is
an expression that contains only one endogenous variable, that variable
is excluded. If neither of these conditions hold, processing stops with
an error. If an endogenous variable has been excluded by the
`exclude_eqs` option and it exists in an equation that has not been
excluded, it is transformed into an exogenous variable.
To specify which equations to exclude, you must pass the argument
``<<equation_tags_to_exclude>>``. This argument takes either a list of
equation tags specifying the equations to be excluded or a filename that
contains those tags.
If ``<<equation_tags_to_exclude>>`` is a list of equation tags, it can
take one of the following forms:
#. Given a single argument, e.g. ``exclude_eqs=eq1``, the equation with
the tag ``[name='eq1']`` will be excluded. Note that if there is a
file called ``eq1`` in the current directory, Dynare will instead
try to open this and read equations to exclude from it (see info on
filename argument to ``exclude_eqs`` below). Further note that if the
tag value contains a space, you must use the variant specified in 2
below, i.e. ``exclude_eqs=[eq 1]``.
#. Given two or more arguments, e.g. ``exclude_eqs=[eq1, eq 2]``, the
equations with the tags ``[name='eq1']`` and ``[name='eq 2']`` will
be excluded.
#. If you'd like to exclude equations based on another tag name (as
opposed to the default ``name``), you can pass the argument as either
e.g. ``exclude_eqs=[tagname=a tag]`` if a single equation with tag
``[tagname='a tag']`` is to be excluded or as
e.g. ``exclude_eqs=[tagname=(a tag, 'a tag with a, comma')]`` if more
than one equation with tags ``[tagname='a tag']`` and ``[tagname='a
tag with a, comma']`` will be excluded (note the parenthesis, which
are required when more than one equation is specified). Note that if
the value of a tag contains a comma, it must be included inside
single quotes.
If ``<<equation_tags_to_exclude>>`` is a filename, the file can take one
of the following forms:
#. One equation per line of the file, where every line represents the
value passed to the ``name`` tag. e.g., a file such as::
eq1
eq 2
would exclude equations with tags ``[name='eq1']`` and ``[name='eq
2']``.
#. One equation per line of the file, where every line after the first
line represents the value passed to the tag specified by the first
line. e.g., a file such as::
tagname=
a tag
a tag with a, comma
would exclude equations with tags ``[tagname='a tag']`` and
``[tagname='a tag with a, comma']``. Here note that the first line
must end in an equal sign.
.. option:: include_eqs=<<equation_tags_to_include>>
Tells Dynare to run with only those equations specified by the
argument; in other words, Dynare will exclude all equations not
specified by the argument. The argument ``<<equation_tags_to_include>>``
is specified in the same way as the argument to :ref:`exclude_eqs
<exclude_eqs>`. The functionality of ``include_eqs`` is to find which
equations to exclude then take actions in accord with :ref:`exclude_eqs
<exclude_eqs>`.
.. option:: use_dll
:noindex:
Instructs the preprocessor to create dynamic loadable libraries (DLL)
containing the model equations and derivatives, instead of writing
those in M-files. This is equivalent to the :opt:`use_dll` option of
the ``model`` block.
.. option:: nocommutativity
This option tells the preprocessor not to use the commutativity of
addition and multiplication when looking for common subexpressions. As a
consequence, when using this option, equations in various outputs
(LaTeX, JSON…) will appear as the user entered them (without terms or
factors swapped). Note that using this option may have a performance
impact on the preprocessing stage, though it is likely to be small.
These options can be passed to the preprocessor by listing them
after the name of the ``.mod`` file. They can alternatively be
defined in the first line of the ``.mod`` file, this avoids typing
them on the command line each time a ``.mod`` file is to be
run. This line must be a Dynare comment (ie must begin with //)
and the options must be comma separated between ``--+`` options:
run. This line must be a Dynare one-line comment (i.e. must begin with ``//``)
and the options must be whitespace separated between ``--+ options:``
and ``+--``. Note that any text after the ``+--`` will be
discarded. As in the command line, if an option admits a value the
equal symbol must not be surrounded by spaces. For instance ``json
= compute`` is not correct, and should be written
``json=compute``.
``json=compute``. The ``nopathchange`` option cannot be specified in
this way, it must be passed on the command-line.
*Output*
......@@ -388,9 +555,13 @@ by the ``dynare`` command.
results in the workspace available for further processing. More
details are given under the relevant computing tasks. The
``M_``, ``oo_``, and ``options_`` structures are saved in a file
called ``FILENAME_results.mat``. If they exist, ``estim_params_``,
called ``FILENAME_results.mat`` located in the ``MODFILENAME/Output`` folder.
If they exist, ``estim_params_``,
``bayestopt_``, ``dataset_``, ``oo_recursive_`` and
``estimation_info`` are saved in the same file.
``estimation_info`` are saved in the same file. Note that MATLAB
by default only allows ``.mat`` files up to 2GB. You can lift this
restriction by enabling the ``save -v7.3`` option in
``Preferences -> General -> MAT-Files``.
.. matvar:: M_
......@@ -418,6 +589,11 @@ by the ``dynare`` command.
saved in the `i` -th field. The fields for non-estimated
endpoints are empty.
.. matvar:: oo_.time
Total computing time of the Dynare run, in seconds. This field is not
set if the :opt:`notime` option has been used.
*Example*
Call dynare from the MATLAB or Octave prompt, without or with options:
......@@ -499,7 +675,7 @@ parser would continue processing.
It is also helpful to keep in mind that any piece of code that does not violate
Dynare syntax, but at the same time is not recognized by the parser, is interpreted
as native Matlab code. This code will be directly passed to the ``driver`` script.
Investigating ``driver.m`` file then helps with debugging. Such problems most often
as native MATLAB code. This code will be directly passed to the driver script.
Investigating the ``driver.m`` file then helps with debugging. Such problems most often
occur when defined variable or parameter names have been misspelled so that Dynare's
parser is unable to recognize them.
......@@ -15,11 +15,16 @@ related to the model (and hence not placed in the model file). At the
moment, it is only used when using Dynare to run parallel
computations.
On Linux and macOS, the default location of the configuration file is
``$HOME/.dynare``, while on Windows it is ``%APPDATA%\dynare.ini``
(typically ``c:\Users\USERNAME\AppData\dynare.ini``). You
can specify a non standard location using the ``conffile`` option of
the ``dynare`` command (see :ref:`dyn-invoc`).
On Linux and macOS, the configuration file is searched by default under
``dynare/dynare.ini`` in the configuration directories defined by the XDG
specification (typically ``$HOME/.config/dynare/dynare.ini`` for the
user-specific configuration and ``/etc/xdg/dynare/dynare.ini`` for the
system-wide configuration, the former having precedence over the latter). Under
Windows, the configuration file is searched by default in
``%APPDATA%\dynare\dynare.ini`` (typically
``c:\Users\USERNAME\AppData\Roaming\dynare\dynare.ini``). You can specify a non
standard location using the ``conffile`` option of the ``dynare`` command (see
:ref:`dyn-invoc`).
The parsing of the configuration file is case-sensitive and it should
take the following form, with each option/choice pair placed on a
......@@ -54,7 +59,7 @@ conventions such as ``USER_NAME`` have been excluded for concision):
``PATH_AND_FILE``
Indicates a valid path to a file in the underlying operating
system (e.g. ``/usr/local/MATLAB/R2010b/bin/matlab``).
system (e.g. ``/usr/local/MATLAB/R2023b/bin/matlab``).
``BOOLEAN``
......@@ -76,8 +81,15 @@ processing. Currently, there is only one option available.
.. option:: GlobalInitFile = PATH_AND_FILE
The location of the global initialization file to be run at
the end of ``global_initialization.m``.
The location of a global initialization file that can be used to
customize some Dynare internals (typically default option values). This
is a MATLAB/Octave script.
If this option is not specified, Dynare will look for a
``global_init.m`` file in its configuration directory (typically
``$HOME/.config/dynare/global_init.m`` under Linux and macOS, and
``c:\Users\USERNAME\AppData\Roaming\dynare\global_init.m`` under
Windows).
*Example*
......@@ -119,7 +131,7 @@ tasks which require very little inter-process communication.
The parallelization is done by running several MATLAB or Octave
processes, either on local or on remote machines. Communication
between master and slave processes are done through SMB on Windows and
between leader and follower processes are done through SMB on Windows and
SSH on UNIX. Input and output data, and also some short status
messages, are exchanged through network filesystems. Currently the
system works only with homogenous grids: only Windows or only Unix
......@@ -140,27 +152,34 @@ and for other options related to the parallelization engine, see
:ref:`dyn-invoc`.
You also need to verify that the following requirements are met by
your cluster (which is composed of a master and of one or more
slaves):
your cluster (which is composed of a leader and of one or more
followers):
For a Windows grid:
* a standard Windows network (SMB) must be in place;
* the `PsTools`_ suite must be installed in the path of the
master Windows machine;
* the Windows user on the master machine has to be user of any
other slave machine in the cluster, and that user will be
leader Windows machine;
* the Windows user on the leader machine has to be user of any
other follower machine in the cluster, and that user will be
used for the remote computations.
* detailed step-by-step setup instructions can be found in
:ref:`win-ssg`.
For a UNIX grid:
* SSH must be installed on the master and on the slave machines;
* SSH must be installed on the leader and on the follower machines;
* SSH keys must be installed so that the SSH connection from
the master to the slaves can be done without passwords, or
the leader to the follower can be done without passwords, or
using an SSH agent.
.. warning:: Compatibility considerations between leader and follower
It is highly recommended to use the same version of Dynare on both the
leader and all followers. Different versions regularly cause problems like
zero acceptance rates during estimation. When upgrading to a newer Dynare
version do not forget to adjust the ``DynarePath``.
We now turn to the description of the configuration directives. Note
that comments in the configuration file can be provided by separate
lines starting with a hashtag (#).
......@@ -263,17 +282,41 @@ lines starting with a hashtag (#).
.. option:: MatlabOctavePath = PATH_AND_FILE
The path to the MATLAB or Octave executable. The default value
is ``matlab``.
is ``matlab`` as MATLAB’s executable is typically in the %PATH% environment
variable. When using full paths on Windows, you may need to enclose the path
in quoted strings, e.g. ``MatlabOctavePath="C:\Program Files\MATLAB\R2023b\bin\matlab.exe"``
.. option:: NumberOfThreadsPerJob = INTEGER
For Windows nodes, sets the number of threads assigned to each
remote MATLAB/Octave run. The default value is 1.
This option controls the distribution of jobs (e.g. MCMC chains) across additional MATLAB instances that are run in parallel.
Needs to be an exact divisor of the number of cores.
The formula :opt:`CPUnbr <CPUnbr = INTEGER | [INTEGER:INTEGER]>` divided by :opt:`NumberOfThreadsPerJob <NumberOfThreadsPerJob = INTEGER>`
calculates the number of MATLAB/Octave instances that will be launched in parallel,
where each instance will then execute a certain number of jobs sequentially.
For example, if you run a MCMC estimation with 24 chains on a 12 core machine, setting ``CPUnbr = 12`` and ``NumberOfThreadsPerJob = 4``
will launch 3 MATLAB instances in parallel, each of which will compute 8 chains sequentially.
Note that this option does not dictate the number of maximum threads utilized by each MATLAB/Octave instance,
see related option :opt:`SingleCompThread <SingleCompThread = BOOLEAN>` for this.
Particularly for very large models, setting this option to 2 might distribute the workload in a
more efficient manner, depending on your hardware and task specifics.
It’s advisable to experiment with different values to achieve optimal performance.
The default value is ``1``.
.. option:: SingleCompThread = BOOLEAN
Whether or not to disable MATLAB’s native multithreading. The
default value is ``false``. Option meaningless under Octave.
This option allows you to enable or disable MATLAB’s native multithreading capability. When set to ``true``,
the additional MATLAB instances are initiated in single thread mode utilizing the ``-singleCompThread`` startup option,
thereby disabling MATLAB’s native multithreading. When set to ``false``, MATLAB’s native multithreading
is enabled, e.g. the actual number of threads utilized by each MATLAB instance is usually determined by the number of CPU cores
(you can check this by running ``maxNumCompThreads`` in MATLAB’s command window).
Note: While MATLAB aims to accelerate calculations by distributing them across your computer’s threads,
certain tasks, like MCMC estimations, may exhibit slowdowns with MATLAB’s multitasking especially when Dynare’s parallel computing is turned on
as we do not use MATLAB’s parallel toolbox.
So in many cases it is advisable to set this setting to ``true``.
If you want to have more control, you can manually add the MATLAB command `maxNumCompThreads(N)` at the beginning of `fParallel.m`.
The default value is ``false``. This option is ineffective under Octave.
.. option:: OperatingSystem = OPERATING_SYSTEM
......@@ -316,7 +359,9 @@ Windows Step-by-Step Guide
==========================
This section outlines the steps necessary on most Windows systems to
set up Dynare for parallel execution.
set up Dynare for parallel execution. Note that the steps 3 to 6 are
required unless parallel execution is confined to a local pool
with the ``parallel_use_psexec=false`` option.
1. Write a configuration file containing the options you want. A
mimimum working example setting up a cluster consisting of two
......@@ -337,12 +382,12 @@ set up Dynare for parallel execution.
Key+Pause to open the System Configuration, then go to Advanced
-> Environment Variables -> Path).
5. Restart your computer to make the path change effective.
6. Open Matlab and type into the command window::
6. Open MATLAB and type into the command window::
!psexec
This executes the ``psexec.exe`` from PSTools on your system
and shows whether Dynare will be able to locate it. If Matlab
and shows whether Dynare will be able to locate it. If MATLAB
complains at this stage, you did not correctly set your Windows
system path for the ``PSTools`` folder.
7. If ``psexec.exe`` was located in the previous step, a popup
......@@ -380,10 +425,10 @@ set up Dynare for parallel execution.
ComputerName=localhost
#cores to be included from this node
CPUnbr=[1:2]
#path to matlab.exe; on Windows, theMatlab bin folder is in the system path
#path to matlab.exe; on Windows, the MATLAB bin folder is in the system path
#so we only need to provide the name of the exe file
MatlabOctavePath=matlab
#Dynare path you are using
DynarePath=C:/dynare/2016-05-10/matlab
DynarePath=C:/dynare/4.7.0/matlab
.. _PsTools: https://technet.microsoft.com/sysinternals/pstools.aspx
Source diff could not be displayed: it is too large. Options to address this: view the blob.
......@@ -8,31 +8,40 @@
Time Series
###########
Dynare provides a Matlab/Octave class for handling time series data,
Dynare provides a MATLAB/Octave class for handling time series data,
which is based on a class for handling dates. Dynare also provides a
new type for dates, so that the basic user does not have to worry
about class and methods for dates. Below, you will first find the
class and methods used for creating and dealing with dates and then
the class used for using time series.
new type for dates, so that the user does not have to worry about
class and methods for dates. Below, you will first find the class and
methods used for creating and dealing with dates and then the class
used for using time series. Dynare also provides an interface to the
X-13 ARIMA-SEATS seasonal adjustment program produced, distributed, and
maintained by the U.S. Census Bureau (2020).
Dates
=====
.. highlight:: matlab
.. _dates in a mod file:
Dates in a mod file
-------------------
Dynare understands dates in a mod file. Users can declare annual,
quarterly, monthly or weekly dates using the following syntax::
Dynare understands dates in a mod file. Users can declare annual, bi-annual,
quarterly, or monthly dates using the following syntax::
1990Y
1990Q3
1990A
1990S2
1990H2
1990Q4
1990M11
1990W49
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
into instantiations of the MATLAB/Octave’s class ``dates`` described
below. Basic operations can be performed on dates:
**plus binary operator (+)**
......@@ -50,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``).
......@@ -65,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
......@@ -84,51 +93,49 @@ below. Basic operations can be performed on dates:
**eq operator (equal, ==)**
Tests if two ``dates`` objects are equal. ``+1950Q1==1950Q2``
returns ``1``, ``1950Q1==1950Q2`` returns ``0``. If the compared
returns ``true``, ``1950Q1==1950Q2`` returns ``false``. If the compared
objects have both ``n>1`` elements, the ``eq`` operator returns a
column vector, ``n`` by ``1``, of zeros and ones.
column vector, ``n`` by ``1``, of logicals.
**ne operator (not equal, ~=)**
Tests if two ``dates`` objects are not equal. ``+1950Q1~=``
returns ``0`` while ``1950Q1~=1950Q2`` returns ``1``. If the
returns ``false`` while ``1950Q1~=1950Q2`` returns ``true``. If the
compared objects both have ``n>1`` elements, the ``ne`` operator
returns an ``n`` by ``1`` column vector of zeros and ones.
returns an ``n`` by ``1`` column vector of logicals.
**lt operator (less than, <)**
Tests if a ``dates`` object preceeds another ``dates`` object. For
instance, ``1950Q1<1950Q3`` returns ``1``. If the compared objects
instance, ``1950Q1<1950Q3`` returns ``true``. If the compared objects
have both ``n>1`` elements, the ``lt`` operator returns a column
vector, ``n`` by ``1``, of zeros and ones.
vector, ``n`` by ``1``, of logicals.
**gt operator (greater than, >)**
Tests if a ``dates`` object follows another ``dates`` object. For
instance, ``1950Q1>1950Q3`` returns ``0``. If the compared objects
instance, ``1950Q1>1950Q3`` returns ``false``. If the compared objects
have both ``n>1`` elements, the ``gt`` operator returns a column
vector, ``n`` by ``1``, of zeros and ones.
vector, ``n`` by ``1``, of logicals.
**le operator (less or equal, <=)**
Tests if a ``dates`` object preceeds another ``dates`` object or
is equal to this object. For instance, ``1950Q1<=1950Q3`` returns
``1``. If the compared objects have both ``n>1`` elements, the
``le`` operator returns a column vector, ``n`` by ``1``, of zeros
and ones.
``true``. If the compared objects have both ``n>1`` elements, the
``le`` operator returns a column vector, ``n`` by ``1``, of logicals.
**ge operator (greater or equal, >=)**
Tests if a ``dates`` object follows another ``dates`` object or is
equal to this object. For instance, ``1950Q1>=1950Q3`` returns
``0``. If the compared objects have both ``n>1`` elements, the
``ge`` operator returns a column vector, ``n`` by ``1``, of zeros
and ones.
``false``. If the compared objects have both ``n>1`` elements, the
``ge`` operator returns a column vector, ``n`` by ``1``, of logicals.
One can select an element, or some elements, in a ``dates`` object as
he would extract some elements from a vector in Matlab/Octave. Let ``a
he would extract some elements from a vector in MATLAB/Octave. Let ``a
= 1950Q1:1951Q1`` be a ``dates`` object, then ``a(1)==1950Q1`` returns
``1``, ``a(end)==1951Q1`` returns ``1`` and ``a(end-1:end)`` selects
``true``, ``a(end)==1951Q1`` returns ``true`` and ``a(end-1:end)`` selects
the two last elements of ``a`` (by instantiating the ``dates`` object
``[1950Q4, 1951Q1]``).
......@@ -146,7 +153,7 @@ Dynare will translate this as::
disp('Initial period is dates('1950Q1')');
which will lead to a crash because this expression is illegal in
Matlab. For this situation, Dynare provides the ``$`` escape
MATLAB. For this situation, Dynare provides the ``$`` escape
parameter. The following expression::
disp('Initial period is $1950Q1');
......@@ -165,19 +172,14 @@ The dates class
.. class:: dates
:arg int freq: equal to 1, 4, 12 or 52 (resp. for annual,
quarterly, monthly or weekly dates).
:arg int ndat: the number of declared dates in the object.
:arg int time: a ``ndat*2`` array, the years are stored in the
first column, the subperiods (1 for annual dates,
1-4 for quarterly dates, 1-12 for monthly dates and
1-52 for weekly dates) are stored in the second
column.
:arg freq: equal to 1, 2, 4, 12 or 365 (resp. for annual, bi-annual, quarterly,
monthly, or daily dates).
:arg time: a ``n*1`` array of integers, the number of periods since year 0 ().
Each member is private, one can display the content of a member
but cannot change its value directly. Note that it is not possible
to mix frequencies in a ``dates`` object: all the elements must
have common frequency.
but cannot change its value directly. Note also that it is not
possible to mix frequencies in a ``dates`` object: all the
elements must have common frequency.
The ``dates`` class has the following constructors:
......@@ -187,12 +189,13 @@ The dates class
|br| Returns an empty ``dates`` object with a given frequency
(if the constructor is called with one input
argument). ``FREQ`` is a character equal to ’Y’ or ’A’ for
annual dates, ’Q’ for quarterly dates, ’M’ for monthly dates
or ’W’ for weekly dates. Note that ``FREQ`` is not case
sensitive, so that, for instance, ’q’ is also allowed for
quarterly dates. The frequency can also be set with an integer
scalar equal to 1 (annual), 4 (quarterly), 12 (monthly) or 52
(weekly). The instantiation of empty objects can be used to
annual dates, ’S’ or ’H’ for bi-annual dates, ’Q’ for
quarterly dates, ’M’ for monthly dates, or ’D’ for daily
dates. Note that ``FREQ`` is not case sensitive, so that, for
instance, ’q’ is also allowed for quarterly dates. The
frequency can also be set with an integer scalar equal to 1
(annual), 2 (bi-annual), 4 (quarterly), 12 (monthly), or 365
(daily). The instantiation of empty objects can be used to
rename the ``dates`` class. For instance, if one only works
with quarterly dates, object ``qq`` can be created as::
......@@ -203,7 +206,14 @@ The dates class
d0 = qq(2009,2);
which is much simpler if ``dates`` objects have to be defined
programmatically.
programmatically. For daily dates, we would instantiate an
empty daily dates object as::
dd = dates('D')
and a ``dates`` object holding the date ``2020-12-31``::
d1 = dd(2020,12,31);
.. construct:: dates(STRING)
......@@ -212,12 +222,17 @@ The dates class
|br| Returns a ``dates`` object that represents a date as
given by the string ``STRING``. This string has to be
interpretable as a date (only strings of the following forms
are admitted: ``'1990Y'``, ``'1990A'``, ``'1990Q1'``,
``'1990M2'``, ``'1990W5'``), the routine ``isdate`` can be
used to test if a string is interpretable as a date. If more
than one argument is provided, they should all be dates
represented as strings, the resulting ``dates`` object
contains as many elements as arguments to the constructor.
are admitted: ``'1990Y'``, ``'1990A'``, ``1990S1``,
``1990H1``, ``'1990Q1'``, ``'1990M2'``, or ``'2020-12-31'``),
the routine ``isdate`` can be used to test if a string is
interpretable as a date. If more than one argument is
provided, they should all be dates represented as strings, the
resulting ``dates`` object contains as many elements as
arguments to the constructor. For the daily dates, the string
must be of the form yyyy-mm-dd with two digits for the
months (mm) and days (dd), even if the number of days or
months is smaller than ten (in this case a leading 0 is
required).
.. construct:: dates(DATES)
......@@ -231,15 +246,16 @@ The dates class
constructor.
.. construct:: dates (FREQ, YEAR, SUBPERIOD)
.. construct:: dates (FREQ, YEAR, SUBPERIOD[, S])
|br| where ``FREQ`` is a single character (’Y’, ’A’, ’Q’, ’M’,
’W’) or integer (1, 4, 12 or 52) specifying the frequency,
``YEAR`` and ``SUBPERIOD`` are ``n*1`` vectors of
integers. Returns a ``dates`` object with ``n`` elements. If
``FREQ`` is equal to ``'Y'``, ``'A'`` or ``1``, the third
argument is not needed (because ``SUBPERIOD`` is necessarily a
vector of ones in this case).
|br| where ``FREQ`` is a single character (’Y’, ’A’, ’S’, ’H’,
’Q’, ’M’, ’D’) or integer (1, 2, 4, 12, or 365) specifying the
frequency, ``YEAR`` and ``SUBPERIOD`` and ``S`` are ``n*1``
vectors of integers. Returns a ``dates`` object with ``n``
elements. The last argument, ``S``, is only to be used for
daily frequency. If ``FREQ`` is equal to ``'Y'``, ``'A'`` or
``1``, the third argument is not needed (because ``SUBPERIOD``
is necessarily a vector of ones in this case).
*Example*
......@@ -250,25 +266,83 @@ The dates class
do2 = dates('1950Q2','1950Q3');
do3 = dates(do1,do2);
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 the Matlab/Octave classes do not allow in place
below. Note that by default the methods do not allow in place
modifications: when a method is applied to an object a new object
is instantiated. For instance, to apply the method
``multiplybytwo`` to an object ``X`` we write::
Y = X.multiplybytwo()
>> X = 2;
>> Y = X.multiplybytwo();
>> X
2
>> Y
4
or equivalently::
Y = multiplybytwo(X)
>> Y = multiplybytwo(X);
the object ``X`` is left unchanged, and the object ``Y`` is a
modified copy of ``X``.
modified copy of ``X`` (multiplied by two). This behaviour is
altered if the name of the method is postfixed with an
underscore. In this case the creation of a copy is avoided. For
instance, following the previous example, we would have::
>> X = 2;
>> X.multiplybytwo_();
>> X
4
Modifying the objects in place, with underscore methods, is
particularly useful if the methods are called in loops, since this
saves the object instantiation overhead.
|br|
.. datesmethod:: 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``
......@@ -282,21 +356,47 @@ The dates class
>> D = dates('1950Q1','1950Q2');
>> d = dates('1950Q3');
>> E = D.append(d);
>> F = D.append('1950Q3')
>> F = D.append('1950Q3');
>> isequal(E,F)
ans =
1
>> F
F = <dates: 1950Q1, 1950Q2, 1950Q3>
>> D
D = <dates: 1950Q1, 1950Q2>
>> D.append_('1950Q3')
ans = <dates: 1950Q1, 1950Q2, 1950Q3>
.. datesmethod:: B = char (A)
|br| Overloads the MATLAB/Octave ``char`` function. Converts a
``dates`` object into a character array.
*Example*
::
>> A = dates('1950Q1');
> A.char()
ans =
'1950Q1'
.. datesmethod:: C = colon (A, B)
C = colon (A, i, B)
|br| Overloads the Matlab/Octave colon (``:``) operator. A and B
are ``dates`` objects. The optional increment ``i`` is a
|br| Overloads the MATLAB/Octave colon (``:``) operator. A and
B are ``dates`` objects. The optional increment ``i`` is a
scalar integer (default value is ``i=1``). This method returns
a ``dates`` object and can be used to create ranges of dates.
......@@ -307,20 +407,50 @@ The dates class
>> A = dates('1950Q1');
>> B = dates('1951Q2');
>> C = A:B
C = <dates: 1950Q1, 1950Q2, 1950Q3, 1950Q4, 1951Q1>
>> D = A:2:B
D = <dates: 1950Q1, 1950Q3, 1951Q1>
.. datesmethod:: B = copy (A)
|br| Returns a copy of a ``dates`` object.
.. datesmethod:: disp (A)
|br| Overloads the MATLAB/Octave disp function for ``dates`` object.
.. datesmethod:: display (A)
|br| Overloads the MATLAB/Octave display function for ``dates`` object.
*Example*
::
>> disp(B)
B = <dates: 1950Q1, 1950Q2, 1950Q3, 1950Q4, 1951Q1, 1951Q2, 1951Q3, 1951Q4, 1952Q1, 1952Q2, 1952Q3>
>> display(B)
B = <dates: 1950Q1, 1950Q2, ..., 1952Q2, 1952Q3>
.. datesmethod:: B = double (A)
|br| Overloads the Matlab/Octave ``double`` function. ``A`` is
|br| Overloads the MATLAB/Octave ``double`` function. ``A`` is
a ``dates`` object. The method returns a floating point
representation of a ``dates`` object, the integer and
fractional parts respectively corresponding to the year and
the subperiod. The fractional part is the subperiod number
minus one divided by the frequency (``1``, ``4``, ``12`` or
``52``).
minus one divided by the frequency (``1``, ``4``, or ``12``).
*Example*:
......@@ -339,11 +469,11 @@ The dates class
.. datesmethod:: C = eq (A, B)
|br| Overloads the Matlab/Octave ``eq`` (equal, ``==``)
|br| Overloads the MATLAB/Octave ``eq`` (equal, ``==``)
operator. ``dates`` objects ``A`` and ``B`` must have the same
number of elements (say, ``n``). The returned argument is a
``n`` by ``1`` vector of zeros and ones. The i-th element of
``C`` is equal to ``1`` if and only if the dates ``A(i)`` and
``n`` by ``1`` vector of logicals. The i-th element of
``C`` is equal to ``true`` if and only if the dates ``A(i)`` and
``B(i)`` are the same.
*Example*
......@@ -356,17 +486,19 @@ The dates class
ans =
2x1 logical array
1
0
.. datesmethod:: C = ge (A, B)
|br| Overloads the Matlab/Octave ``ge`` (greater or equal,
|br| Overloads the MATLAB/Octave ``ge`` (greater or equal,
``>=``) operator. ``dates`` objects ``A`` and ``B`` must have
the same number of elements (say, ``n``). The returned
argument is a ``n`` by ``1`` vector of zeros and ones. The
i-th element of ``C`` is equal to ``1`` if and only if the
argument is a ``n`` by ``1`` vector of logicals. The
i-th element of ``C`` is equal to ``true`` if and only if the
date ``A(i)`` is posterior or equal to the date ``B(i)``.
*Example*
......@@ -379,16 +511,18 @@ The dates class
ans =
2x1 logical array
1
1
.. datesmethod:: C = gt (A, B)
|br| Overloads the Matlab/Octave ``gt`` (greater than, ``>``)
|br| Overloads the MATLAB/Octave ``gt`` (greater than, ``>``)
operator. ``dates`` objects ``A`` and ``B`` must have the same
number of elements (say, ``n``). The returned argument is a
``n`` by ``1`` vector of zeros and ones. The i-th element of
``n`` by ``1`` vector of logicals. The i-th element of
``C`` is equal to ``1`` if and only if the date ``A(i)`` is
posterior to the date ``B(i)``.
......@@ -402,13 +536,15 @@ The dates class
ans =
2x1 logical array
0
1
.. datesmethod:: D = horzcat (A, B, C, ...)
|br| Overloads the Matlab/Octave ``horzcat`` operator. All the
|br| Overloads the MATLAB/Octave ``horzcat`` operator. All the
input arguments must be ``dates`` objects. The returned
argument is a ``dates`` object gathering all the dates given
in the input arguments (repetitions are not removed).
......@@ -421,12 +557,13 @@ The dates class
>> B = dates('1950Q2');
>> C = [A, B];
>> C
C = <dates: 1950Q1, 1950Q2>
.. datesmethod:: C = intersect (A, B)
|br| Overloads the Matlab/Octave ``intersect`` function. All
|br| Overloads the MATLAB/Octave ``intersect`` function. All
the input arguments must be ``dates`` objects. The returned
argument is a ``dates`` object gathering all the common dates
given in the input arguments. If ``A`` and ``B`` are disjoint
......@@ -442,73 +579,63 @@ The dates class
>> B = dates('1951Q1'):dates('1951Q4');
>> C = intersect(A, B);
>> C
C = <dates: 1951Q1, 1951Q2, 1951Q3, 1951Q4>
.. datesmethod:: C = setdiff (A, B)
.. datesmethod:: B = isempty (A)
|br| Overloads the Matlab/Octave ``setdiff`` function. All the
input arguments must be ``dates`` objects. The returned
argument is a ``dates`` object all dates present in ``A`` but
not in ``B``. If ``A`` and ``B`` are disjoint ``dates``
objects, the function returns ``A``. Returned dates in
``dates`` object ``C`` are sorted by increasing order.
|br| Overloads the MATLAB/Octave ``isempty`` function.
*Example*
::
>> A = dates('1950Q1'):dates('1969Q4') ;
>> B = dates('1960Q1'):dates('1969Q4') ;
>> C = dates('1970Q1'):dates('1979Q4') ;
>> d1 = setdiff(d1,d2);
>> d2 = setdiff(d1,d3);
d1 = <dates: 1950Q1, 1950Q2, ..., 1959Q3, 1959Q4>
d2 = <dates: 1950Q1, 1950Q2, ..., 1969Q3, 1969Q4>
.. datesmethod:: B = isempty (A)
>> A = dates('1950Q1');
>> A.isempty()
|br| Overloads the Matlab/Octave ``isempty`` function for ``dates``
objects``.
ans =
*Example*
logical
::
0
>> A = dates('1950Q1'):dates('1951Q4');
>> A.isempty()
>> B = dates();
>> B.isempty()
ans =
0
logical
1
.. datesmethod:: C = isequal (A, B)
|br| Overloads the Matlab/Octave ``isequal`` function for
``dates`` objects.
|br| Overloads the MATLAB/Octave ``isequal`` function.
*Example*
::
>> A = dates('1950Q1'):dates('1951Q4');
>> isequal(A,A)
>> A = dates('1950Q1');
>> B = dates('1950Q2');
>> isequal(A, B)
ans =
1
logical
0
.. datesmethod:: C = le (A, B)
|br| Overloads the Matlab/Octave ``le`` (less or equal,
|br| Overloads the MATLAB/Octave ``le`` (less or equal,
``<=``) operator. ``dates`` objects ``A`` and ``B`` must have
the same number of elements (say, ``n``). The returned
argument is a ``n`` by ``1`` vector of zeros and ones. The
i-th element of ``C`` is equal to ``1`` if and only if the
date ``A(i)`` is not posterior to the date ``B(i)``.
argument is a ``n`` by ``1`` vector of logicals. The
i-th element of ``C`` is equal to ``true`` if and only if the
date ``A(i)`` is anterior or equal to the date ``B(i)``.
*Example*
......@@ -520,36 +647,37 @@ The dates class
ans =
2x1 logical array
1
0
.. datesmethod:: B = length (A)
|br| Overloads the Matlab/Octave ``length`` function. Returns the
number of dates in ``dates`` object ``A`` (``B`` is a scalar
integer).
|br| Overloads the MATLAB/Octave ``length`` function. Returns
the number of elements in a ``dates`` object.
*Example*
::
>> A = dates('1950Q1','1951Q2');
>> A = dates('1950Q1'):dates(2000Q3);
>> A.length()
ans =
2
203
.. datesmethod:: C = lt (A, B)
|br| Overloads the Matlab/Octave ``lt`` (less than, ``<``)
operator. ``dates`` objects ``A`` and ``B`` must have the same
number of elements (say, ``n``). The returned argument is a
``n`` by ``1`` vector of zeros and ones. The i-th element of
``C`` is equal to ``1`` if and only if the date ``A(i)``
preceeds the date ``B(i)``.
|br| Overloads the MATLAB/Octave ``lt`` (less than,
``<``) operator. ``dates`` objects ``A`` and ``B`` must have
the same number of elements (say, ``n``). The returned
argument is a ``n`` by ``1`` vector of logicals. The
i-th element of ``C`` is equal to ``true`` if and only if the
date ``A(i)`` is anterior or equal to the date ``B(i)``.
*Example*
......@@ -561,13 +689,15 @@ The dates class
ans =
2x1 logical array
0
0
.. datesmethod:: D = max (A, B, C, ...)
|br| Overloads the Matlab/Octave ``max`` function. All input
|br| Overloads the MATLAB/Octave ``max`` function. All input
arguments must be ``dates`` objects. The function returns a
single element ``dates`` object containing the greatest date.
......@@ -577,12 +707,13 @@ The dates class
>> A = {dates('1950Q2'), dates('1953Q4','1876Q2'), dates('1794Q3')};
>> max(A{:})
ans = <dates: 1953Q4>
.. datesmethod:: D = min (A, B, C, ...)
|br| Overloads the Matlab/Octave ``min`` function. All input
|br| Overloads the MATLAB/Octave ``min`` function. All input
arguments must be ``dates`` objects. The function returns a
single element ``dates`` object containing the smallest date.
......@@ -592,12 +723,13 @@ The dates class
>> A = {dates('1950Q2'), dates('1953Q4','1876Q2'), dates('1794Q3')};
>> min(A{:})
ans = <dates: 1794Q3>
.. datesmethod:: C = minus (A, B)
|br| Overloads the Matlab/Octave ``minus`` operator
|br| Overloads the MATLAB/Octave ``minus`` operator
(``-``). If both input arguments are ``dates`` objects, then
number of periods between ``A`` and ``B`` is returned (so that
``A+C=B``). If ``B`` is a vector of integers, the minus
......@@ -619,17 +751,35 @@ The dates class
0
>> d1-(-ee)
ans = <dates: 1950Q3, 1950Q4, 1960Q1>
.. datesmethod:: C = mtimes (A, B)
|br| Overloads the MATLAB/Octave ``mtimes`` operator
(``*``). ``A`` and ``B`` are respectively expected to be a
``dates`` object and a scalar integer. Returns ``dates``
object ``A`` replicated ``B`` times.
*Example*
::
>> d = dates('1950Q1');
>> d*2
ans = <dates: 1950Q1, 1950Q1>
.. datesmethod:: C = ne (A, B)
|br| Overloads the Matlab/Octave ``ne`` (not equal, ``~=``)
|br| Overloads the MATLAB/Octave ``ne`` (not equal, ``~=``)
operator. ``dates`` objects ``A`` and ``B`` must have the same
number of elements (say, ``n``) or one of the inputs must be a
single element ``dates`` object. The returned argument is a
``n`` by ``1`` vector of zeros and ones. The i-th element of
``C`` is equal to ``1`` if and only if the dates ``A(i)`` and
``n`` by ``1`` vector of logicals. The i-th element of
``C`` is equal to ``true`` if and only if the dates ``A(i)`` and
``B(i)`` are different.
*Example*
......@@ -642,19 +792,21 @@ The dates class
ans =
2x1 logical array
0
1
.. datesmethod:: C = plus (A, B)
|br| Overloads the Matlab/Octave ``plus`` operator (``+``). If
|br| Overloads the MATLAB/Octave ``plus`` operator (``+``). If
both input arguments are ``dates`` objects, then the method
combines ``A`` and ``B`` without removing repetitions. If
``B`` is a vector of integers, the ``plus`` operator shifts
the ``dates`` object by ``B`` periods forward.
:ex:
*Example*
::
......@@ -674,6 +826,8 @@ The dates class
.. datesmethod:: 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``
......@@ -685,15 +839,58 @@ The dates class
::
>> d1 = dates('1950Q1','1950Q2');
>> d1.pop()
>> d = dates('1950Q1','1950Q2');
>> d.pop()
ans = <dates: 1950Q1>
>> d1.pop(1)
>> d.pop_(1)
ans = <dates: 1950Q2>
.. datesmethod:: 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``.
*Example*
::
>> d = dates('1950Q1','1950Q2');
>> d.remove(dates('1950Q2'))
ans = <dates: 1950Q1>
.. datesmethod:: C = setdiff (A, B)
|br| Overloads the MATLAB/Octave ``setdiff`` function. All the
input arguments must be ``dates`` objects. The returned
argument is a ``dates`` object all dates present in ``A`` but
not in ``B``. If ``A`` and ``B`` are disjoint ``dates``
objects, the function returns ``A``. Returned dates in
``dates`` object ``C`` are sorted by increasing order.
*Example*
::
>> A = dates('1950Q1'):dates('1969Q4');
>> B = dates('1960Q1'):dates('1969Q4');
>> C = dates('1970Q1'):dates('1979Q4');
>> setdiff(A, B)
ans = <dates: 1950Q1, 1950Q2, ..., 1959Q3, 1959Q4>
>> setdiff(A, C)
ans = <dates: 1950Q1, 1950Q2, ..., 1969Q3, 1969Q4>
.. datesmethod:: B = sort (A)
sort_ ()
|br| Sort method for ``dates`` objects. Returns a ``dates`` object
with elements sorted by increasing order.
......@@ -704,12 +901,50 @@ The dates class
>> dd = dates('1945Q3','1938Q4','1789Q3');
>> dd.sort()
ans = <dates: 1789Q3, 1938Q4, 1945Q3>
.. datesmethod:: B = strings (A)
|br| Converts a ``dates`` object into a cell of char arrays.
*Example*
::
>> A = dates('1950Q1');
>> A = A:A+1;
>> A.strings()
ans =
1x2 cell array
{'1950Q1'} {'1950Q2'}
.. datesmethod:: B = subperiod (A)
|br| Returns the subperiod of a date (an integer scalar
between 1 and ``A.freq``). This method is not implemented for
daily dates.
*Example*
::
>> A = dates('1950Q2');
>> A.subperiod()
ans =
2
.. datesmethod:: B = uminus (A)
|br| Overloads the Matlab/Octave unary minus operator. Returns
|br| Overloads the MATLAB/Octave unary minus operator. Returns
a ``dates`` object with elements shifted one period backward.
*Example*
......@@ -718,12 +953,13 @@ The dates class
>> dd = dates('1945Q3','1938Q4','1973Q1');
>> -dd
ans = <dates: 1945Q2, 1938Q3, 1972Q4>
.. datesmethod:: D = union (A, B, C, ...)
|br| Overloads the Matlab/Octave ``union`` function. Returns a
|br| Overloads the MATLAB/Octave ``union`` function. Returns a
``dates`` object with elements sorted by increasing order
(repetitions are removed, to keep the repetitions use the
``horzcat`` or ``plus`` operators).
......@@ -735,12 +971,14 @@ The dates class
>> d1 = dates('1945Q3','1973Q1','1938Q4');
>> d2 = dates('1973Q1','1976Q1');
>> union(d1,d2)
ans = <dates: 1938Q4, 1945Q3, 1973Q1, 1976Q1>
.. datesmethod:: B = unique (A)
unique_ ()
|br| Overloads the Matlab/Octave ``unique`` function. Returns
|br| Overloads the MATLAB/Octave ``unique`` function. Returns
a ``dates`` object with repetitions removed (only the last
occurence of a date is kept).
......@@ -750,12 +988,13 @@ The dates class
>> d1 = dates('1945Q3','1973Q1','1945Q3');
>> d1.unique()
ans = <dates: 1973Q1, 1945Q3>
.. datesmethod:: B = uplus (A)
|br| Overloads the Matlab/Octave unary plus operator. Returns
|br| Overloads the MATLAB/Octave unary plus operator. Returns
a ``dates`` object with elements shifted one period ahead.
*Example*
......@@ -764,9 +1003,34 @@ The dates class
>> dd = dates('1945Q3','1938Q4','1973Q1');
>> +dd
ans = <dates: 1945Q4, 1939Q1, 1973Q2>
.. datesmethod:: D = vertcat (A, B, C, ...)
|br| Overloads the MATLAB/Octave ``horzcat`` operator. All the
input arguments must be ``dates`` objects. The returned
argument is a ``dates`` object gathering all the dates given
in the input arguments (repetitions are not removed).
.. datesmethod:: B = year (A)
|br| Returns the year of a date (an integer scalar
between 1 and ``A.freq``).
*Example*
::
>> A = dates('1950Q2');
>> A.subperiod()
ans =
1950
.. _dseries-members:
The dseries class
......@@ -774,20 +1038,18 @@ The dseries class
.. class:: dseries
|br| The Matlab/Octave ``dseries`` class handles time series
data. As any Matlab/Octave statements, this class can be used in a
|br| The MATLAB/Octave ``dseries`` class handles time series
data. As any MATLAB/Octave statements, this class can be used in a
Dynare’s mod file. A ``dseries`` object has six members:
:arg name: A ``nobs*1`` cell of strings or a ``nobs*p`` character
array, the names of the variables.
:arg tex: A ``nobs*1`` cell of strings or a ``nobs*p`` character
array, the tex names of the variables.
:arg name: A ``vobs*1`` cell of strings or a ``vobs*p`` character array, the names of the variables.
:arg tex: A ``vobs*1`` cell of strings or a ``vobs*p`` character array, the tex names of the variables.
:arg dates dates: An object with ``nobs`` elements, the dates of the sample.
:arg double data: A ``nobs`` by ``vobs`` array, the data.
:arg ops: The history of operations on the variables.
:arg tags: The user-defined tags on the variables.
``data``, ``name``, ``tex`` are private members. The following
``data``, ``name``, ``tex``, and ``ops`` are private members. The following
constructors are available:
.. construct:: dseries ()
......@@ -803,10 +1065,13 @@ The dseries class
data file specified by *FILENAME*, a string passed as
input. Valid file types are ``.m``, ``.mat``, ``.csv`` and
``.xls/.xlsx`` (Octave only supports ``.xlsx`` files and the
`io <http://octave.sourceforge.net/io/>`_ package from
Octave-Forge must be installed). A typical ``.m`` file will
have the following form::
`io <https://octave.sourceforge.io/io/>`__ package from
Octave-Forge must be installed). The extension of the file
should be explicitly provided.
A typical ``.m`` file will have the following form::
FREQ__ = 4;
INIT__ = '1994Q3';
NAMES__ = {'azert';'yuiop'};
TEX__ = {'azert';'yuiop'};
......@@ -815,15 +1080,25 @@ The dseries class
yuiop = randn(100,1);
If a ``.mat`` file is used instead, it should provide the same
informations. Note that the ``INIT__`` variable can be either
a ``dates`` object or a string which could be used to
instantiate the same ``dates`` object. If ``INIT__`` is not
provided in the ``.mat`` or ``.m`` file, the initial is by
default set equal to ``dates('1Y')``. If a second input
argument is passed to the constructor, ``dates`` object
*INITIAL_DATE*, the initial date defined in *FILENAME* is
reset to *INITIAL_DATE*. This is typically usefull if
``INIT__`` is not provided in the data file.
informations, except that the data should not be given as a
set of vectors, but as a single matrix of doubles named
``DATA__``. This array should have as many columns as elements
in ``NAMES__`` (the number of variables). Note that the
``INIT__`` variable can be either a ``dates`` object or a
string which could be used to instantiate the same ``dates``
object. If ``INIT__`` is not provided in the ``.mat`` or
``.m`` file, the initial is by default set equal to
``dates('1Y')``. If a second input argument is passed to the
constructor, ``dates`` object *INITIAL_DATE*, the initial date
defined in *FILENAME* is reset to *INITIAL_DATE*. This is
typically usefull if ``INIT__`` is not provided in the data
file.
If an ``.xlsx`` file is used, the first row should be a header
containing the variable names. The first column may contain date
information that must correspond to a valid date format recognized
by Dynare. If such date information is specified in the first column,
its header name must be left empty.
.. construct:: dseries (DATA_MATRIX[,INITIAL_DATE[,LIST_OF_NAMES[,TEX_NAMES]]])
dseries (DATA_MATRIX[,RANGE_OF_DATES[,LIST_OF_NAMES[,TEX_NAMES]]])
......@@ -849,6 +1124,13 @@ The dseries class
elements *RANGE_OF_DATES* or be equal to one (in which case
the single observation is replicated).
.. construct:: dseries (TABLE)
Creates a ``dseries`` object given the MATLAB Table provided as the sole
argument. It is assumed that the first column of the table contains the
dates of the ``dseries`` and the first row contains the names. This
feature is not available under Octave or MATLAB R2013a or earlier.
*Example*
Various ways to create a ``dseries`` object::
......@@ -871,10 +1153,13 @@ The dseries class
to the last observation, then ``ds(d)`` instantiates a new
``dseries`` object containing the subsample defined by ``d``.
A list of the available methods, by alphabetical order, is given below.
A list of the available methods, by alphabetical order, is given
below. As in the previous section the in place modifications
versions of the methods are postfixed with an underscore.
.. dseriesmethod:: A = abs (B)
abs_ ()
|br| Overloads the ``abs()`` function for ``dseries``
objects. Returns the absolute value of the variables in
......@@ -904,8 +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_ (B)
If ``dseries`` objects ``A`` and ``B`` are defined on
different time ranges, this function extends ``A`` and/or
......@@ -944,30 +1253,107 @@ The dseries class
2001Q1 | 0.17813
2001Q2 | 0.12801
>> ts0 = dseries(rand(5,1),dates('2000Q1')); % 2000Q1 -> 2001Q1
>> ts1 = dseries(rand(3,1),dates('2000Q4')); % 2000Q4 -> 2001Q2
>> align_(ts0, ts1); % 2000Q1 -> 2001Q2
>> ts1
.. dseriesmethod:: B = baxter_king_filter(A, hf, lf, K)
ts1 is a dseries object:
|br| Implementation of the *Baxter and King* (1999) band pass
filter for ``dseries`` objects. This filter isolates business
cycle fluctuations with a period of length ranging between
``hf`` (high frequency) to ``lf`` (low frequency) using a
symmetric moving average smoother with :math:`2K+1` points, so
that :math:`K` observations at the beginning and at the end of
the sample are lost in the computation of the filter. The
default value for ``hf`` is ``6``, for ``lf`` is ``32``, and
for ``K`` is ``12``.
| Variable_1
2000Q1 | NaN
2000Q2 | NaN
2000Q3 | NaN
2000Q4 | 0.66653
2001Q1 | 0.17813
2001Q2 | 0.12801
*Example*
*Example (in-place modification version)*
::
% Simulate a component model (stochastic trend, deterministic
% trend, and a stationary autoregressive process).
e = 0.2*randn(200,1);
u = randn(200,1);
stochastic_trend = cumsum(e);
deterministic_trend = .1*transpose(1:200);
x = zeros(200,1);
>> 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_ (B[, diff])
Backcasts ``dseries`` object ``A`` with ``dseries`` object B's
growth rates (except if the last optional argument, ``diff``,
is true in which case first differences are used). Both
``dseries`` objects must have the same frequency.
.. 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
cycle fluctuations with a period of length ranging between
``hf`` (high frequency) to ``lf`` (low frequency) using a
symmetric moving average smoother with :math:`2K+1` points, so
that :math:`K` observations at the beginning and at the end of
the sample are lost in the computation of the filter. The
default value for ``hf`` is ``6``, for ``lf`` is ``32``, and
for ``K`` is ``12``.
*Example*
::
% Simulate a component model (stochastic trend, deterministic
% trend, and a stationary autoregressive process).
e = 0.2*randn(200,1);
u = randn(200,1);
stochastic_trend = cumsum(e);
deterministic_trend = .1*transpose(1:200);
x = zeros(200,1);
for i=2:200
x(i) = .75*x(i-1) + u(i);
end
......@@ -990,7 +1376,17 @@ The dseries class
set(gca,'XTickLabel',strings(ts1.dates(id)));
.. dseriesmethod:: B = center (A[, geometric])
center_ ([geometric])
|br| Centers variables in ``dseries`` object ``A`` around their
arithmetic means, except if the optional argument ``geometric``
is set equal to ``true`` in which case all the variables are
divided by their geometric means.
.. dseriesmethod:: C = chain (A, B)
chain_ (B)
|br| Merge two ``dseries`` objects along the time
dimension. The two objects must have the same number of
......@@ -1003,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:
......@@ -1013,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:
......@@ -1035,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)
......@@ -1044,9 +1459,70 @@ The dseries class
error.
.. dseriesmethod:: B = copy (A)
|br| Returns a copy of ``A``. If an inplace modification method
is applied to ``A``, object ``B`` will not be affected. Note
that if ``A`` is assigned to ``C``, ``C = A``, then any in
place modification method applied to ``A`` will change ``C``.
*Example*
::
>> a = dseries(randn(5,1))
a is a dseries object:
| Variable_1
1Y | -0.16936
2Y | -1.1451
3Y | -0.034331
4Y | -0.089042
5Y | -0.66997
>> b = copy(a);
>> c = a;
>> a.abs();
>> a.abs_();
>> a
a is a dseries object:
| Variable_1
1Y | 0.16936
2Y | 1.1451
3Y | 0.034331
4Y | 0.089042
5Y | 0.66997
>> b
b is a dseries object:
| Variable_1
1Y | -0.16936
2Y | -1.1451
3Y | -0.034331
4Y | -0.089042
5Y | -0.66997
>> c
c is a dseries object:
| Variable_1
1Y | 0.16936
2Y | 1.1451
3Y | 0.034331
4Y | 0.089042
5Y | 0.66997
.. dseriesmethod:: B = cumprod (A[, d[, v]])
cumprod_ ([d[, v]])
|br| Overloads the Matlab/Octave ``cumprod`` function for
|br| Overloads the MATLAB/Octave ``cumprod`` function for
``dseries`` objects. The cumulated product cannot be computed
if the variables in ``dseries`` object ``A`` have NaNs. If a
``dates`` object ``d`` is provided as a second argument, then
......@@ -1107,8 +1583,9 @@ The dseries class
.. dseriesmethod:: B = cumsum (A[, d[, v]])
cumsum_ ([d[, v]])
|br| Overloads the Matlab/Octave ``cumsum`` function for
|br| Overloads the MATLAB/Octave ``cumsum`` function for
``dseries`` objects. The cumulated sum cannot be computed if
the variables in ``dseries`` object ``A`` have NaNs. If a
``dates`` object ``d`` is provided as a second argument, then
......@@ -1177,14 +1654,53 @@ The dseries class
10Y | 10.1416
.. dseriesmethod:: B = detrend (A[, m])
detrend_ ([m])
|br| Detrends ``dseries`` object ``A`` with a fitted
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_ ()
|br| Computes daily growth rates.
.. dseriesmethod:: B = diff (A)
diff_ ()
|br| Returns the first difference of ``dseries`` object ``A``.
.. datesmethod:: disp (A)
|br| Overloads the MATLAB/Octave disp function for ``dseries`` object.
.. datesmethod:: display (A)
|br| Overloads the MATLAB/Octave display function for
``dseries`` object. ``display`` is the function called by
MATLAB to print the content of an object if a semicolon is
missing at the end of a MATLAB statement. If the ``dseries``
object is defined over a too large time span, only the first
and last periods will be printed. If the ``dseries`` object
contains too many variables, only the first and last variables
will be printed. If all the periods and variables are
required, the ``disp`` method should be used instead.
.. dseriesmethod:: C = eq (A, B)
|br| Overloads the Matlab/Octave ``eq`` (equal, ``==``)
|br| Overloads the MATLAB/Octave ``eq`` (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 \times N`
matrix of zeros and ones. Element :math:`(i,j)` of ``C`` is
equal to ``1`` if and only if observation :math:`i` for
matrix of logicals. Element :math:`(i,j)` of ``C`` is
equal to ``true`` if and only if observation :math:`i` for
variable :math:`j` in ``A`` and ``B`` are the same.
*Example*
......@@ -1197,28 +1713,17 @@ The dseries class
ans =
3x1 logical array
1
0
1
.. dseriesmethod:: B = exp(A)
|br| Overloads the Matlab/Octave ``exp`` function for
``dseries`` objects.
*Example*
::
>> ts0 = dseries(rand(10,1));
>> ts1 = ts0.exp();
.. dseriesmethod:: l = exist (A, varname)
|br| Tests if variable exists in ``dseries`` object ``A``. Returns
``1`` (true) iff variable exists in ``A``.
|br| Tests if variable ``varname`` exists in ``dseries`` object ``A``. Returns
``true`` iff variable exists in ``A``.
*Example*
......@@ -1229,15 +1734,56 @@ The dseries class
ans =
logical
1
>> ts.exist('Variable_2')
ans =
logical
0
.. dseriesmethod:: B = exp (A)
exp_ (A)
|br| Overloads the MATLAB/Octave ``exp`` function for
``dseries`` objects.
*Example*
::
>> 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[, ...])
|br| Extracts some variables from a ``dseries`` object ``A``
......@@ -1247,7 +1793,7 @@ The dseries class
creation of sub-objects, the ``dseries`` class overloads the
curly braces (``D = extract (A, B, C)`` is equivalent to ``D =
A{B,C}``) and allows implicit loops (defined between a pair of
``@`` symbol, see examples below) or Matlab/Octave’s regular
``@`` symbol, see examples below) or MATLAB/Octave’s regular
expressions (introduced by square brackets).
*Example*
......@@ -1256,12 +1802,14 @@ The dseries class
>> ts0 = dseries(ones(100,10));
>> ts1 = ts0{'Variable_1','Variable_2','Variable_3'};
>> ts2 = ts0{'Variable_@1,2,3@'}
>> ts3 = ts0{'Variable_[1-3]$'}
>> ts2 = ts0{'Variable_@1,2,3@'};
>> ts3 = ts0{'Variable_[1-3]$'};
>> isequal(ts1,ts2) && isequal(ts1,ts3)
ans =
logical
1
It is possible to use up to two implicit loops to select variables::
......@@ -1283,7 +1831,55 @@ The dseries class
1973Q4 | -0.03705 | -0.35899 | 0.85838 | -1.4675 | -2.1666 | -0.62032
.. dseriesmethod:: f = freq(B)
.. 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 initial period in the ``dseries`` object ``A``.
.. dseriesmethod:: f = firstobservedperiod (A)
|br| Returns the first period where all the variables in ``dseries`` object ``A`` are observed (non NaN).
.. dseriesmethod:: B = flip (A)
flip_ (A)
|br| Flips the rows in the data member (without changing the
periods order).
.. dseriesmethod:: f = frequency (B)
|br| Returns the frequency of the variables in ``dseries`` object ``B``.
......@@ -1292,16 +1888,76 @@ The dseries class
::
>> ts = dseries(randn(3,2),'1973Q1');
>> ts.freq
>> ts.frequency
ans =
4
.. 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
|br| Overloads the ``horzcat`` MATLAB/Octave’s method for
``dseries`` objects. Returns a ``dseries`` object ``D``
containing the variables in ``dseries`` objects passed as
inputs: ``A, B, ...`` If the inputs are not defined on the
......@@ -1335,6 +1991,7 @@ The dseries class
.. dseriesmethod:: B = hpcycle (A[, lambda])
hpcycle_ ([lambda])
|br| Extracts the cycle component from a ``dseries`` ``A``
object using the *Hodrick and Prescott (1997)* filter and
......@@ -1375,6 +2032,7 @@ The dseries class
.. dseriesmethod:: B = 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
......@@ -1402,19 +2060,6 @@ The dseries class
set(gca,'XTickLabel',strings(ts0.dates(id)));
.. dseriesmethod:: f = init(B)
|br| Returns the initial date in ``dseries`` object ``B``.
*Example*
::
>> ts = dseries(randn(3,2),'1973Q1');
>> ts.init
ans = <dates: 1973Q1>
.. dseriesmethod:: C = insert (A, B, I)
|br| Inserts variables contained in ``dseries`` object ``B``
......@@ -1426,7 +2071,7 @@ The dseries class
defined over the same time ranges, but it is assumed that they
have common frequency.
:ex:
*Example*
::
......@@ -1452,21 +2097,44 @@ The dseries class
.. dseriesmethod:: B = isempty (A)
|br| Overloads the Matlab/octave’s ``isempty`` function. Returns
``1`` if ``dseries`` object ``A`` is empty, ``0`` otherwise.
|br| Overloads the MATLAB/octave’s ``isempty`` function. Returns
``true`` if ``dseries`` object ``A`` is empty.
.. dseriesmethod:: C = isequal (A, B)
|br| Overloads the Matlab/octave’s ``isequal`` function. Returns
``1`` if ``dseries`` objects ``A`` and ``B`` are identical, ``0``
otherwise.
|br| Overloads the MATLAB/octave’s ``isequal`` function. Returns
``true`` if ``dseries`` objects ``A`` and ``B`` are identical.
.. dseriesmethod:: C = isinf (A)
|br| Overloads the MATLAB/octave’s ``isinf`` function. Returns
a logical array, with element ``(i,j)`` equal to ``true`` if and
only if variable ``j`` is finite in period ``A.dates(i)``.
.. dseriesmethod:: C = isnan (A)
|br| Overloads the MATLAB/octave’s ``isnan`` function. Returns
a logical array, with element ``(i,j)`` equal to ``true`` if and
only if variable ``j`` isn't NaN in period ``A.dates(i)``.
.. dseriesmethod:: C = isreal (A)
|br| Overloads the MATLAB/octave’s ``isreal`` function. Returns
a logical array, with element ``(i,j)`` equal to ``true`` if and
only if variable ``j`` is real in period ``A.dates(i)``.
.. dseriesmethod:: B = lag (A[, p])
lag_ ([p])
Returns lagged time series. Default value of ``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*
......@@ -1486,7 +2154,7 @@ The dseries class
ts1 is a dseries object:
| lag(Variable_1,1)
| Variable_1
1950Q1 | NaN
1950Q2 | 1
1950Q3 | 2
......@@ -1496,7 +2164,7 @@ The dseries class
ts2 is a dseries object:
| lag(Variable_1,2)
| Variable_1
1950Q1 | NaN
1950Q2 | NaN
1950Q3 | 1
......@@ -1510,7 +2178,7 @@ The dseries class
ans is a dseries object:
| lag(Variable_1,1)
| Variable_1
1950Q1 | NaN
1950Q2 | 1
1950Q3 | 2
......@@ -1522,32 +2190,99 @@ The dseries class
ans is a dseries object:
| lag(Variable_1,1)
| Variable_1
1950Q1 | NaN
1950Q2 | 1
1950Q3 | 2
1950Q4 | 3
.. dseriesmethod:: l = last(B)
.. dseriesmethod:: l = lastdate (B)
|br| Returns the last date in ``dseries`` object ``B``.
|br| Retrieves the final period from the ``dseries`` object ``B``.
*Example*
::
>> ts = dseries(randn(3,2),'1973Q1');
>> ts.last
>> ts.lastdate()
ans = <dates: 1973Q3>
.. dseriesmethod:: f = lastobservedperiod (A)
|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 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_ ([p])
|br| Returns lead time series. Default value of ``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*
......@@ -1558,7 +2293,7 @@ The dseries class
ts1 is a dseries object:
| lead(Variable_1,1)
| Variable_1
1950Q1 | 2
1950Q2 | 3
1950Q3 | 4
......@@ -1568,7 +2303,7 @@ The dseries class
ts2 is a dseries object:
| lead(Variable_1,2)
| Variable_1
1950Q1 | 3
1950Q2 | 4
1950Q3 | NaN
......@@ -1576,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;
...
......@@ -1599,9 +2334,31 @@ The dseries class
in the ``model`` block is zero, but the residuals are non
zero).
.. dseriesmethod:: B = lineartrend (A)
|br| Returns a linear trend centered on 0, the length of the
trend is given by the size of ``dseries`` object ``A`` (the
number of periods).
*Example*
::
>> ts = dseries(ones(3,1));
>> ts.lineartrend()
ans =
-1
0
1
.. dseriesmethod:: B = log (A)
log_ ()
|br| Overloads the Matlab/Octave ``log`` function for
|br| Overloads the MATLAB/Octave ``log`` function for
``dseries`` objects.
*Example*
......@@ -1611,16 +2368,37 @@ The dseries class
>> ts0 = dseries(rand(10,1));
>> ts1 = ts0.log();
.. dseriesmethod:: B = mdiff (A)
mdiff_ ()
B = mgrowth (A)
mgrowth_ ()
|br| Calculates the monthly differences or growth rates of
variables in the ``dseries`` object ``A``.
.. dseriesmethod:: C = merge(A, B)
|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``.
.. dseriesmethod:: B = mean (A[, geometric])
|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``, 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*
......@@ -1631,66 +2409,66 @@ The dseries class
ts0 is a dseries object:
| A1 | A2
1950Q1 | 0.42448 | 0.92477
1950Q2 | 0.60726 | 0.64208
1950Q3 | 0.070764 | 0.1045
1950Q1 | 0.96284 | 0.5363
1950Q2 | 0.25145 | 0.31866
1950Q3 | 0.34447 | 0.4355
>> ts1 = dseries(rand(3,1),'1950Q2',{'A1'})
ts1 is a dseries object:
| A1
1950Q2 | 0.70023
1950Q3 | 0.3958
1950Q4 | 0.084905
1950Q2 | 0.40161
1950Q3 | 0.81763
1950Q4 | 0.97769
>> merge(ts0,ts1)
ans is a dseries object:
| A1 | A2
1950Q1 | NaN | 0.92477
1950Q2 | 0.70023 | 0.64208
1950Q3 | 0.3958 | 0.1045
1950Q4 | 0.084905 | NaN
1950Q1 | 0.96284 | 0.5363
1950Q2 | 0.40161 | 0.31866
1950Q3 | 0.81763 | 0.4355
1950Q4 | 0.97769 | NaN
>> merge(ts1,ts0)
ans is a dseries object:
| A1 | A2
1950Q1 | 0.42448 | 0.92477
1950Q2 | 0.60726 | 0.64208
1950Q3 | 0.070764 | 0.1045
1950Q4 | NaN | NaN
1950Q1 | 0.96284 | 0.5363
1950Q2 | 0.25145 | 0.31866
1950Q3 | 0.34447 | 0.4355
1950Q4 | 0.97769 | NaN
.. dseriesmethod:: C = minus (A, B)
|br| Overloads the ``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` 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
|br| Overloads the MATLAB/Octave ``minus`` (``-``) operator
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 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*
......@@ -1702,7 +2480,7 @@ The dseries class
ans is a dseries object:
| minus(Variable_1,Variable_2) | minus(Variable_2,Variable_2)
| Variable_1 | Variable_2
1Y | -0.48853 | 0
2Y | -0.50535 | 0
3Y | -0.32063 | 0
......@@ -1720,7 +2498,7 @@ The dseries class
ans is a dseries object:
| minus(Variable_2,0.703)
| Variable_2
1Y | 0
2Y | 0.051148
3Y | -0.15572
......@@ -1729,7 +2507,7 @@ The dseries class
ans is a dseries object:
| minus(0.703,Variable_2)
| Variable_2
1Y | 0
2Y | -0.051148
3Y | 0.15572
......@@ -1737,15 +2515,16 @@ The dseries class
.. dseriesmethod:: C = mpower (A, B)
|br| Overloads the ``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*
......@@ -1756,7 +2535,7 @@ The dseries class
ts1 is a dseries object:
| power(Variable_1,2)
| Variable_1
1Y | 1
2Y | 4
3Y | 9
......@@ -1765,7 +2544,7 @@ The dseries class
ts2 is a dseries object:
| power(Variable_1,Variable_1)
| Variable_1
1Y | 1
2Y | 4
3Y | 27
......@@ -1773,31 +2552,31 @@ The dseries class
.. dseriesmethod:: C = mrdivide (A, B)
|br| Overloads the ``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*
......@@ -1817,7 +2596,7 @@ The dseries class
ans is a dseries object:
| divide(Variable_1,Variable_2) | divide(Variable_2,Variable_2)
| Variable_1 | Variable_2
1Y | 0.80745 | 1
2Y | 4.2969 | 1
3Y | 0.59235 | 1
......@@ -1825,43 +2604,63 @@ The dseries class
.. dseriesmethod:: C = mtimes (A, B)
|br| Overloads the ``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 ``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.
|br| Overloads the MATLAB/Octave ``mtimes`` (``*``) operator
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 ``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. 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. 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.
|br| Overloads the MATLAB/Octave ``ne`` (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*
......@@ -1873,6 +2672,8 @@ The dseries class
ans =
3x1 logical array
0
1
0
......@@ -1895,32 +2696,55 @@ The dseries class
10
.. dseriesmethod:: B = onesidedhpcycle (A[, lambda[, init]])
onesidedhpcycle_ ([lambda[, init]])
|br| Extracts the cycle component from a ``dseries`` ``A``
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 (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)
h = plot (A, B)
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*
......@@ -1940,7 +2764,7 @@ The dseries class
If one wants to modify the properties of the plotted time
series (line style, colours, ...), the set function can be
used (see Matlab’s documentation)::
used (see MATLAB’s documentation)::
>> set(h(1),'-k','linewidth',2);
>> set(h(2),'--r');
......@@ -1960,37 +2784,38 @@ The dseries class
.. dseriesmethod:: C = plus (A, B)
|br| Overloads the ``plus`` (``+``) operator for ``dseries``
objects, element by element addition. 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 ``plus`` 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
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 length
:math:`T_A`, then the ``plus`` method will add ``B`` to all
the variables.
|br| Overloads the MATLAB/Octave ``plus`` (``+``) operator for
``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`
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 ``plus`` operator will compute for
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 “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,\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_ ([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*
......@@ -2007,8 +2832,42 @@ The dseries class
3Y | 1 | 1
.. dseriesmethod:: A = projection (A, info, periods)
|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*
::
>> data = ones(10,4);
>> ts = dseries(data, '1990Q1', {'A1', 'A2', 'A3', 'A4'});
>> info = {'A1', 'Trend', 1.2; 'A2', 'Constant', 0.0; 'A3', 'AR', .5; 'A4', 'AR', [.4, -.2]};
>> ts.projection(info, 10);
.. dseriesmethod:: B = qdiff (A)
B = qgrowth (A)
qdiff_ ()
qgrowth_ ()
|br| Computes quarterly differences or growth rates.
......@@ -2021,7 +2880,7 @@ The dseries class
ts1 is a dseries object:
| qdiff(Variable_1)
| Variable_1
1950Q1 | NaN
1950Q2 | 1
1950Q3 | 1
......@@ -2032,7 +2891,7 @@ The dseries class
ts1 is a dseries object:
| qdiff(Variable_1)
| Variable_1
1950M1 | NaN
1950M2 | NaN
1950M3 | NaN
......@@ -2042,9 +2901,14 @@ The dseries class
.. dseriesmethod:: C = remove (A, B)
remove_ (B)
|br| Alias for the ``pop`` method with two arguments. Removes
variable ``B`` from ``dseries`` object ``A``.
|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*
......@@ -2060,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@'} = [];
......@@ -2075,9 +2939,13 @@ The dseries class
.. dseriesmethod:: B = rename (A, oldname, newname)
rename_ (oldname, newname)
|br| Rename variable ``oldname`` to ``newname`` in ``dseries``
object ``A``. Returns a ``dseries`` object.``
|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*
......@@ -2094,40 +2962,80 @@ The dseries class
.. dseriesmethod:: C = 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 cells as ``A`` has ``dseries``. 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*
::
>> ts0 = dseries(ones(2,3));
>> ts1 = ts0.rename({'Tree','Worst','President'})
>> ts1 = ts0.rename({'TinkyWinky','Dipsy','LaaLaa'})
ts1 is a dseries object:
| Bush | Worst | President
| TinkyWinky | Dipsy | LaaLaa
1Y | 1 | 1 | 1
2Y | 1 | 1 | 1
.. dseriesmethod:: A = resetops (A, ops)
|br| Redefine ``ops`` member.
.. dseriesmethod:: A = resetags (A, ops)
|br| Redefine ``tags`` member.
.. dseriesmethod:: B = round (A[, n])
round_ ([n])
|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*
::
>> ts = dseries(pi)
ts is a dseries object:
| Variable_1
1Y | 3.1416
>> ts.round_();
>> ts
ts is a dseries object:
| Variable_1
1Y | 3
.. dseriesmethod:: save (A, basename[, format])
|br| Overloads the Matlab/Octave ``save`` function and saves
``dseries`` object ``A`` to disk. Possible formats are ``csv``
(this is the default), ``m`` (Matlab/Octave script), and
``mat`` (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*
::
>> ts0 = dseries(ones(2,2));
>> ts0.save('ts0');
>> ts0.save('ts0', 'csv');
The last command will create a file ts0.csv with the
following content::
......@@ -2136,7 +3044,7 @@ The dseries class
1Y, 1, 1
2Y, 1, 1
To create a Matlab/Octave script, the following command::
To create a MATLAB/Octave script, the following command::
>> ts0.save('ts0','m');
......@@ -2149,6 +3057,8 @@ The dseries class
NAMES__ = {'Variable_1'; 'Variable_2'};
TEX__ = {'Variable_{1}'; 'Variable_{2}'};
OPS__ = {};
TAGS__ = struct();
Variable_1 = [
1
......@@ -2165,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*
......@@ -2188,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*
......@@ -2208,23 +3119,74 @@ The dseries class
1 3
.. dseriesmethod:: B = std (A[, geometric])
|br| Overloads the MATLAB/Octave ``std`` function for
``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 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*
::
>> o = dseries(transpose(1:5));
>> o.subsample(dates('2y'),dates('4y'))
ans is a dseries object:
| Variable_1
2Y | 2
3Y | 3
4Y | 4
.. dseriesmethod:: A = tag (A, a[, b, c])
|br| Adds a tag to a variable in ``dseries`` object ``A``.
*Example*
::
>> ts = dseries(randn(10, 3));
>> tag(ts, 'type'); % Define a tag name.
>> tag(ts, 'type', 'Variable_1', 'Stock');
>> tag(ts, 'type', 'Variable_2', 'Flow');
>> tag(ts, 'type', 'Variable_3', 'Stock');
.. dseriesmethod:: B = tex_rename (A, name, newtexname)
B = 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*
......@@ -2241,19 +3203,19 @@ The dseries class
ts1 is a dseries object:
| -Variable_1
| Variable_1
1Y | -1
.. 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*
......@@ -2274,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*
......@@ -2291,5 +3252,393 @@ The dseries class
.. dseriesmethod:: B = ydiff (A)
B = ygrowth (A)
ydiff_ ()
ygrowth_ ()
|br| Calculates annual differences or growth rates.
.. _x13-members:
X-13 ARIMA-SEATS interface
==========================
.. class:: x13
|br| The x13 class provides a method for each X-13 command as
documented in the X-13 ARIMA-SEATS reference manual (`x11`,
`automdl`, `estimate`, ...). The respective options (see Chapter 7 of U.S. Census Bureau (2020))
can then be passed by key/value pairs. The ``x13`` class has 22 members:
:arg y: ``dseries`` object with a single variable.
:arg x: ``dseries`` object with an arbitrary number of variables (to be used in the REGRESSION block).
:arg arima: structure containing the options of the ARIMA model command.
:arg automdl: structure containing the options of the ARIMA model selection command.
:arg regression: structure containing the options of the Regression command.
:arg estimate: structure containing the options of the estimation command.
:arg transform: structure containing the options of the transform command.
:arg outlier: structure containing the options of the outlier command.
:arg forecast: structure containing the options of the forecast command.
:arg check: structure containing the options of the check command.
:arg x11: structure containing the options of the X11 command.
:arg force: structure containing the options of the force command.
:arg history: structure containing the options of the history command.
:arg metadata: structure containing the options of the metadata command.
:arg identify: structure containing the options of the identify command.
:arg pickmdl: structure containing the options of the pickmdl command.
:arg seats: structure containing the options of the seats command.
:arg slidingspans: structure containing the options of the slidingspans command.
:arg spectrum: structure containing the options of the spectrum command.
:arg x11regression: structure containing the options of the x11Regression command.
:arg results: structure containing the results returned by x13.
:arg commands: cell array containing the list of commands.
All these members are private. The following constructors are available:
.. construct:: x13 (y)
|br| Instantiates an ``x13`` object with `dseries` object
``y``. The ``dseries`` object passed as an argument must
contain only one variable, the one we need to pass to X-13.
.. construct:: x13 (y, x)
|br| Instantiates an ``x13`` object with `dseries` objects
``y`` and ``x``. The first ``dseries`` object passed as an
argument must contain only one variable, the second
``dseries`` object contains the exogenous variables used by
some of the X-13 commands. Both objects must be defined on the
same time span.
The following methods allow to set sequence of X-13 commands, write an `.spc` file, and run the X-13 binary:
.. x13method:: A = arima (A, key, value[, key, value[, [...]]])
Interface to the ``arima`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = automdl (A, key, value[, key, value[, [...]]])
Interface to the ``automdl`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = regression (A, key, value[, key, value[, [...]]])
Interface to the ``regression`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = estimate (A, key, value[, key, value[, [...]]])
Interface to the ``estimate`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = transform (A, key, value[, key, value[, [...]]])
Interface to the ``transform`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs. For example, the key/value pair ``function,log``
instructs the use of a multiplicative instead of an additive seasonal pattern,
while ``function,auto`` triggers an automatic selection between the two based
on their fit.
.. x13method:: A = outlier (A, key, value[, key, value[, [...]]])
Interface to the ``outlier`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = forecast (A, key, value[, key, value[, [...]]])
Interface to the ``forecast`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = check (A, key, value[, key, value[, [...]]])
Interface to the ``check`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = x11 (A, key, value[, key, value[, [...]]])
Interface to the ``x11`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = force (A, key, value[, key, value[, [...]]])
Interface to the ``force`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = history (A, key, value[, key, value[, [...]]])
Interface to the ``history`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = metadata (A, key, value[, key, value[, [...]]])
Interface to the ``metadata`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = identify (A, key, value[, key, value[, [...]]])
Interface to the ``identify`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = pickmdl (A, key, value[, key, value[, [...]]])
Interface to the ``pickmdl`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = seats (A, key, value[, key, value[, [...]]])
Interface to the ``seats`` command, see the X-13 ARIMA-SEATS
reference manual. All the options must be passed by key/value
pairs.
.. x13method:: A = slidingspans (A, key, value[, key, value[, [...]]])
Interface to the ``slidingspans`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = spectrum (A, key, value[, key, value[, [...]]])
Interface to the ``spectrum`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: A = x11regression (A, key, value[, key, value[, [...]]])
Interface to the ``x11regression`` command, see the X-13
ARIMA-SEATS reference manual. All the options must be passed
by key/value pairs.
.. x13method:: print (A[, basefilename])
Prints an ``.spc`` file with all the X-13 commands. The
optional second argument is a row char array specifying the
name (without extension) of the file.
.. x13method:: run (A)
Calls the X-13 binary and run the previously defined
commands. All the results are stored in the structure
``A.results``. When it makes sense these results are saved in
``dseries`` objects (*e.g.* for forecasts or filtered variables).
.. x13method:: clean (A)
Removes the temporary files created by an x13 run that store the intermediate
results. This method allows keeping the main folder clean but will also
delete potentially important debugging information.
*Example*
::
>> ts = dseries(rand(100,1),'1999M1');
>> o = x13(ts);
>> o.x11('save','(d11)');
>> o.automdl('savelog','amd','mixed','no');
>> o.outlier('types','all','save','(fts)');
>> o.check('maxlag',24,'save','(acf pcf)');
>> o.estimate('save','(mdl est)');
>> o.forecast('maxlead',18,'probability',0.95,'save','(fct fvr)');
>> o.run();
The above example shows a run of X13 with various commands an options specified.
*Example*
::
% 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
y = [112 115 145 171 196 204 242 284 315 340 360 417 ... % Jan
118 126 150 180 196 188 233 277 301 318 342 391 ... % Feb
132 141 178 193 236 235 267 317 356 362 406 419 ... % Mar
129 135 163 181 235 227 269 313 348 348 396 461 ... % Apr
121 125 172 183 229 234 270 318 355 363 420 472 ... % May
135 149 178 218 243 264 315 374 422 435 472 535 ... % Jun
148 170 199 230 264 302 364 413 465 491 548 622 ... % Jul
148 170 199 242 272 293 347 405 467 505 559 606 ... % Aug
136 158 184 209 237 259 312 355 404 404 463 508 ... % Sep
119 133 162 191 211 229 274 306 347 359 407 461 ... % Oct
104 114 146 172 180 203 237 271 305 310 362 390 ... % Nov
118 140 166 194 201 229 278 306 336 337 405 432 ]'; % Dec
ts = dseries(y,'1949M1');
o = x13(ts);
o.transform('function','auto','savelog','atr');
o.automdl('savelog','all');
o.x11('save','(d11 d10)');
o.run();
o.clean();
y_SA=o.results.d11;
y_seasonal_pattern=o.results.d10;
figure('Name','Comparison raw data and SAed data');
plot(ts.dates,log(o.y.data),ts.dates,log(y_SA.data),ts.dates,log(y_seasonal_pattern.data))
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
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``
into ``dseries`` with the respective names in the output structure ``o.results``. ``o.clean()`` removes the
temporary files created by ``o.run()``. Among these are the ``.log``-file storing
summary information, the ``.err``-file storing information on problems encountered,
the ``.out``-file storing the raw output, and the `.spc`-file storing the specification for the `x11` run.
There may be further files depending on the output requested. The last part of the example reads out the
results and plots a comparison of the logged raw data and its log-additive decomposition into a
seasonal pattern and the seasonally adjusted series.
Miscellaneous
=============
Time aggregation
----------------
|br| A set of functions allows to convert time series to lower frequencies:
- ``dseries2M`` converts daily time series object to monthly
time series object.
- ``dseries2Q`` converts daily or monthly time series object
to quarterly time series object.
- ``dseries2S`` converts daily, monthly, or quarterly time
series object to bi-annual time series object.
- ``dseries2Y`` converts daily, monthly, quarterly, or
bi-annual time series object to annual time series object.
|br| All these routines have two mandatory input arguments: the first one is a
``dseries`` object, the second one the name (row char array) of the
aggregation method. Possible values for the second argument are:
- ``arithmetic-average`` (for growth rates),
- ``geometric-average`` (for growth factors),
- ``sum`` (for flow variables), and
- ``end-of-period`` (for stock variables).
*Example*
::
>> ts = dseries(rand(12,1),'2000M1')
ts is a dseries object:
| Variable_1
2000M1 | 0.55293
2000M2 | 0.14228
2000M3 | 0.38036
2000M4 | 0.39657
2000M5 | 0.57674
2000M6 | 0.019402
2000M7 | 0.57758
2000M8 | 0.9322
2000M9 | 0.10687
2000M10 | 0.73215
2000M11 | 0.97052
2000M12 | 0.60889
>> ds = dseries2Y(ts, 'end-of-period')
ds is a dseries object:
| Variable_1
2000Y | 0.60889
Create time series with a univariate model
------------------------------------------
|br| It is possible to expand a ``dseries`` object recursively
with the ``from`` command. For instance to create a ``dseries`` object
containing the simulation of an ARMA(1,1) model:
::
|br| Computes yearly differences or growth rates.
>> e = dseries(randn(100, 1), '2000Q1', 'e', '\varepsilon');
>> y = dseries(zeros(100, 1), '2000Q1', 'y');
>> from 2000Q2 to 2024Q4 do y(t)=.9*y(t-1)+e(t)-.4*e(t-1);
>> y
y is a dseries object:
| y
2000Q1 | 0
2000Q2 | -0.95221
2000Q3 | -0.6294
2000Q4 | -1.8935
2001Q1 | -1.1536
2001Q2 | -1.5905
2001Q3 | 0.97056
2001Q4 | 1.1409
2002Q1 | -1.9255
2002Q2 | -0.29287
|
2022Q2 | -1.4683
2022Q3 | -1.3758
2022Q4 | -1.2218
2023Q1 | -0.98145
2023Q2 | -0.96542
2023Q3 | -0.23203
2023Q4 | -0.34404
2024Q1 | 1.4606
2024Q2 | 0.901
2024Q3 | 2.4906
2024Q4 | 0.79661
The expression following the ``do`` keyword can be any univariate
equation, the only constraint is that the model cannot have
leads. It can be a static equation, or a very nonlinear backward
equation with an arbitrary number of lags. The ``from`` command
must be followed by a range, which is separated from the
(recursive) expression to be evaluated by the ``do`` command.
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2019 Dynare Team
# Copyright © 2018-2024 Dynare Team
#
# This file is part of Dynare.
#
......@@ -15,7 +15,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
# along with Dynare. If not, see <https://www.gnu.org/licenses/>.
"""
sphinx.domains.dynare
......@@ -34,7 +34,7 @@ from docutils.parsers.rst import Directive, directives
from sphinx import addnodes
from sphinx.domains import Domain, ObjType
from sphinx.locale import l_, _
from sphinx.locale import _
from sphinx.directives import ObjectDescription
from sphinx.roles import XRefRole
from sphinx.util.nodes import make_refnode
......@@ -80,9 +80,7 @@ class DynObject(ObjectDescription):
signode += addnodes.desc_name(name, name)
if self.has_arguments:
if not arglist:
signode += addnodes.desc_parameterlist()
else:
if arglist:
signode += addnodes.desc_addname(arglist,arglist)
return fullname, prefix
......@@ -99,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)
......@@ -121,6 +119,8 @@ class DynObject(ObjectDescription):
return _('%s (dates method)') % name
elif self.objtype == 'dseriesmethod':
return _('%s (dseries method)') % name
elif self.objtype == 'x13method':
return _('%s (x13 method)') % name
elif self.objtype == 'reportingmethod':
return _('%s (reporting method)') % name
elif self.objtype == 'matcomm':
......@@ -140,14 +140,14 @@ class DynCallable(DynObject):
has_arguments = True
doc_field_types = [
TypedField('arguments', label=l_('Arguments'),
TypedField('arguments', label=_('Arguments'),
names=('argument', 'arg', 'parameter', 'param'),
typerolename='func', typenames=('paramtype', 'type')),
Field('returnvalue', label=l_('Returns'), has_arg=False,
Field('returnvalue', label=_('Returns'), has_arg=False,
names=('returns', 'return')),
Field('returntype', label=l_('Return type'), has_arg=False,
Field('returntype', label=_('Return type'), has_arg=False,
names=('rtype',)),
Field('example', label=l_('Example'), has_arg=False,
Field('example', label=_('Example'), has_arg=False,
names=('ex',)),
]
......@@ -157,10 +157,10 @@ class DynClass(DynObject):
allow_nesting = True
doc_field_types = [
TypedField('members', label=l_('Members'),
TypedField('members', label=_('Members'),
names=('argument', 'arg', ),
typerolename='func', typenames=('type', )),
Field('example', label=l_('Example'), has_arg=False,
Field('example', label=_('Example'), has_arg=False,
names=('ex',)),
]
......@@ -176,6 +176,10 @@ class DseriesMethod(DynCallable):
display_prefix = 'Method: '
allow_nesting = True
class X13Method(DynCallable):
display_prefix = 'Method: '
allow_nesting = True
class ReportingMethod(DynCallable):
display_prefix = 'Method: '
allow_nesting = True
......@@ -238,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)
......@@ -291,27 +295,29 @@ class DynareDomain(Domain):
name = 'dynare'
label = 'Dynare'
object_types = {
'function': ObjType(l_('function'), 'func'),
'datesmethod': ObjType(l_('method'), 'datmeth'),
'dseriesmethod': ObjType(l_('method'), 'dsermeth'),
'reportingmethod': ObjType(l_('method'), 'repmeth'),
'matcomm': ObjType(l_('matlab command'), 'mcomm'),
'command': ObjType(l_('command'), 'comm'),
'class': ObjType(l_('class'), 'class'),
'block': ObjType(l_('block'), 'bck'),
'confblock': ObjType(l_('config block'), 'cbck'),
'macrodir': ObjType(l_('macro directive'), 'mdir'),
'construct': ObjType(l_('constructor'), 'cstr'),
'matvar': ObjType(l_('matlab variable'), 'mvar'),
'specvar': ObjType(l_('special variable'), 'svar'),
'operator': ObjType(l_('operator'), 'op'),
'constant': ObjType(l_('constant'), 'const'),
'option': ObjType(l_('option'), 'opt'),
'function': ObjType(_('function'), 'func'),
'datesmethod': ObjType(_('method'), 'datmeth'),
'dseriesmethod': ObjType(_('method'), 'dsermeth'),
'x13method': ObjType(_('method'), 'x13meth'),
'reportingmethod': ObjType(_('method'), 'repmeth'),
'matcomm': ObjType(_('matlab command'), 'mcomm'),
'command': ObjType(_('command'), 'comm'),
'class': ObjType(_('class'), 'class'),
'block': ObjType(_('block'), 'bck'),
'confblock': ObjType(_('config block'), 'cbck'),
'macrodir': ObjType(_('macro directive'), 'mdir'),
'construct': ObjType(_('constructor'), 'cstr'),
'matvar': ObjType(_('matlab variable'), 'mvar'),
'specvar': ObjType(_('special variable'), 'svar'),
'operator': ObjType(_('operator'), 'op'),
'constant': ObjType(_('constant'), 'const'),
'option': ObjType(_('option'), 'opt'),
}
directives = {
'function': DynFunction,
'datesmethod': DatesMethod,
'dseriesmethod': DseriesMethod,
'x13method': X13Method,
'reportingmethod': ReportingMethod,
'matcomm': MatComm,
'command': DynComm,
......@@ -330,6 +336,7 @@ class DynareDomain(Domain):
'func': DynareXRefRole(),
'datmeth': DynareXRefRole(),
'dsermeth': DynareXRefRole(),
'x13meth': DynareXRefRole(),
'repmeth': DynareXRefRole(),
'mcomm': DynareXRefRole(),
'comm': DynareXRefRole(),
......
# Copyright (C) 2018-2019 Dynare Team
# Copyright © 2018-2021 Dynare Team
#
# This file is part of Dynare.
#
......@@ -13,7 +13,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dynare. If not, see <http://www.gnu.org/licenses/>.
# along with Dynare. If not, see <https://www.gnu.org/licenses/>.
import re
......@@ -36,8 +36,8 @@ class DynareLexer(RegexLexer):
"dynare","var","varexo","varexo_det","parameters","change_type","model_local_variable",
"predetermined_variables","trend_var","log_trend_var","external_function",
"write_latex_original_model","write_latex_dynamic_model",
"write_latex_static_model","resid","initval_file","histval_file","dsample",
"periods","values","corr","steady","check","model_diagnostics","model_info",
"write_latex_static_model","write_latex_steady_state_model","resid","initval_file","histval_file","dsample",
"periods","values","scales","corr","stderr","steady","check","model_diagnostics","model_info",
"print_bytecode_dynamic_model"," print_bytecode_static_model",
"perfect_foresight_setup","perfect_foresight_solver","simul","stoch_simul",
"extended_path","varobs","estimation","unit_root_vars","bvar_density",
......@@ -52,13 +52,15 @@ class DynareLexer(RegexLexer):
"save_params_and_steady_state","load_params_and_steady_state",
"dynare_version","write_latex_definitions","write_latex_parameter_table",
"write_latex_prior_table","collect_latex_files","prior_function",
"posterior_function","generate_trace_plots")
"posterior_function","generate_trace_plots","evaluate_planner_objective",
"occbin_setup","occbin_solver","occbin_write_regimes","occbin_graph","method_of_moments",
"var_model","trend_component_model","var_expectation_model","pac_model")
report_commands = ("report","addPage","addSection","addGraph","addTable",
"addSeries","addParagraph","addVspace","write","compile")
operators = (
"STEADY_STATE","EXPECTATION")
"STEADY_STATE","EXPECTATION","var_expectation","pac_expectation","pac_target_nonstationary")
macro_dirs = (
"@#includepath", "@#include", "@#define", "@#if",
......@@ -70,17 +72,21 @@ class DynareLexer(RegexLexer):
tokens = {
'root': [
(r'\s*(%|//).*$', Comment),
(r'\s*(%|//).*$', Comment.Single),
(r'/(\\\n)?[*][\w\W]*?[*](\\\n)?/', Comment.Multiline),
(words((
'model','steady_state_model','initval','endval','histval',
'model','steady_state_model','initval','endval','histval','epilogue',
'shocks','mshocks','homotopy_setup','observation_trends',
'estimated_params','estimated_params_init','estimated_params_bounds',
'shock_groups','conditional_forecast_paths','optim_weights',
'osr_params_bounds','ramsey_constraints','irf_calibration',
'moment_calibration','identification','svar_identification',
'verbatim','end','node','cluster','paths','hooks'), prefix=r'\b', suffix=r'\s*\b'),Keyword.Reserved),
'matched_moments','occbin_constraints','surprise','overwrite','bind','relax',
'verbatim','end','node','cluster','paths','hooks','target','pac_target_info','auxname_target_nonstationary',
'component', 'growth', 'auxname', 'kind'), prefix=r'\b', suffix=r'\s*\b'),Keyword.Reserved),
# FIXME: Commands following multiline comments are not highlighted properly.
(words(commands + report_commands,
prefix=r'\b', suffix=r'\s*\b'), Name.Entity),
......@@ -92,7 +98,6 @@ class DynareLexer(RegexLexer):
(r'\s*[a-zA-Z_]\s*', Name),
(r'\s*(\d+\.\d+|\d*\.\d+)([eEf][+-]?[0-9]+)?\s*', Number.Float),
(r'\s*\d+[eEf][+-]?[0-9]+\s*', Number.Float),
(r'\s*\d+\s*', Number.Integer),
......
version = u'@PACKAGE_VERSION@'
release = u'@PACKAGE_VERSION@'
if HAVE_PDFLATEX
if HAVE_BIBTEX
pdf-local: parallel.pdf
endif
endif
SRC = AvenueParadigm.pdf iVaNo_gain.pdf iVaNo_time_comp.pdf marco.bib \
netbook_complete_comp.pdf netbook_complete_openclose.pdf \
netbook_partial_comp.pdf netbook_partial_openclose.pdf parallel.tex \
quest_complete_comp.pdf quest_complete_openclose.pdf quest_partial_comp.pdf \
quest_partial_openclose.pdf RWMH_quest1_PriorsAndPosteriors1Comp.pdf \
RWMH_quest1_PriorsAndPosteriors2Comp.pdf \
RWMH_quest1_PriorsAndPosteriors3Comp.pdf \
RWMH_quest1_PriorsAndPosteriors4Comp.pdf \
RWMH_quest1_PriorsAndPosteriors5Comp.pdf \
RWMH_quest1_PriorsAndPosteriors6Comp.pdf \
RWMH_quest1_PriorsAndPosteriors7Comp.pdf waitbars1.pdf waitbars2.pdf \
waitbarsP.pdf
EXTRA_DIST = $(SRC)
parallel.pdf: $(SRC)
$(PDFLATEX) parallel
$(BIBTEX) parallel
$(PDFLATEX) parallel
$(PDFLATEX) parallel
$(PDFLATEX) parallel
clean-local:
rm -f *.log *.aux *.toc *.blg *.bbl *.out
rm -f parallel.pdf
% ----------------------------------------------------------------
% AMS-LaTeX Paper ************************************************
% **** -----------------------------------------------------------
\documentclass[12pt,a4paper,pdftex,nofootinbib]{article}
\usepackage[cp1252]{inputenc}
\documentclass[12pt,a4paper,pdftex]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amssymb,amsmath}
\usepackage[pdftex]{graphicx}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{natbib}
\usepackage{verbatim}
\usepackage[pdftex]{color}
\usepackage{xcolor}
\usepackage{psfrag}
\usepackage{setspace}
\usepackage{rotating}
......@@ -49,6 +50,15 @@
\def \supp{{\rm supp}}
\def \var{{\rm var}}
\usepackage[pdfpagelabels]{hyperref}
\hypersetup{
pdfproducer = {LaTeX},
colorlinks,
linkcolor=blue,
filecolor=yellow,
urlcolor=green,
citecolor=green}
% ----------------------------------------------------------------
\begin{document}
......@@ -179,7 +189,7 @@ We have considered the following DYNARE components suitable to be parallelized u
\item the Random Walk- (and the analogous Independent-)-Metropolis-Hastings algorithm with multiple chains: the different chains are completely independent and do not require any communication between them, so it can be executed on different cores/CPUs/Computer Network easily;
\item a number of procedures performed after the completion of Metropolis, that use the posterior MC sample:
\begin{enumerate}
\item the diagnostic tests for the convergence of the Markov Chain \\(\texttt{McMCDiagnostics.m});
\item the diagnostic tests for the convergence of the Markov Chain \\(\texttt{mcmc\_diagnostics.m});
\item the function that computes posterior IRF's (\texttt{posteriorIRF.m}).
\item the function that computes posterior statistics for filtered and smoothed variables, forecasts, smoothed shocks, etc.. \\ (\verb"prior_posterior_statistics.m").
\item the utility function that loads matrices of results and produces plots for posterior statistics (\texttt{pm3.m}).
......@@ -248,7 +258,7 @@ The configuration file is designed as follows:
The list of slave options includes:
\begin{description}
\item[Name]: name of the node;
\item[CPUnbr]: this is the number of CPU's to be used on that computer; if \verb"CPUnbr" is a vector of integers, the syntax is \verb"[s:d]", with \verb"d>=s" (\verb"d, s" are integer); the first core has number 1 so that, on a quad-core, use \verb"4" to use all cores, but use \verb [3:4] to specify just the last two cores (this is particularly relevant for Windows where it is possible to assign jobs to specific processors);
\item[CPUnbr]: this is the number of CPU's to be used on that computer; if \verb"CPUnbr" is a vector of integers, the syntax is \verb"[s:d]", with \verb"d>=s" (\verb"d, s" are integer); the first core has number 1 so that, on a quad-core, use \verb"4" to use all cores, but use \verb"[3:4]" to specify just the last two cores (this is particularly relevant for Windows where it is possible to assign jobs to specific processors);
\item[ComputerName]: Computer name on the network or IP address; use the NETBIOS name under Windows\footnote{In Windows XP it is possible find this name in 'My Computer' $->$ mouse right click $->$ 'Property' $->$ 'Computer Name'.}, or the DNS name under Unix.;
\item[UserName]: required for remote login; in order to assure proper communications between the master and the slave threads, it must be the same user name actually logged on the `master' machine. On a Windows network, this is in the form \verb"DOMAIN\username", like \verb"DEPT\JohnSmith", i.e. user JohnSmith in windows group DEPT;
\item[Password]: required for remote login (only under Windows): it is the user password on \verb"DOMAIN" and \verb"ComputerName";
......@@ -349,7 +359,7 @@ Finally, the DYNARE command line options are:
\item \verb"parallel": trigger the parallel computation using the first cluster specified in config file
\item \verb"parallel=<clustername>": trigger the parallel computation, using the given cluster
\item \verb"parallel_slave_open_mode": use the leaveSlaveOpen mode in the cluster
\item \verb"parallel_test": just test the cluster, don’t actually run the MOD file
\item \verb"parallel_test": just test the cluster, don't actually run the MOD file
\end{itemize}
......@@ -616,10 +626,10 @@ MatlabOctavePath = matlab
In this section we describe what happens when the user omits a mandatory entry or provides bad values for them and how DYNARE reacts in these cases. In the parallel package there is a utility (\verb"AnalyseComputationalEnvironment.m") devoted to this task (this is triggered by the command line option \verb"parallel_test"). When necessary during the discussion, we use the \verb"parallel" entries used in the previous examples.
%Le parti in rosa sono una possibile reazione ad un errore che può accadere … vanno concordate e quindi magari riviste.
%Le parti in rosa sono una possibile reazione ad un errore che può accadere vanno concordate e quindi magari riviste.
\begin{description}
%\item[Local:] if no value is given for this variable the execution is stopped when DYNARE starts. More serious if we give a bad value (i.e. for example -1, 3), DYNARE will be stopped after some time with no error message! In these cases the Dynare …
%\item[Local:] if no value is given for this variable the execution is stopped when DYNARE starts. More serious if we give a bad value (i.e. for example -1, 3), DYNARE will be stopped after some time with no error message!
\item[ComputerName:] If \verb"Local=0", DYNARE checks if the computer \verb"vonNeumann" exists and if it is possible communicate with it. If this is not the case, an error message is generated and the computation is stopped.
\item[CPUnbr:] a value for this variable must be in the form \verb"[s:d]" with \verb"d>=s". If the user types values \verb"s>d", their order is flipped and a warning message is sent. When the user provides a correct value for this field, DYNARE checks if \verb"d" CPUs (or cores) are available on the computer. Suppose that this check returns an integer \verb"nC". We can have three possibilities:
\begin{enumerate}
......@@ -634,7 +644,8 @@ In this section we describe what happens when the user omits a mandatory entry o
\subsection{The Developers perspective}
%L'esposizione nel seguito (e anche in alcuni punti su) dipende molto da come il pacchetto parallelo viene rilasciato in Dynare, e quindi se PsTools viene installato durante l'installazione di Dynare oppure no, se le directory necessarie alla computazione vengono create durante l'installazione di Dynare oppure no. E cose così ...
%L'esposizione nel seguito (e anche in alcuni punti su) dipende molto da come il pacchetto parallelo viene rilasciato in Dynare, e quindi se PsTools viene installato durante l'installazione di Dynare oppure no, se le directory necessarie alla computazione vengono create durante l'installazione di Dynare oppure no. E cose così ...
In this section we describe with some accuracy the DYNARE parallel routines.
\begin{description}
......@@ -715,8 +726,8 @@ So far, we have parallelized the following functions, by selecting the most comp
\verb"independent_metropolis_hastings.m", \\
\verb"independent_metropolis_hastings_core.m";
\item the cycle looping over estimated parameters computing univariate diagnostics:\\
\verb"McMCDiagnostics.m", \\
\verb"McMCDiagnostics_core.m";
\verb"mcmc_diagnostics.m", \\
\verb"mcmc_diagnostics_core.m";
\item the Monte Carlo cycle looping over posterior parameter subdraws performing the IRF simulations (\verb"<*>_core1") and the cycle looping over exogenous shocks plotting IRF's charts (\verb"<*>_core2"):\\
\verb"posteriorIRF.m", \\\verb"posteriorIRF_core1.m", \verb"posteriorIRF_core2.m";
\item the Monte Carlo cycle looping over posterior parameter subdraws, that computes filtered, smoothed, forecasted variables and shocks:\\
......@@ -828,7 +839,7 @@ The modified \verb"random_walk_metropolis_hastings.m" is therefore:
\noindent\begin{tabular}[b]{| p{\linewidth} |}
\hline
\begin{verbatim}
function random_walk_metropolis_hastings(TargetFun,ProposalFun,…,varargin)
function random_walk_metropolis_hastings(TargetFun,ProposalFun,\ldots,varargin)
[...]
% here we wrap all local variables needed by the <*>_core function
localVars = struct('TargetFun', TargetFun, ...
......@@ -896,7 +907,7 @@ waitbarString = [ '(' int2str(b) '/' int2str(mh_nblck) ') ...
if mod(j, 3)==0 & ~whoiam
% serial computation
waitbar(prtfrc,hh,waitbarString);
waitbar(prtfrc,hh_fig,waitbarString);
elseif mod(j,50)==0 & whoiam,
% parallel computation
......@@ -961,20 +972,20 @@ On the other hand, under the parallel implementation, a parallel monitoring plot
%[...]
%\end{verbatim}
%Non so se può andare bene impostata in questo modo … se va bene la concludo.
%Non so se può andare bene impostata in questo modo se va bene la concludo.
%
%2.
%Prendiamo il tutto il lavoro fatto per arrivare a parallellizzare la PosteriorIRF,
%Traacianti, anlisi computazionale … commentiamo bene tutte le funzioni coinvolte e le usiamo qui …
%Traacianti, anlisi computazionale commentiamo bene tutte le funzioni coinvolte e le usiamo qui
\section{Parallel DYNARE: testing}
We checked the new parallel platform for DYNARE performing a number of tests, using different models and computer architectures. We present here all tests performed with Windows Xp/Matlab. However, similar tests were performed successfully under Linux/Ubuntu environment.
In the Bayesian estimation of DSGE models with DYNARE, most of the computing time is devoted to the posterior parameter estimation with the Metropolis algorithm. The first and second tests are therefore focused on the parallelization of the Random Walking Metropolis Hastings algorithm (Sections \ref{s:test1}-\ref{s:test2}). In addition, further tests (Sections \ref{s:test3}-\ref{s:test4}) are devoted to test all the parallelized functions in DYNARE. Finally, we compare the two parallel implementations of the Metropolis Hastings algorithms, available in DYNARE: the Independent and the Random Walk (Section \ref{s:test5}).
We checked the new parallel platform for DYNARE performing a number of tests, using different models and computer architectures. We present here all tests performed with Windows XP/MATLAB. However, similar tests were performed successfully under Linux/Ubuntu environment.
In the Bayesian estimation of DSGE models with DYNARE, most of the computing time is devoted to the posterior parameter estimation with the Metropolis algorithm. The first and second tests are therefore focused on the parallelization of the Random Walking Metropolis Hastings algorithm (Sections \ref{s:test1}-\ref{s:test2}). In addition, further tests (Sections \ref{s:test3}-\ref{s:test4}) are devoted to test all the parallelized functions in DYNARE. %Finally, we compare the two parallel implementations of the Metropolis Hastings algorithms, available in DYNARE: the Independent and the Random Walk (Section \ref{s:test5}).
\subsection{Test 1.}\label{s:test1}
The main goal here was to evaluate the parallel package on a \emph{fixed hardware platform} and using chains of \emph{variable length}. The model used for testing is a modification of \cite{Hradisky_etal_2006}. This is a small scale open economy DSGE model with 6 observed variables, 6 endogenous variables and 19 parameters to be estimated.
We estimated the model on a bi-processor machine (Fujitsu Siemens, Celsius R630) powered with an Intel(R) Xeon(TM) CPU 2.80GHz Hyper Treading Technology; first with the original serial Metropolis and subsequently using the parallel solution, to take advantage of the two processors technology. We ran chains of increasing length: 2500, 5000, 10,000, 50,000, 100,000, 250,000, 1,000,000.
We estimated the model on a bi-processor machine (Fujitsu Siemens, Celsius R630) powered with an Intel\textsuperscript{\textregistered} Xeon\texttrademark CPU 2.80GHz Hyper Treading Technology; first with the original serial Metropolis and subsequently using the parallel solution, to take advantage of the two processors technology. We ran chains of increasing length: 2500, 5000, 10,000, 50,000, 100,000, 250,000, 1,000,000.
\begin{figure}[!ht]
\begin{centering}
......@@ -997,8 +1008,8 @@ Overall results are given in Figure \ref{fig:test_time_comp}, showing the comput
The scope of the second test was to verify if results were robust over different hardware platforms.
We estimated the model with chain lengths of 1,000,000 runs on the following hardware platforms:
\begin{itemize}
\item Single processor machine: Intel(R) Pentium4(R) CPU 3.40GHz with Hyper Treading Technology (Fujitsu-Siemens Scenic Esprimo);
\item Bi-processor machine: two CPU's Intel(R) Xeon(TM) 2.80GHz Hyper Treading Technology (Fujitsu-Siemens, Celsius R630);
\item Single processor machine: Intel\textsuperscript{\textregistered} Pentium4\textsuperscript{\textregistered} CPU 3.40GHz with Hyper Treading Technology (Fujitsu-Siemens Scenic Esprimo);
\item Bi-processor machine: two CPU's Intel\textsuperscript{\textregistered} Xeon\texttrademark 2.80GHz Hyper Treading Technology (Fujitsu-Siemens, Celsius R630);
\item Dual core machine: Intel Centrino T2500 2.00GHz Dual Core (Fujitsu-Siemens, LifeBook S Series).
\end{itemize}
......@@ -1042,7 +1053,7 @@ Unplugged network cable. &
Given the excellent results reported above, we have parallelized many other DYNARE functions. This implies that parallel instances can be invoked many times during a single DYNARE session. Under the basic parallel toolbox implementation, that we call the `Open/Close' strategy, this implies that MATLAB instances are opened and closed many times by system calls, possibly slowing down the computation, specially for `entry-level' computer resources. As mentioned before, this suggested to implement an alternative strategy for the parallel toolbox, that we call the `Always-Open' strategy, where the slave MATLAB threads, once opened, stay alive and wait for new tasks assigned by the master until the full DYNARE procedure is completed. We show next the tests of these latest implementations.
\subsection{Test 3}\label{s:test3}
In this Section we use the \cite{Lubik2003} model as test function\footnote{The \cite{Lubik2003} model is also selected as the `official' test model for the parallel toolbox in DYNARE.} and a very simple computer class, quite diffuse nowadays: Netbook personal Computer. In particular we used the Dell Mini 10 with Processor Intel® Atom™ Z520 (1,33 GHz, 533 MHz), 1 GB di RAM (with Hyper-trading). First, we tested the computational gain of running a full Bayesian estimation: Metropolis (two parallel chains), MCMC diagnostics, posterior IRF's and filtered, smoothed, forecasts, etc. In other words, we designed DYNARE sessions that invoke all parallelized functions. Results are shown in Figures \ref{fig:netbook_complete_openclose}-\ref{fig:netbook_partial_openclose}.
In this Section we use the \cite{Lubik2003} model as test function\footnote{The \cite{Lubik2003} model is also selected as the `official' test model for the parallel toolbox in DYNARE.} and a very simple computer class, quite diffuse nowadays: Netbook personal Computer. In particular we used the Dell Mini 10 with Processor Intel\textsuperscript{\textregistered} Atom\texttrademark Z520 (1,33 GHz, 533 MHz), 1 GB di RAM (with Hyper-trading). First, we tested the computational gain of running a full Bayesian estimation: Metropolis (two parallel chains), MCMC diagnostics, posterior IRF's and filtered, smoothed, forecasts, etc. In other words, we designed DYNARE sessions that invoke all parallelized functions. Results are shown in Figures \ref{fig:netbook_complete_openclose}-\ref{fig:netbook_partial_openclose}.
\begin{figure}[p]
\begin{centering}
% Requires \usepackage{graphicx}
......@@ -1143,49 +1154,49 @@ The methodology identified for parallelizing MATLAB codes within DYNARE proved t
\begin{figure}
\begin{centering}
% Requires \usepackage{graphicx}
\epsfxsize=250pt \epsfbox{RWMH_quest1_PriorsAndPosteriors1Comp.pdf}
\epsfxsize=300pt \epsfbox{RWMH_quest1_PriorsAndPosteriors1Comp.pdf}
\caption{Prior (grey lines) and posterior density of estimated parameters (black = 100,000 runs; red = 1,000,000 runs) using the RWMH algorithm \citep[QUEST III model][]{Ratto_et_al_EconModel2009}.}\label{fig:quest_RWMH_comp1}
\end{centering}
\end{figure}
\begin{figure}
\begin{centering}
% Requires \usepackage{graphicx}
\epsfxsize=250pt \epsfbox{RWMH_quest1_PriorsAndPosteriors2Comp.pdf}
\epsfxsize=300pt \epsfbox{RWMH_quest1_PriorsAndPosteriors2Comp.pdf}
\caption{Prior (grey lines) and posterior density of estimated parameters (black = 100,000 runs; red = 1,000,000 runs) using the RWMH algorithm \citep[QUEST III model][]{Ratto_et_al_EconModel2009}.}\label{fig:quest_RWMH_comp2}
\end{centering}
\end{figure}
\begin{figure}
\begin{centering}
% Requires \usepackage{graphicx}
\epsfxsize=250pt \epsfbox{RWMH_quest1_PriorsAndPosteriors3Comp.pdf}
\epsfxsize=300pt \epsfbox{RWMH_quest1_PriorsAndPosteriors3Comp.pdf}
\caption{Prior (grey lines) and posterior density of estimated parameters (black = 100,000 runs; red = 1,000,000 runs) using the RWMH algorithm \citep[QUEST III model][]{Ratto_et_al_EconModel2009}.}\label{fig:quest_RWMH_comp3}
\end{centering}
\end{figure}
\begin{figure}
\begin{centering}
% Requires \usepackage{graphicx}
\epsfxsize=250pt \epsfbox{RWMH_quest1_PriorsAndPosteriors4Comp.pdf}
\epsfxsize=300pt \epsfbox{RWMH_quest1_PriorsAndPosteriors4Comp.pdf}
\caption{Prior (grey lines) and posterior density of estimated parameters (black = 100,000 runs; red = 1,000,000 runs) using the RWMH algorithm \citep[QUEST III model][]{Ratto_et_al_EconModel2009}.}\label{fig:quest_RWMH_comp4}
\end{centering}
\end{figure}
\begin{figure}
\begin{centering}
% Requires \usepackage{graphicx}
\epsfxsize=250pt \epsfbox{RWMH_quest1_PriorsAndPosteriors5Comp.pdf}
\epsfxsize=300pt \epsfbox{RWMH_quest1_PriorsAndPosteriors5Comp.pdf}
\caption{Prior (grey lines) and posterior density of estimated parameters (black = 100,000 runs; red = 1,000,000 runs) using the RWMH algorithm \citep[QUEST III model][]{Ratto_et_al_EconModel2009}.}\label{fig:quest_RWMH_comp5}
\end{centering}
\end{figure}
\begin{figure}
\begin{centering}
% Requires \usepackage{graphicx}
\epsfxsize=250pt \epsfbox{RWMH_quest1_PriorsAndPosteriors6Comp.pdf}
\epsfxsize=300pt \epsfbox{RWMH_quest1_PriorsAndPosteriors6Comp.pdf}
\caption{Prior (grey lines) and posterior density of estimated parameters (black = 100,000 runs; red = 1,000,000 runs) using the RWMH algorithm \citep[QUEST III model][]{Ratto_et_al_EconModel2009}.}\label{fig:quest_RWMH_comp6}
\end{centering}
\end{figure}
\begin{figure}
\begin{centering}
% Requires \usepackage{graphicx}
\epsfxsize=250pt \epsfbox{RWMH_quest1_PriorsAndPosteriors7Comp.pdf}
\epsfxsize=300pt \epsfbox{RWMH_quest1_PriorsAndPosteriors7Comp.pdf}
\caption{Prior (grey lines) and posterior density of estimated parameters (black = 100,000 runs; red = 1,000,000 runs) using the RWMH algorithm \citep[QUEST III model][]{Ratto_et_al_EconModel2009}.}\label{fig:quest_RWMH_comp7}
\end{centering}
\end{figure}
......
File moved