diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index b7c2848..a7cca00 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2024-05-24T20:35:09","documenter_version":"1.4.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.4","generation_timestamp":"2024-06-24T12:41:05","documenter_version":"1.4.1"}} \ No newline at end of file diff --git a/dev/index.html b/dev/index.html index 0e25c6f..152b54a 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Home · Dynare.jl

The Dynare Julia Reference Manual

Introduction

DynareJulia is a rewriting of Dynare (https://www.dynare.org) that was initially written in Gauss in 1994 and rewritten in Matlab around 2000.

Dynare provides several algorithms to work with Dynamic Stochastic General Equilibrium (DSGE) models often used in macroeconomics. Among other features, it helps

  • solving such models,
  • simulating them,
  • estimating the parameters,
  • making forecasts.

The user of the package writes a text file, usually with an .mod extension, that contains the equations of the model and the computation tasks. Then, DynareJulia compiles the model and runs the computations.

DynareJulia honors a subset of commands valid in DynareMatlab. Tell us if one of your favorite command or option is missing.

For many computing tasks, DynareJulia provides also Julia functions that can be used in the *.mod file or issued interactively after having run the *.mod file. These Julia functions use keyword arguments for the options and you need only to enter them if you want to change the default value. The keyword arguments without a default value are required arguments. In the sections of this documentation, the Dynare Commands are presented first, then the Julia functions.

Dynare has benefited from many contributions over the years. Here is a list of the contributors:

The Dynare Team

Currently the development team of Dynare is composed of:

  • Stéphane Adjemian (Le Mans Université, Gains)
  • Michel Juillard (Banque de France)
  • Sumudu Kankanamge (Toulouse School of Economics and CEPREMAP)
  • Frédéric Karamé (Le Mans Université, Gains and CEPREMAP)
  • Junior Maih (Norges Bank)
  • Willi Mutschler (University of Tübingen)
  • Johannes Pfeifer (Universität der Bundeswehr München)
  • Marco Ratto (European Commission, Joint Research Centre - JRC)
  • Normann Rion (CY Cergy Paris Université and CEPREMAP)
  • Sébastien Villemot (CEPREMAP)

The following people contribute or have contributed to DynareJulia

  • Satyanarayana Bade
  • Petre Caraiani
  • Lilith Hafner
  • Michel Juillard
  • Félix Ordoñez
  • Louis Ponet
  • Rohit Singh Rathaur
  • Dawie van Lill

The following people used to be members of the Dynare team:

  • Houtan Bastani
  • Abdeljabar Benzougar
  • Alejandro Buesa
  • Fabrice Collard
  • Assia Ezzeroug
  • Dóra Kocsis
  • Stéphane Lhuissier
  • Ferhat Mihoubi
  • George Perendia

Copyright © 1996-2023, 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 https://www.gnu.org/licenses/fdl.txt.

+Home · Dynare.jl

The Dynare Julia Reference Manual

Introduction

DynareJulia is a rewriting of Dynare (https://www.dynare.org) that was initially written in Gauss in 1994 and rewritten in Matlab around 2000.

Dynare provides several algorithms to work with Dynamic Stochastic General Equilibrium (DSGE) models often used in macroeconomics. Among other features, it helps

  • solving such models,
  • simulating them,
  • estimating the parameters,
  • making forecasts.

The user of the package writes a text file, usually with an .mod extension, that contains the equations of the model and the computation tasks. Then, DynareJulia compiles the model and runs the computations.

DynareJulia honors a subset of commands valid in DynareMatlab. Tell us if one of your favorite command or option is missing.

For many computing tasks, DynareJulia provides also Julia functions that can be used in the *.mod file or issued interactively after having run the *.mod file. These Julia functions use keyword arguments for the options and you need only to enter them if you want to change the default value. The keyword arguments without a default value are required arguments. In the sections of this documentation, the Dynare Commands are presented first, then the Julia functions.

Dynare has benefited from many contributions over the years. Here is a list of the contributors:

The Dynare Team

Currently the development team of Dynare is composed of:

  • Stéphane Adjemian (Le Mans Université, Gains)
  • Michel Juillard (Banque de France)
  • Sumudu Kankanamge (Toulouse School of Economics and CEPREMAP)
  • Frédéric Karamé (Le Mans Université, Gains and CEPREMAP)
  • Junior Maih (Norges Bank)
  • Willi Mutschler (University of Tübingen)
  • Johannes Pfeifer (Universität der Bundeswehr München)
  • Marco Ratto (European Commission, Joint Research Centre - JRC)
  • Normann Rion (CY Cergy Paris Université and CEPREMAP)
  • Sébastien Villemot (CEPREMAP)

The following people contribute or have contributed to DynareJulia

  • Satyanarayana Bade
  • Petre Caraiani
  • Lilith Hafner
  • Michel Juillard
  • Félix Ordoñez
  • Louis Ponet
  • Rohit Singh Rathaur
  • Dawie van Lill

The following people used to be members of the Dynare team:

  • Houtan Bastani
  • Abdeljabar Benzougar
  • Alejandro Buesa
  • Fabrice Collard
  • Assia Ezzeroug
  • Dóra Kocsis
  • Stéphane Lhuissier
  • Ferhat Mihoubi
  • George Perendia

Copyright © 1996-2023, 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 https://www.gnu.org/licenses/fdl.txt.

diff --git a/dev/installation-and-configuration/index.html b/dev/installation-and-configuration/index.html index eef176c..34bcc45 100644 --- a/dev/installation-and-configuration/index.html +++ b/dev/installation-and-configuration/index.html @@ -1,3 +1,3 @@ Installation and Configuration · Dynare.jl

Installation and configuration

Software requirements

Dynare is available for all plateforms supported by the current stable version of Julia (https://julialang.org/downloads/#supported_platforms). It should also work with older versions of Julia starting with version 1.6.3

Installation of Dynare

In Julia, install the Dynare.jl package:

using Pkg
-pkg"add Dynare"

Using Dynare

In order to start using Dynare in Julia, type

using Dynare

Optional extensions

Pardiso

If you want the solution of very large perfect foresight models and reduce the memory consumption, use the Pardiso package (https://github.com/JuliaSparse/Pardiso.jl) and type

using MKL, Pardiso

PATHSolver

If youw want to solve perfect foresight models with occasionally binding constraints use the PATHSolver package (https://github.com/chkwon/PATHSolver.jl) and type

using PATHSolver
+pkg"add Dynare"

Using Dynare

In order to start using Dynare in Julia, type

using Dynare

Optional extensions

Pardiso

If you want the solution of very large perfect foresight models and reduce the memory consumption, use the Pardiso package (https://github.com/JuliaSparse/Pardiso.jl) and type

using MKL, Pardiso

PATHSolver

If youw want to solve perfect foresight models with occasionally binding constraints use the PATHSolver package (https://github.com/chkwon/PATHSolver.jl) and type

using PATHSolver
diff --git a/dev/macroprocessor/index.html b/dev/macroprocessor/index.html index f1ec746..6fcf8dd 100644 --- a/dev/macroprocessor/index.html +++ b/dev/macroprocessor/index.html @@ -145,4 +145,4 @@ % Anything contained in this block will be passed % directly to the <modfile>.m file, including comments var = 1; - end;

Misc commands

Command: `saveparamsandsteadystate (FILENAME);

For all parameters, endogenous and exogenous variables, stores their value in a text file, using a simple name/value associative table.

Note that no variable type is stored in the file, so that the values can be reloaded with load_params_and_steady_state in a setup where the variable types are different.

The typical usage of this function is to compute the steady-state of a model by calibrating the steady-state value of some endogenous variables (which implies that some parameters must be endogeneized during the steady-state computation).

You would then write a first .mod file which computes the steady state and saves the result of the computation at the end of the file, using save_params_and_steady_state.

In a second file designed to perform the actual simulations, you would use load_params_and_steady_state just after your variable declarations, in order to load the steady state previously computed (including the parameters which had been endogeneized during the steady state computation).

The need for two separate .mod files arises from the fact that the variable declarations differ between the files for steady state calibration and for simulation (the set of endogenous and parameters differ between the two); this leads to different var and parameters statements.

Also note that you can take advantage of the @#include directive to share the model equations between the two files (see macro-proc-lang).

For all parameters, endogenous and exogenous variables, loads their value from a file created with save_params_and_steady_state.

This function is used in conjunction with save_params_and_steady_state; see the documentation of that function for more information.

+ end;

Misc commands

Command: `saveparamsandsteadystate (FILENAME);

For all parameters, endogenous and exogenous variables, stores their value in a text file, using a simple name/value associative table.

Note that no variable type is stored in the file, so that the values can be reloaded with load_params_and_steady_state in a setup where the variable types are different.

The typical usage of this function is to compute the steady-state of a model by calibrating the steady-state value of some endogenous variables (which implies that some parameters must be endogeneized during the steady-state computation).

You would then write a first .mod file which computes the steady state and saves the result of the computation at the end of the file, using save_params_and_steady_state.

In a second file designed to perform the actual simulations, you would use load_params_and_steady_state just after your variable declarations, in order to load the steady state previously computed (including the parameters which had been endogeneized during the steady state computation).

The need for two separate .mod files arises from the fact that the variable declarations differ between the files for steady state calibration and for simulation (the set of endogenous and parameters differ between the two); this leads to different var and parameters statements.

Also note that you can take advantage of the @#include directive to share the model equations between the two files (see macro-proc-lang).

For all parameters, endogenous and exogenous variables, loads their value from a file created with save_params_and_steady_state.

This function is used in conjunction with save_params_and_steady_state; see the documentation of that function for more information.

diff --git a/dev/model-file/deterministic-simulations/index.html b/dev/model-file/deterministic-simulations/index.html index f04e1f4..0c8a2fa 100644 --- a/dev/model-file/deterministic-simulations/index.html +++ b/dev/model-file/deterministic-simulations/index.html @@ -8,9 +8,9 @@ Jacobian singular.
Example

Consider the following specification of an Euler equation with log utility:

Lambda = beta*C(-1)/C;
 Lambda(+1)*R(+1)= 1;

Clearly, the derivative of the second equation with respect to all endogenous variables at time t is zero, causing perfect_foresight_solver to generally fail. This is due to the use of the Lagrange multiplier Lambda as an auxiliary variable. Instead, employing the identical

beta*C/C(+1)*R(+1)= 1;

will work.

Julia function

Dynare.perfect_foresight!Function
perfect_foresight!(; periods, context = context, display = true,
                    linear_solve_algo=ilu, maxit = 50, mcp = false,
-                   tolf = 1e-5, tolx = 1e-5)

Keyword arguments

  • periods::Int: number of periods in the simulation [required]
  • context::Context=context: context in which the simulation is computed
  • display::Bool=true: whether to display the results
  • linear_solve_algo::LinearSolveAlgo=ilu: algorithm used for the solution of the linear problem. Either ilu or pardiso. ilu is the sparse linear solver used by default in Julia. To use the Pardiso solver, write using Pardiso before running Dynare.
  • maxit::Int=50 maximum number of iterations
  • mcp::Bool=falseL whether to solve a mixed complementarity problem with occasionally binding constraints
  • tolf::Float64=1e-5: tolerance for the norm of residualts
  • tolx::Float64=1e-5: tolerance for the norm of the change in the result
source
Output

The simulated endogenous variables are available in context.results.model_results[1].simulations. This is a vector of AxisArrayTable, one for each simulations stored in context. Each AxisArrayTable contains the trajectories for endogenous and exogenous variables

Solving mixed complementarity problems

requires a particular model setup as the goal is to get rid of any min/max operators and complementary slackness conditions that might introduce a singularity into the Jacobian. This is done by attaching an equation tag (see model-decl) with the mcp keyword to affected equations. The format of the mcp tag is

[mcp = 'VARIABBLENAME OP CONSTANT']

where VARIABLENAME is an endogenous variable and OP is either > or <. For complicated occasionally binding constraints, it may be necessary to declare a new endogenous variable.

This tag states that the equation to which the tag is attached has to hold unless the expression within the tag is binding. For instance, a ZLB on the nominal interest rate would be specified as follows in the model block:

    model;
+                   tolf = 1e-5, tolx = 1e-5)

Keyword arguments

source
Output

The simulated endogenous variables are available in context.results.model_results[1].simulations. This is a vector of AxisArrayTable, one for each simulations stored in context. Each AxisArrayTable contains the trajectories for endogenous and exogenous variables

Solving mixed complementarity problems

requires a particular model setup as the goal is to get rid of any min/max operators and complementary slackness conditions that might introduce a singularity into the Jacobian. This is done by attaching an equation tag (see model-decl) with the mcp keyword to affected equations. The format of the mcp tag is

[mcp = 'VARIABBLENAME OP CONSTANT']

where VARIABLENAME is an endogenous variable and OP is either > or <. For complicated occasionally binding constraints, it may be necessary to declare a new endogenous variable.

This tag states that the equation to which the tag is attached has to hold unless the expression within the tag is binding. For instance, a ZLB on the nominal interest rate would be specified as follows in the model block:

    model;
        ...
        [mcp = 'r > -1.94478']
        r = rho*r(-1) + (1-rho)*(gpi*Infl+gy*YGap) + e;
        ...
-    end;

where r is the nominal interest rate in deviation from the steady state. This construct implies that the Taylor rule is operative, unless the implied interest rate r<=-1.94478, in which case the r is fixed at -1.94478. This is equavalant to

\[(r_t > -1.94478)\;\; \bot\;\; r_t = \rho r_{t-1} + (1-\rho) (g_\pi Infl_t+g_y YGap_t) + e_t\]

By restricting the value of r coming out of this equation, the mcp tag also avoids using max(r,-1.94478) for other occurrences of r in the rest of the model. It is important to keep in mind that, because the mcp tag effectively replaces a complementary slackness condition, it cannot be simply attached to any equation.

Note that in the current implementation, the content of the mcp equation tag is not parsed by the preprocessor. The inequalities must therefore be as simple as possible: an endogenous variable, followed by a relational operator, followed by a number (not a variable, parameter or expression).

+ end;

where r is the nominal interest rate in deviation from the steady state. This construct implies that the Taylor rule is operative, unless the implied interest rate r<=-1.94478, in which case the r is fixed at -1.94478. This is equavalant to

\[(r_t > -1.94478)\;\; \bot\;\; r_t = \rho r_{t-1} + (1-\rho) (g_\pi Infl_t+g_y YGap_t) + e_t\]

By restricting the value of r coming out of this equation, the mcp tag also avoids using max(r,-1.94478) for other occurrences of r in the rest of the model. It is important to keep in mind that, because the mcp tag effectively replaces a complementary slackness condition, it cannot be simply attached to any equation.

Note that in the current implementation, the content of the mcp equation tag is not parsed by the preprocessor. The inequalities must therefore be as simple as possible: an endogenous variable, followed by a relational operator, followed by a number (not a variable, parameter or expression).

diff --git a/dev/model-file/estimation/index.html b/dev/model-file/estimation/index.html index 96e46fd..95a4cd6 100644 --- a/dev/model-file/estimation/index.html +++ b/dev/model-file/estimation/index.html @@ -12,7 +12,7 @@ estimated_params; bet, normal_pdf, 1, 0.05; - end;

It is possible to have several estimated_params blocks. By default, subsequent blocks are concatenated with the previous ones; this can be useful when building models in a modular fashion (see also estimated_params_remove for that use case). However, if an estimated_params block has the overwrite option, its contents becomes the new list of estimated parameters, cancelling previous blocks; this can be useful when doing several estimations in a single .mod file.

estimated_params_init

Block: estimated_params_init ;

Block: estimated_params_init (OPTIONS...);

This block declares numerical initial values for the optimizer when these ones are different from the prior mean. It should be specified after the estimated_params block as otherwise the specified starting values are overwritten by the latter.

Each line has the following syntax:

    stderr VARIABLE_NAME | corr VARIABLE_NAME_1, VARIABLE_NAME_2 | PARAMETER_NAME, INITIAL_VALUE;

estimation

Command: estimation [VARIABLE_NAME...];

Command: estimation (OPTIONS...)[VARIABLE_NAME...];

This command runs Bayesian estimation.

Options

The datafile must be in CSV format

    estimation(datafile='../fsdat_simul.csv',...);

The number of observations following first_obs to be used. Default: all observations in the file after first_obs.

The number of the first observation to be used. In case of estimating a DSGE-VAR, first_obs needs to be larger than the number of lags. Default: 1.

Number of replications for each chain of the Metropolis-Hastings algorithm. The number of draws should be sufficient to achieve convergence of the MCMC and to meaningfully compute posterior objects. Default: 20000.

Number of parallel chains for Metropolis-Hastings algorithm. Default: 2.

The scale parameter of the jumping distribution's covariance matrix. The default value is rarely satisfactory. This option must be tuned to obtain, ideally, an acceptance ratio of 25%-33%. Basically, the idea is to increase the variance of the jumping distribution if the acceptance ratio is too high, and decrease the same variance if the acceptance ratio is too low. In some situations it may help to consider parameter-specific values for this scale parameter. This can be done in the estimated_params block. Default: 0.2.

Julia functions

Dynare.covarianceFunction

covariance(chain:Chains)

computes the covariance matrix of MCMC chain

source
Dynare.mode_compute!Function
 mode_compute!(; 
+     end;

It is possible to have several estimated_params blocks. By default, subsequent blocks are concatenated with the previous ones; this can be useful when building models in a modular fashion (see also estimated_params_remove for that use case). However, if an estimated_params block has the overwrite option, its contents becomes the new list of estimated parameters, cancelling previous blocks; this can be useful when doing several estimations in a single .mod file.

estimated_params_init

Block: estimated_params_init ;

Block: estimated_params_init (OPTIONS...);

This block declares numerical initial values for the optimizer when these ones are different from the prior mean. It should be specified after the estimated_params block as otherwise the specified starting values are overwritten by the latter.

Each line has the following syntax:

    stderr VARIABLE_NAME | corr VARIABLE_NAME_1, VARIABLE_NAME_2 | PARAMETER_NAME, INITIAL_VALUE;

estimation

Command: estimation [VARIABLE_NAME...];

Command: estimation (OPTIONS...)[VARIABLE_NAME...];

This command runs Bayesian estimation.

Options
  • datafile = FILENAME

The datafile must be in CSV format

    estimation(datafile='../fsdat_simul.csv',...);
  • nobs = INTEGER

The number of observations following first_obs to be used. Default: all observations in the file after first_obs.

  • first_obs = INTEGER

The number of the first observation to be used. In case of estimating a DSGE-VAR, first_obs needs to be larger than the number of lags. Default: 1.

  • plot_priors = INTEGER: Control the plotting of priors, 0, no prior plot, 1, pPrior density for each estimated parameter is plotted. It is important to check that the actual shape of prior densities matches what you have in mind. Ill-chosen values for the prior standard density can result in absurd prior densities (default valueL 1).

  • mh_replic = INTEGER

Number of replications for each chain of the Metropolis-Hastings algorithm. The number of draws should be sufficient to achieve convergence of the MCMC and to meaningfully compute posterior objects. Default: 20000.

  • mh_nblocks = INTEGER

Number of parallel chains for Metropolis-Hastings algorithm. Default: 2.

  • mh_jscale = DOUBLE

The scale parameter of the jumping distribution's covariance matrix. The default value is rarely satisfactory. This option must be tuned to obtain, ideally, an acceptance ratio of 25%-33%. Basically, the idea is to increase the variance of the jumping distribution if the acceptance ratio is too high, and decrease the same variance if the acceptance ratio is too low. In some situations it may help to consider parameter-specific values for this scale parameter. This can be done in the estimated_params block. Default: 0.2.

Julia functions

Dynare.mode_compute!Function
 mode_compute!(; 
              context=context,
              data = AxisArrayTable(AxisArrayTables.AxisArray(Matrix(undef, 0, 0))),
              datafile = "",
@@ -26,10 +26,10 @@
              nobs::Int = 0,
              order::Int = 1,
              presample::Int = 0,
-             transformed_parameters = true)

computes the posterior mode.

Keyword arguments

  • context::Context=context: context of the computation
  • data::AxisArrayTable: AxisArrayTable containing observed variables
  • datafile::String: data filename (can't be used as the same time asdataset`)
  • first_obs::PeriodsSinceEpoch: first observation (default: first observation in the dataset)
  • initial_values: initival parameter values for optimization algorithm (default: estimated_params_init block if present or prior mean)
  • last_obs::PeriodsSinceEpoch: last period (default: last period of the dataset)
  • nobs::Int = 0: number of observations (default: entire dataset)
  • transformed_parameters = true: whether to transform estimated parameter so as they take their value on R

Either data or datafile must be specified.

source
Dynare.plot_priorsFunction
plot_priors(; context::Context = context, n_points::Int = 100)

plots prior density

Keyword arguments

  • context::Context = context: context in which to take the date to be ploted
  • n_points::Int = 100: number of points used for a curve
source
Dynare.plot_prior_posteriorFunction
plot_prior_posterior(chains; context::Context=context)

plots priors posterios and mode if computed on the same plots

Keyword arguments

  • context::Context=context: context used to get the estimation results

Output

  • the plots are saved in ./<modfilename>/Graphs/PriorPosterior_<x>.png
source
Dynare.prior!Function
 prior!(s::Symbol; shape::{<:Distributions}, initialvalue::Union{Real,Missing}=missing, mean::Union{Real,Missing}=missing, stdev::Union{Real,Missing}=missing, domain=[], variance ::Union{Real,Missing}=missing, context::Context=context)
+             transformed_parameters = true)

computes the posterior mode.

Keyword arguments

  • context::Context=context: context of the computation
  • data::AxisArrayTable: AxisArrayTable containing observed variables
  • datafile::String: data filename (can't be used as the same time asdataset`)
  • first_obs::PeriodsSinceEpoch: first observation (default: first observation in the dataset)
  • initial_values: initival parameter values for optimization algorithm (default: estimated_params_init block if present or prior mean)
  • last_obs::PeriodsSinceEpoch: last period (default: last period of the dataset)
  • nobs::Int = 0: number of observations (default: entire dataset)
  • transformed_parameters = true: whether to transform estimated parameter so as they take their value on R

Either data or datafile must be specified.

source
Dynare.plot_priorsFunction
plot_priors(; context::Context = context, n_points::Int = 100)

plots prior density

Keyword arguments

  • context::Context = context: context in which to take the date to be ploted
  • n_points::Int = 100: number of points used for a curve
source
Dynare.plot_prior_posteriorFunction
plot_prior_posterior(chains; context::Context=context)

plots priors posterios and mode if computed on the same plots

Keyword arguments

  • context::Context=context: context used to get the estimation results

Output

  • the plots are saved in ./<modfilename>/Graphs/PriorPosterior_<x>.png
source
Dynare.prior!Function
 prior!(s::Symbol; shape::{<:Distributions}, initialvalue::Union{Real,Missing}=missing, mean::Union{Real,Missing}=missing, stdev::Union{Real,Missing}=missing, domain=[], variance ::Union{Real,Missing}=missing, context::Context=context)
  prior!(s::stdev; shape::{<:Distributions}, initialvalue::Union{Real,Missing}=missing, mean::Union{Real,Missing}=missing, stdev::Union{Real,Missing}=missing, domain=[], variance ::Union{Real,Missing}=missing, context::Context=context)
  prior!(s::variance; shape::{<:Distributions}, initialvalue::Union{Real,Missing}=missing, mean::Union{Real,Missing}=missing, stdev::Union{Real,Missing}=missing, domain=[], variance ::Union{Real,Missing}=missing, context::Context=context)
- prior!(s::corr; shape::{<:Distributions}, initialvalue::Union{Real,Missing}=missing, mean::Union{Real,Missing}=missing, stdev::Union{Real,Missing}=missing, domain=[], variance ::Union{Real,Missing}=missing, context::Context=context)

generates a prior for a symbol of a parameter, the standard deviation (stdev) or the variance (variance) of an exogenous variable or an endogenous variable (measurement error) or the correlation (corr) between 2 endogenous or exogenous variables

Keyword arguments

  • shape <: Distributions: the shape of the prior distribution (Beta, InvertedGamma, InvertedGamma1, Gamma, Normal, Uniform, Weibull) [required]
  • context::Context=context: context in which the prior is declared
  • domain::Vector{<:Real}=Float64[]: domain for a uniform distribution
  • initialvalue::Union{Real,Missing}=missing: initialvalue for mode finding or MCMC iterations
  • mean::Union{Real,Missing}=missing: mean of the prior distribution
  • stdev::Union{Real,Missing}=missing: stdev of the prior distribution
  • variance::Union{Real,Missing}=missing: variance of the prior distribution
source
Dynare.rwmh_compute!Function
rwmh_compute!(;context::Context=context,
+ prior!(s::corr; shape::{<:Distributions}, initialvalue::Union{Real,Missing}=missing, mean::Union{Real,Missing}=missing, stdev::Union{Real,Missing}=missing, domain=[], variance ::Union{Real,Missing}=missing, context::Context=context)

generates a prior for a symbol of a parameter, the standard deviation (stdev) or the variance (variance) of an exogenous variable or an endogenous variable (measurement error) or the correlation (corr) between 2 endogenous or exogenous variables

Keyword arguments

  • shape <: Distributions: the shape of the prior distribution (Beta, InvertedGamma, InvertedGamma1, Gamma, Normal, Uniform, Weibull) [required]
  • context::Context=context: context in which the prior is declared
  • domain::Vector{<:Real}=Float64[]: domain for a uniform distribution
  • initialvalue::Union{Real,Missing}=missing: initialvalue for mode finding or MCMC iterations
  • mean::Union{Real,Missing}=missing: mean of the prior distribution
  • stdev::Union{Real,Missing}=missing: stdev of the prior distribution
  • variance::Union{Real,Missing}=missing: variance of the prior distribution
source
Dynare.rwmh_compute!Function
rwmh_compute!(;context::Context=context,
          back_transformation::Bool = true,
          datafile::String = "",
          data::AxisArrayTable = AxisArrayTable(AxisArrayTables.AxisArray(Matrix(undef, 0, 0))),
@@ -51,4 +51,4 @@
          plot_chain::Bool = true,
          plot_posterior_density::Bool = false, 
          presample::Int = 0,
-         transformed_parameters::Bool = true

)

runs random walk Monte Carlo simulations of the posterior

Keyword arguments

  • context::Context=context: context of the computation
  • covariance::AbstractMatrix{Float64}:
  • data::AxisArrayTable: AxisArrayTable containing observed variables
  • datafile::String: data filename
  • first_obs::PeriodsSinceEpoch: first observation (default: first observation in the dataset)
  • initial_values: initival parameter values for optimization algorithm (default: estimated_params_init block if present or prior mean)
  • last_obs::PeriodsSinceEpoch: last period (default: last observation in the dataset)
  • mcmc_chains::Int number of MCMC chains (default: 1)
  • mcmc_jscale::Float64: scale factor of proposal
  • mcmc_replic::Int: = 0,
  • nobs::Int = 0: number of observations (default: entire dataset)
  • plot_chain::Bool: whether to display standard MCMC chain output (default:true)
  • plot_posterior_density::Bool: wether to display plots with prior and posterior densities (default: false)
  • transformed_covariance::Matrix{Float64}: covariance of transformed parameters (default: empty)
  • transformed_parameters = true: whether to transform estimated parameter so as they take their value on R

Either data or datafile must be specified.

source
+ transformed_parameters::Bool = true

)

runs random walk Monte Carlo simulations of the posterior

Keyword arguments

Either data or datafile must be specified.

source diff --git a/dev/model-file/filtersmoother/index.html b/dev/model-file/filtersmoother/index.html index 26f055f..62eb65b 100644 --- a/dev/model-file/filtersmoother/index.html +++ b/dev/model-file/filtersmoother/index.html @@ -11,4 +11,4 @@ first_obs::PeriodSinceEpoch = Undated(typemin(Int)), last_obs::PeriodSinceEpoch = Undated(typemin(Int)), nobs::Int = 0 - )

Compute the smoothed values of the variables for an estimated model

#Keyword arguments

source + )

Compute the smoothed values of the variables for an estimated model

#Keyword arguments

source diff --git a/dev/model-file/forecasting/index.html b/dev/model-file/forecasting/index.html index 0035d67..30d5785 100644 --- a/dev/model-file/forecasting/index.html +++ b/dev/model-file/forecasting/index.html @@ -6,11 +6,11 @@ first_obs::PeriodsSinceEpoch=Undated(typemin(Int)), first_period::PeriodsSinceEpoch=Undated(0), last_obs::PeriodsSinceEpoch=Undated(typemin(Int)), - order::Integer=1)

computes an unconditional forecast of the variables of the model

Keyword arguments

source
Dynare.recursive_forecasting!Function
recursive_forecasting!(; Np::Integer,
+               order::Integer=1)

computes an unconditional forecast of the variables of the model

Keyword arguments

  • periods::Integer: number of forecasted periods [required]
  • forecast_mode::ForecastModes: one of histval or calibsmoother [required]
  • datafile::String: file with the observations for the smoother
  • first_obs::PeriodsSinceEpoch: first period used by smoother (default: first observation in the file)
  • first_period::PeriodsSinceEpoch: initial_period for the forecast (default when histval: Undated(0), default when calibsmoother: last period of the smoother)
  • last_obs::PeriodsSinceEpoch: last period used by smoother (default: last observation in the file)
  • order::Integer: order of local approximation
source
Dynare.recursive_forecasting!Function
recursive_forecasting!(; Np::Integer,
                        first_period::PeriodsSinceEpoch=Undated(typemin(Int)), 
                        last_period::PeriodsSinceEpoch=Undated(typemax(Int)), 
                        context::Context=context,
                        datafile::String="", 
                        first_obs::PeriodsSinceEpoch=Undated(typemin(Int)), 
                        last_obs::PeriodsSinceEpoch=Undated(typemax(Int)), 
-                       order::Integer=1)

computes an unconditional recursive forecast by adding one period to the sample used for the smoother before forecasting over Np periods.

Keyword arguments

  • Np::Integer: number of forecasted periods [required]
  • first_period::PeriodsSinceEpoch: initial period of first forecast [required]
  • last_period::PeriodsSinceEpoch: initial period of last forecast [required]
  • datafile::String: file with the observations for the smoother
  • first_obs::PeriodsSinceEpoch: first period used by smoother (default: first observation in the file)
  • last_obs::PeriodsSinceEpoch: last period used by smoother (default: last observation in the file)
  • order::Integer: order of local approximation
source
+ order::Integer=1)

computes an unconditional recursive forecast by adding one period to the sample used for the smoother before forecasting over Np periods.

Keyword arguments

source diff --git a/dev/model-file/local-approxiation/index.html b/dev/model-file/local-approxiation/index.html index 6791a23..bd2a9b1 100644 --- a/dev/model-file/local-approxiation/index.html +++ b/dev/model-file/local-approxiation/index.html @@ -12,6 +12,6 @@ dr_algo::String = "GS", irf::Int = 40, LRE_options = LinearRationalExpectationsOptions(), nar::Int = 5, nonstationary::Bool = false, - order::Int = 1, periods::Int = 0 )

computes a local approximation of a model contained in context

Keyword arguments

source

First-order approximation

The approximation has the stylized form:

\[y_t = y^s + A \phi(y_{t-1}) + B u_t\]

where $y^s$ is the steady state value of $y$ and $\phi(y_{t-1})=y_{t-1}-y^s$. Matrices of coefficients $A$ and $B$ are computed by Dynare.

Second-order approximation

The approximation has the form:

\[y_t = y^s + 0.5 \Delta^2 + A \phi(y_{t-1}) + B u_t + 0.5 C + order::Int = 1, periods::Int = 0 )

computes a local approximation of a model contained in context

Keyword arguments

source

First-order approximation

The approximation has the stylized form:

\[y_t = y^s + A \phi(y_{t-1}) + B u_t\]

where $y^s$ is the steady state value of $y$ and $\phi(y_{t-1})=y_{t-1}-y^s$. Matrices of coefficients $A$ and $B$ are computed by Dynare.

Second-order approximation

The approximation has the form:

\[y_t = y^s + 0.5 \Delta^2 + A \phi(y_{t-1}) + B u_t + 0.5 C (\phi(y_{t-1})\otimes \phi(y_{t-1})) + 0.5 D (u_t \otimes u_t) + E -(\phi(y_{t-1}) \otimes u_t)\]

where $y^s$ is the steady state value of $y$, $\phi(y_{t-1})=y_{t-1}-y^s$, and $\Delta^2$ is the shift effect of the variance of future shocks. Matrices of coefficients $A$, $B$, $C$, $D$ and $E$ are computed by Dynare.

+(\phi(y_{t-1}) \otimes u_t)\]

where $y^s$ is the steady state value of $y$, $\phi(y_{t-1})=y_{t-1}-y^s$, and $\Delta^2$ is the shift effect of the variance of future shocks. Matrices of coefficients $A$, $B$, $C$, $D$ and $E$ are computed by Dynare.

diff --git a/dev/model-file/model-declaration/index.html b/dev/model-file/model-declaration/index.html index 2b3704b..961827a 100644 --- a/dev/model-file/model-declaration/index.html +++ b/dev/model-file/model-declaration/index.html @@ -47,4 +47,4 @@ model_replace('dummy'); c^(-gam) = (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam); -end;

In the above example, the dummy equation is replaced by a proper Euler equation.

Auxiliary variables

The model which is solved internally by Dynare is not exactly the model declared by the user. In some cases, Dynare will introduce auxiliary endogenous variables–-along with corresponding auxiliary equations–-which will appear in the final output.

The main transformation concerns leads and lags. Dynare will perform a transformation of the model so that there is only one lead and one lag on endogenous variables and no leads/lags on exogenous variables.

This transformation is achieved by the creation of auxiliary variables and corresponding equations. For example, if x(+2) exists in the model, Dynare will create one auxiliary variable AUX_ENDO_LEAD = x(+1), and replace x(+2) by AUX_ENDO_LEAD(+1).

A similar transformation is done for lags greater than 2 on endogenous (auxiliary variables will have a name beginning with AUX_ENDO_LAG), and for exogenous with leads and lags (auxiliary variables will have a name beginning with AUX_EXO_LEAD or AUX_EXO_LAG respectively).

Another transformation is done for the EXPECTATION operator. For each occurrence of this operator, Dynare creates an auxiliary variable defined by a new equation, and replaces the expectation operator by a reference to the new auxiliary variable. For example, the expression EXPECTATION(-1)(x(+1)) is replaced by AUX_EXPECT_LAG_1(-1), and the new auxiliary variable is declared as AUX_EXPECT_LAG_1 = x(+2).

Auxiliary variables are also introduced by the preprocessor for the ramsey_model and ramsey_policy commands. In this case, they are used to represent the Lagrange multipliers when first order conditions of the Ramsey problem are computed. The new variables take the form MULT_i, where i represents the constraint with which the multiplier is associated (counted from the order of declaration in the model block).

Auxiliary variables are also introduced by the differentiate_forward_vars option of the model block. The new variables take the form AUX_DIFF_FWRD_i, and are equal to x-x(-1) for some endogenous variable x.

Finally, auxiliary variables will arise in the context of employing the diff-operator.

Once created, all auxiliary variables are included in the set of endogenous variables. The output of decision rules (see below) is such that auxiliary variable names are replaced by the original variables they refer to.

The number of endogenous variables before the creation of auxiliary variables is stored in context.models[1].orig_endo_nbr, and the number of endogenous variables after the creation of auxiliary variables is stored in context.models[1].endogenous_nbr.

+end;

In the above example, the dummy equation is replaced by a proper Euler equation.

Auxiliary variables

The model which is solved internally by Dynare is not exactly the model declared by the user. In some cases, Dynare will introduce auxiliary endogenous variables–-along with corresponding auxiliary equations–-which will appear in the final output.

The main transformation concerns leads and lags. Dynare will perform a transformation of the model so that there is only one lead and one lag on endogenous variables and no leads/lags on exogenous variables.

This transformation is achieved by the creation of auxiliary variables and corresponding equations. For example, if x(+2) exists in the model, Dynare will create one auxiliary variable AUX_ENDO_LEAD = x(+1), and replace x(+2) by AUX_ENDO_LEAD(+1).

A similar transformation is done for lags greater than 2 on endogenous (auxiliary variables will have a name beginning with AUX_ENDO_LAG), and for exogenous with leads and lags (auxiliary variables will have a name beginning with AUX_EXO_LEAD or AUX_EXO_LAG respectively).

Another transformation is done for the EXPECTATION operator. For each occurrence of this operator, Dynare creates an auxiliary variable defined by a new equation, and replaces the expectation operator by a reference to the new auxiliary variable. For example, the expression EXPECTATION(-1)(x(+1)) is replaced by AUX_EXPECT_LAG_1(-1), and the new auxiliary variable is declared as AUX_EXPECT_LAG_1 = x(+2).

Auxiliary variables are also introduced by the preprocessor for the ramsey_model and ramsey_policy commands. In this case, they are used to represent the Lagrange multipliers when first order conditions of the Ramsey problem are computed. The new variables take the form MULT_i, where i represents the constraint with which the multiplier is associated (counted from the order of declaration in the model block).

Auxiliary variables are also introduced by the differentiate_forward_vars option of the model block. The new variables take the form AUX_DIFF_FWRD_i, and are equal to x-x(-1) for some endogenous variable x.

Finally, auxiliary variables will arise in the context of employing the diff-operator.

Once created, all auxiliary variables are included in the set of endogenous variables. The output of decision rules (see below) is such that auxiliary variable names are replaced by the original variables they refer to.

The number of endogenous variables before the creation of auxiliary variables is stored in context.models[1].orig_endo_nbr, and the number of endogenous variables after the creation of auxiliary variables is stored in context.models[1].endogenous_nbr.

diff --git a/dev/model-file/reporting/index.html b/dev/model-file/reporting/index.html index 73fe409..964f9e7 100644 --- a/dev/model-file/reporting/index.html +++ b/dev/model-file/reporting/index.html @@ -1,2 +1,2 @@ -Reporting · Dynare.jl

Dynare can generate PDF reports using \LaTeX

  • A report is made of
    • a title
    • a subtitle (optional)
    • pages
  • A page is made of sections
  • A section can be
    • a text paragraph
    • a listing of the model
    • a table
    • a graphic

Julia functions

Dynare.ReportType

Report(title::String; subtitle::String = "")

initialize empty report

Keyword arguments

  • title::String: Report title [required]
  • subtitle::String: Report subtitle
source
Dynare.add_page!Function

add_page!(report::Report, page::Page)

adds a page to a report

Keyword arguments

  • report::Report: report
  • page::Page: page to be added
source
Dynare.add_graph!Function

add_graph!(page::Page, graph::Graph)

adds a graph to a page

Keyword arguments

  • page::Page: page
  • graph::Graph: graph to be added
source
Dynare.add_model!Function

add_model!(page::Page; context::Context = context, lastline::Int = 0, format = 1) adds the lines of a *.mod file to pages

Keyword arguments

  • page::Page: page [required]
  • context::Context: context corresponding to the *.mod file (default: context)
  • lastline::Int: last line to be printed
  • format::Int: how to display parameter values 1: value is written after the parameter name 2: value is written below the parameter name
source
Dynare.add_paragraph!Function

add_paragraph!(page::Page, paragraph::String)

adds a graph to a page

Keyword arguments

  • page::Page: page
  • paragraph::String: paragraph to be added
source

@docs add_table! ````

`$@docs print$

+Reporting · Dynare.jl

Dynare can generate PDF reports using \LaTeX

  • A report is made of
    • a title
    • a subtitle (optional)
    • pages
  • A page is made of sections
  • A section can be
    • a text paragraph
    • a listing of the model
    • a table
    • a graphic

Julia functions

Dynare.ReportType

Report(title::String; subtitle::String = "")

initialize empty report

Keyword arguments

  • title::String: Report title [required]
  • subtitle::String: Report subtitle
source
Dynare.add_page!Function

add_page!(report::Report, page::Page)

adds a page to a report

Keyword arguments

  • report::Report: report
  • page::Page: page to be added
source
Dynare.add_graph!Function

add_graph!(page::Page, graph::Graph)

adds a graph to a page

Keyword arguments

  • page::Page: page
  • graph::Graph: graph to be added
source
Dynare.add_model!Function

add_model!(page::Page; context::Context = context, lastline::Int = 0, format = 1) adds the lines of a *.mod file to pages

Keyword arguments

  • page::Page: page [required]
  • context::Context: context corresponding to the *.mod file (default: context)
  • lastline::Int: last line to be printed
  • format::Int: how to display parameter values 1: value is written after the parameter name 2: value is written below the parameter name
source
Dynare.add_paragraph!Function

add_paragraph!(page::Page, paragraph::String)

adds a graph to a page

Keyword arguments

  • page::Page: page
  • paragraph::String: paragraph to be added
source

@docs add_table! ````

`$@docs print$

diff --git a/dev/model-file/shocks/index.html b/dev/model-file/shocks/index.html index 82105d2..2416a39 100644 --- a/dev/model-file/shocks/index.html +++ b/dev/model-file/shocks/index.html @@ -46,5 +46,5 @@ stoch_simul(irf=0); forecast;

Julia function

scenario!()

The Julia function scenario!() lets you

Dynare.scenario!Function
scenario!(; name=Symbol, period::PeriodSinceEpoch, value<:Number, context::Context=context,
-  exogenous::Symbol=Symbol(), infoperiod::PeriodSinceEpoch=Undated(1))

Keyword arguments

  • name::Symbol: the name of an endogenous or exogenous variable [required]
  • period::PeriodSinceEpoch: the period in which the value is set
  • value<:PeriodSinceEpoch: the value of the endogenous or exogenous variables
  • context: the context is which the function operates (optional, default = context)
  • exogenous: when an endogenous variable is set, the name of the exogenous that must be freed (required when an endogenous variables is set)
  • infoperiod: the period in which the information is learned (optional, default = Undated(1))
source
Examples
scenario!(name = :e, value = 0.1, period = 2)

Exogenous variable e, takes value 0.1 in period 2.

scenario!(name = :y, value = 0.2, period=2, exogenous = :u)

Endogenous variable y is set to 0.2 in period 2 and exogenous variable u is treated as endogenous in the same period. Agents in the model know at the beginning of period 1 that this will happen.

scenario!(infoperiod = 2, name = :y, value = 0.2, period = 2,
-                exogenous = :u)

Endogenous variable y is set to 0.2 in period 2 and exogenous variable u is treated as endogenous in the same period. Agents in the model only learn at the beginning of period 2 that this will happen.

+ exogenous::Symbol=Symbol(), infoperiod::PeriodSinceEpoch=Undated(1))

Keyword arguments

source
Examples
scenario!(name = :e, value = 0.1, period = 2)

Exogenous variable e, takes value 0.1 in period 2.

scenario!(name = :y, value = 0.2, period=2, exogenous = :u)

Endogenous variable y is set to 0.2 in period 2 and exogenous variable u is treated as endogenous in the same period. Agents in the model know at the beginning of period 1 that this will happen.

scenario!(infoperiod = 2, name = :y, value = 0.2, period = 2,
+                exogenous = :u)

Endogenous variable y is set to 0.2 in period 2 and exogenous variable u is treated as endogenous in the same period. Agents in the model only learn at the beginning of period 2 that this will happen.

diff --git a/dev/model-file/steady-state/index.html b/dev/model-file/steady-state/index.html index 06d2869..1edae78 100644 --- a/dev/model-file/steady-state/index.html +++ b/dev/model-file/steady-state/index.html @@ -85,11 +85,11 @@ steady(homotopy_mode = 1, homotopy_steps = 50);

Julia function

steadystate!

Dynare.steadystate!Function
steadystate!(; context::Context=context, display::Bool = true,
         maxit::Int = 50, nocheck::Bool = false, tolf::Float64 = cbrt(eps()),
-        tolx::Float64 = 0.0)

Keyword arguments

  • context::Context=context: context in which the simulation is computed
  • homotopy_steps::Int=0: number of homotopy steps
  • display::Bool=true: whether to display the results
  • maxit::Int=50 maximum number of iterations
  • nocheck::Bool=false: don't check the steady state
  • tolf::Float64=cbrt(eps()): tolerance for the norm of residualts
  • tolx::Float64=0: tolerance for the norm of the change in the result
source

Replace some equations during steady state computations

When there is no steady state file, Dynare computes the steady state by solving the static model, i.e. the model from the .mod file from which leads and lags have been removed.

In some specific cases, one may want to have more control over the way this static model is created. Dynare therefore offers the possibility to explicitly give the form of equations that should be in the static model.

More precisely, if an equation is prepended by a [static] tag, then it will appear in the static model used for steady state computation, but that equation will not be used for other computations. For every equation tagged in this way, you must tag another equation with [dynamic]: that equation will not be used for steady state computation, but will be used for other computations.

This functionality can be useful on models with a unit root, where there is an infinity of steady states. An equation (tagged [dynamic]) would give the law of motion of the nonstationary variable (like a random walk). To pin down one specific steady state, an equation tagged [static] would affect a constant value to the nonstationary variable. Another situation where the [static] tag can be useful is when one has only a partial closed form solution for the steady state.

Example

This is a trivial example with two endogenous variables. The second equation takes a different form in the static model:

var c k;
+        tolx::Float64 = 0.0)

Keyword arguments

source

Replace some equations during steady state computations

When there is no steady state file, Dynare computes the steady state by solving the static model, i.e. the model from the .mod file from which leads and lags have been removed.

In some specific cases, one may want to have more control over the way this static model is created. Dynare therefore offers the possibility to explicitly give the form of equations that should be in the static model.

More precisely, if an equation is prepended by a [static] tag, then it will appear in the static model used for steady state computation, but that equation will not be used for other computations. For every equation tagged in this way, you must tag another equation with [dynamic]: that equation will not be used for steady state computation, but will be used for other computations.

This functionality can be useful on models with a unit root, where there is an infinity of steady states. An equation (tagged [dynamic]) would give the law of motion of the nonstationary variable (like a random walk). To pin down one specific steady state, an equation tagged [static] would affect a constant value to the nonstationary variable. Another situation where the [static] tag can be useful is when one has only a partial closed form solution for the steady state.

Example

This is a trivial example with two endogenous variables. The second equation takes a different form in the static model:

var c k;
 varexo x;
 ...
 model;
 c + k - aa*x*k(-1)^alph - (1-delt)*k(-1);
 [dynamic] c^(-gam) - (1+bet)^(-1)*(aa*alph*x(+1)*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
 [static] k = ((delt+bet)/(x*aa*alph))^(1/(alph-1));
-end;
+end; diff --git a/dev/model-file/syntax-elements/index.html b/dev/model-file/syntax-elements/index.html index efbec92..7011759 100644 --- a/dev/model-file/syntax-elements/index.html +++ b/dev/model-file/syntax-elements/index.html @@ -15,4 +15,4 @@ 0 &\quad\text{if }x=0\\ 1 &\quad\text{if }x>0 \end{cases} - \end{aligned}\]

Note that this function is not continuous, hence not differentiable, at $x=0$. However, for facilitating convergence of Newton-type methods, Dynare assumes that the derivative at $x=0$ is equal to $0$. This assumption comes from the observation that both the right- and left-derivatives at this point exist and are equal to $0$, so we can remove the singularity by postulating that the derivative at $x=0$ is $0$.

Function: abs(x)

Absolute value.

Note that this continuous function is not differentiable at $x=0$. However, for facilitating convergence of Newton-type methods, Dynare assumes that the derivative at $x=0$ is equal to $0$ (even if the derivative does not exist). The rational for this mathematically unfounded definition, rely on the observation that the derivative of $\mathrm{abs}(x)$ is equal to $\mathrm{sign}(x)$ for any $x\neq 0$ in $\mathbb R$ and from the convention for the value of $\mathrm{sign}(x)$ at $x=0$).

Function: sin(x)

Function: cos(x)

Function: tan(x)

Function: asin(x)

Function: acos(x)

Function: atan(x)

Trigonometric functions.

Function: sinh(x)

Function: cosh(x)

Function: tanh(x)

Function: asinh(x)

Function: acosh(x)

Function: atanh(x)

Hyperbolic functions.

Function: max(a, b)

Function: min(a, b)

Maximum and minimum of two reals.

Note that these functions are differentiable everywhere except on a line of the 2-dimensional real plane defined by $a=b$. However for facilitating convergence of Newton-type methods, Dynare assumes that, at the points of non-differentiability, the partial derivative of these functions with respect to the first (resp. the second) argument is equal to $1$ (resp. to $0$) (i.e. the derivatives at the kink are equal to the derivatives observed on the half-plane where the function is equal to its first argument).

Function: normcdf(x)

Function: normcdf(x, mu, sigma)

Gaussian cumulative density function, with mean mu and standard deviation sigma. Note that normcdf(x) is equivalent to normcdf(x,0,1).

Function: normpdf(x) Function: normpdf(x, mu, sigma)

Gaussian probability density function, with mean mu and standard deviation sigma. Note that normpdf(x) is equivalent to normpdf(x,0,1).

Function: erf(x)

Gauss error function.

Function: erfc(x)

Complementary error function, i.e. $\mathrm{erfc}(x) = 1-\mathrm{erf}(x)$.

A few words of warning in stochastic context

The use of the following functions and operators is strongly discouraged in a stochastic context: max, min, abs, sign, <, >, <=, >=, ==, !=.

The reason is that the local approximation used by stoch_simul or estimation will by nature ignore the non-linearities introduced by these functions if the steady state is away from the kink. And, if the steady state is exactly at the kink, then the approximation will be bogus because the derivative of these functions at the kink is bogus (as explained in the respective documentations of these functions and operators).

Note that extended_path is not affected by this problem, because it does not rely on a local approximation of the mode.

Footnotes

+ \end{aligned}\]

Note that this function is not continuous, hence not differentiable, at $x=0$. However, for facilitating convergence of Newton-type methods, Dynare assumes that the derivative at $x=0$ is equal to $0$. This assumption comes from the observation that both the right- and left-derivatives at this point exist and are equal to $0$, so we can remove the singularity by postulating that the derivative at $x=0$ is $0$.

Function: abs(x)

Absolute value.

Note that this continuous function is not differentiable at $x=0$. However, for facilitating convergence of Newton-type methods, Dynare assumes that the derivative at $x=0$ is equal to $0$ (even if the derivative does not exist). The rational for this mathematically unfounded definition, rely on the observation that the derivative of $\mathrm{abs}(x)$ is equal to $\mathrm{sign}(x)$ for any $x\neq 0$ in $\mathbb R$ and from the convention for the value of $\mathrm{sign}(x)$ at $x=0$).

Function: sin(x)

Function: cos(x)

Function: tan(x)

Function: asin(x)

Function: acos(x)

Function: atan(x)

Trigonometric functions.

Function: sinh(x)

Function: cosh(x)

Function: tanh(x)

Function: asinh(x)

Function: acosh(x)

Function: atanh(x)

Hyperbolic functions.

Function: max(a, b)

Function: min(a, b)

Maximum and minimum of two reals.

Note that these functions are differentiable everywhere except on a line of the 2-dimensional real plane defined by $a=b$. However for facilitating convergence of Newton-type methods, Dynare assumes that, at the points of non-differentiability, the partial derivative of these functions with respect to the first (resp. the second) argument is equal to $1$ (resp. to $0$) (i.e. the derivatives at the kink are equal to the derivatives observed on the half-plane where the function is equal to its first argument).

Function: normcdf(x)

Function: normcdf(x, mu, sigma)

Gaussian cumulative density function, with mean mu and standard deviation sigma. Note that normcdf(x) is equivalent to normcdf(x,0,1).

Function: normpdf(x) Function: normpdf(x, mu, sigma)

Gaussian probability density function, with mean mu and standard deviation sigma. Note that normpdf(x) is equivalent to normpdf(x,0,1).

Function: erf(x)

Gauss error function.

Function: erfc(x)

Complementary error function, i.e. $\mathrm{erfc}(x) = 1-\mathrm{erf}(x)$.

A few words of warning in stochastic context

The use of the following functions and operators is strongly discouraged in a stochastic context: max, min, abs, sign, <, >, <=, >=, ==, !=.

The reason is that the local approximation used by stoch_simul or estimation will by nature ignore the non-linearities introduced by these functions if the steady state is away from the kink. And, if the steady state is exactly at the kink, then the approximation will be bogus because the derivative of these functions at the kink is bogus (as explained in the respective documentations of these functions and operators).

Note that extended_path is not affected by this problem, because it does not rely on a local approximation of the mode.

Footnotes

diff --git a/dev/model-file/variable-declarations/index.html b/dev/model-file/variable-declarations/index.html index ff3ead0..7ea25d5 100644 --- a/dev/model-file/variable-declarations/index.html +++ b/dev/model-file/variable-declarations/index.html @@ -55,4 +55,4 @@ k(1) = i|e + (1-delta|p)*k; y|e = k|e^alpha|p; ... -end; +end; diff --git a/dev/objects.inv b/dev/objects.inv index ab5d93d..f74aab7 100644 Binary files a/dev/objects.inv and b/dev/objects.inv differ diff --git a/dev/running-dynare/index.html b/dev/running-dynare/index.html index 208e8e8..6a93943 100644 --- a/dev/running-dynare/index.html +++ b/dev/running-dynare/index.html @@ -1,3 +1,3 @@ Running Dynare · Dynare.jl

Running Dynare

In order to give instructions to Dynare, the user has to write a model file whose filename extension must be .mod. This file contains the description of the model and the computing tasks required by the user. Its contents are described in The model file

Dynare invocation

Once the model file is written, Dynare is invoked using the @dynare Julia macro (with the filename of the .mod given as argument).

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 Julia instructions are generated; in the second step, the program actually runs the computations. Both steps are triggered automatically by the @dynare macro:

context = @dynare "FILENAME [.mod ]" [OPTIONS... ]";

This command launches Dynare and executes the instructions included in FILENAME.mod. This user-supplied file contains the model and the processing instructions, as described in The model file. The options, listed below, can be passed on the command line, following the name of the .mod file or in the first line of the .mod file itself (see below).

Dynare begins by launching the preprocessor on the .mod file.

Options

  • debug

    Instructs the preprocessor to write some debugging information about the scanning and parsing of the .mod file.

  • notmpterms

    Instructs the preprocessor to omit temporary terms in the static and dynamic files; this generally decreases performance, but is used for debugging purposes since it makes the static and dynamic files more readable.

  • savemacro\[=FILENAME\]

    Instructs Dynare to save the intermediary file which is obtained after macro processing (see (@ref "Macro processing language")); 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") for info on passing a FILENAME argument containing spaces.

  • onlymacro

    Instructs the preprocessor to only perform the macro processing step, and stop just after. Useful for debugging purposes or for using the macro processor independently of the rest of Dynare toolbox.

  • linemacro

    Instructs the macro preprocessor include @#line directives specifying the line on which macro directives were encountered and expanded from. Only useful in conjunction with savemacro <savemacro[=FILENAME]>.

  • onlymodel

    Instructs the preprocessor to print only information about the model in the driver file; no Dynare commands (other than the shocks statement and parameter initializations) are printed and hence no computational tasks performed. The same ancillary files are created as would otherwise be created (dynamic, static files, etc.).

  • nolog

    Instructs Dynare to no create a logfile of this run in FILENAME.log. The default is to create the logfile.

  • output=second\|third

    Instructs the preprocessor to output derivatives of the dynamic model at least up to the given order.

  • language=matlab\|julia

Instructs the preprocessor to write output for MATLAB or Julia. Default: MATLAB

  • params\_derivs\_order=0\|1\|2

    When (@ref "identification"), (@ref "dynaresensitivity") (with identification), or (@ref "estimationcmd") 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 derivatives, and 2 means second derivatives. Default: 2

  • transform\_unary\_ops

    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

  • json = parse\|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 operators substituted, etc.) will be written to a file called FILENAME.json and the original, untransformed model will be written in FILENAME_original.json.

And if compute is passed, the output is written after the computing pass. In this case, the transformed model is written to FILENAME.json, the original model is written to FILENAME_original.json, and the dynamic and static files are written to FILENAME_dynamic.json and FILENAME_static.json.

  • jsonstdout

    Instead of writing output requested by json to files, write to standard out, i.e. to the Julia command window (and the log-file).

  • onlyjson

    Quit processing once the output requested by json has been written.

  • jsonderivsimple

    Print a simplified version (excluding variable name(s) and lag information) of the static and dynamic files in FILENAME_static.json and FILENAME_dynamic..

  • warn\_uninit

Display a warning for each variable or parameter which is not initialized. See (@ref "Parameter initialization"), or (@ref "loadparamsandsteadystate") for initialization of parameters. See (@ref "Initial and Terminal conditions"), or (@ref "loadparamsandsteadystate") for initialization of endogenous and exogenous variables.

  • nopreprocessoroutput

    Prevent Dynare from printing the output of the steps leading up to the preprocessor as well as the preprocessor output itself.

  • -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 processing language")). See the (@ref "note on quotes") 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.

    Example

    Call dynare with command line defines

    julia julia> @dynare <<modfile.mod>> -DA=true '-DB="A string with space"' -DC=[1,2,3] '-DD=[ i in C when i > 1 ]' -DE;

  • -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. See the (@ref "note on quotes") for info on passing a <<path>> argument containing spaces.

  • nostrict

    Allows Dynare to issue a warning and continue processing when

  1. there are more endogenous variables than equations.
  2. an undeclared symbol is assigned in initval or endval.
  3. an undeclared symbol is found in the model block in this case, it is automatically declared exogenous.
  4. exogenous variables were declared but not used in the model block.
  • stochastic

    Tells Dynare that the model to be solved is stochastic. If no Dynare commands related to stochastic models (stoch_simul, estimation, ...) are present in the .mod file, Dynare understands by default that the model to be solved is deterministic.

  • 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:

  1. 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].
  2. 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.
  3. 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:

  1. One equation per line of the file, where every line represents the value passed to the name tag. e.g., a file such as: julia eq1 eq 2 would exclude equations with tags [name='eq1'] and [name='eq 2'].

  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: julia 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.

  • 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 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").

  • 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 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. The nopathchange option cannot be specified in this way, it must be passed on the command-line.

Understanding Preprocessor Error Messages

If the preprocessor runs into an error while processing your .mod file, it will issue an error. Due to the way that a parser works, sometimes these errors can be misleading. Here, we aim to demystify these error messages.

The preprocessor issues error messages of the form:

  1. ERROR: <<file.mod>>: line A, col B: <<error message>>
  2. ERROR: <<file.mod>>: line A, cols B-C: <<error message>>
  3. ERROR: <<file.mod>>: line A, col B - line C, col D: <<error message>>

The first two errors occur on a single line, with error two spanning multiple columns. Error three spans multiple rows.

Often, the line and column numbers are precise, leading you directly to the offending syntax. Infrequently however, because of the way the parser works, this is not the case. The most common example of misleading line and column numbers (and error message for that matter) is the case of a missing semicolon, as seen in the following example:

varexo a, b
-parameters c, ...;

In this case, the parser doesn't know a semicolon is missing at the end of the varexo command until it begins parsing the second line and bumps into the parameters command. This is because we allow commands to span multiple lines and, hence, the parser cannot know that the second line will not have a semicolon on it until it gets there. Once the parser begins parsing the second line, it realizes that it has encountered a keyword, parameters, which it did not expect. Hence, it throws an error of the form: ERROR: <<file.mod>>: line 2, cols 0-9: syntax error, unexpected PARAMETERS. In this case, you would simply place a semicolon at the end of line one and the parser would continue processing.

+parameters c, ...;

In this case, the parser doesn't know a semicolon is missing at the end of the varexo command until it begins parsing the second line and bumps into the parameters command. This is because we allow commands to span multiple lines and, hence, the parser cannot know that the second line will not have a semicolon on it until it gets there. Once the parser begins parsing the second line, it realizes that it has encountered a keyword, parameters, which it did not expect. Hence, it throws an error of the form: ERROR: <<file.mod>>: line 2, cols 0-9: syntax error, unexpected PARAMETERS. In this case, you would simply place a semicolon at the end of line one and the parser would continue processing.