Commit Graph

126 Commits (74ef3457b4805099ee9885b34173a0d0fd6aca61)

Author SHA1 Message Date
Sébastien Villemot 74ef3457b4
Use secure URL for link to GNU licenses 2021-06-09 17:21:00 +02:00
Sébastien Villemot cfb41d291c
Substitute out model-local variables early in the model transform pass
Incidentally, this makes it possible to use model-local variables with either
the “block” or “bytecode” option. (Ref: dynare#1243)
2020-11-10 18:07:57 +01:00
Sébastien Villemot 56581b1dd4
PAC model: make detection of non-optimizing part more robust
Introduce a new method for decomposing a product of factors, so that we can
identify expressions of the form (1-optim_share)*A*B.

Also enforce that the optim_share parameter be in a factor of the form
1-optim_share (previously it would accept any expression containing the
parameter).

Note that this fix does not yet allow to actually write non-optimizing parts of
the form (1-optim_share)*A*B, since at a later point the preprocessor imposes
that this part be a linear combination of variables (but in the future we could
think of expanding the A*B product into a linear combination if, for example, A
is a paramater or a constant and B is a linear combination).

Closes: #50
2020-10-19 18:32:30 +02:00
Sébastien Villemot d2cbe2a19e
PAC model: fixes to M_.pac.MODEL.ar (information about autoregressive part)
– Fix order of items in this structure. Previously, items were ordered
  according to the declaration order of parameters. Now, items are order
  according to lag order (first lag appears first)
– Gracefully handle the case where there is no autoregressive part
  (Closes: #52)
2020-10-16 16:31:51 +02:00
Sébastien Villemot 5979885714
Block decomposition, chain rule derivation: code improvement 2020-10-02 18:31:55 +02:00
Sébastien Villemot d347a92f14
Drop ExprNode::containsExogenous()
Replace it by calls to ExprNode::collectVariables() at the single place where
it was used.
2020-09-29 18:41:31 +02:00
Sébastien Villemot 063207e71f
ExprNode::collectEndogenous() is not a virtual method 2020-09-29 18:41:31 +02:00
Sébastien Villemot 2424b7358c
Remove unused ExprNode::collectExogenous() 2020-09-29 18:41:31 +02:00
Sébastien Villemot b0bd031a9f
Remove unused ExprNode::containsEndogenous() 2020-09-29 18:41:31 +02:00
Sébastien Villemot 7f05489639
Simplify ExprNode::findConstantEquations() 2020-09-29 18:41:31 +02:00
Houtan Bastani 7ba77751c3
simplify external function C output 2020-09-18 17:05:54 +02:00
Sébastien Villemot 09054e11dc
Add new “matched_moments” block
Closes: #51
2020-07-28 18:30:24 +02:00
Sébastien Villemot ecf6d67e1c
PAC/MCE model: fix timing of target in PAC expectation term
Also be more strict on the form of the target (must now be X(-1) or log(X(-1))
where X is *not* an auxiliary variable).

By the way, improve some comments in SymbolTable.
2020-07-24 18:26:16 +02:00
Sébastien Villemot 3b3589b958
PAC model: rewrite the algorithm for detecting the target, to make it more robust
Closes: #54
2020-07-23 17:19:16 +02:00
Sébastien Villemot 16f9168fda
PAC MCE: fix incorrect detection of the target variable
The detection of the target EC variable to be used when constructing the
forward-looking expectation variable is rather fragile.

When the PAC model is written with an (non-)optimizing share of agents,
restrict the identification of the target variable to the optimizing
expression, to minimize the risk of wrong identification.

By the way, add a few comments, and a small simplification.
2020-07-13 17:52:42 +02:00
Sébastien Villemot 79763911b2
Block decomposition: in the dynamic file, y and T are now vectors as in non-block mode 2020-06-17 16:49:12 +02:00
Sébastien Villemot faa6666abe
Block decomposition: no longer use global variables for temporary terms in the dynamic M-file
Rather use a single vector as in non-block mode.

By the way, change the order of output arguments in static functions, to be
closer to the dynamic ones.
2020-05-26 16:21:11 +02:00
Sébastien Villemot 3033417f5a
Block decomposition: remove ExprNodeOutputType::matlabDynamicSparseSteadyStateOperator
It’s not really needed, since it does the same as
ExprNodeOutputType::matlabDynamicSteadyStateOperator.
2020-05-25 15:35:55 +02:00
Sébastien Villemot a2bea00fee
Block decomposition: another fix related to temporary terms refactoring
Temporary terms need to be computed per equation (as was done previously), and
not simply per block.

It’s necessary to track temporary terms per equation, because some equations
are evaluated instead of solved, and an equation E1 may depend on the value of
an endogenous Y computed by a previously evaluated equation E2; in this case,
if some temporary term TT of equation E2 contains Y, then TT needs to be
computed after E1, but before E2.
2020-05-13 16:58:19 +02:00
Sébastien Villemot 2e6bc7ecaa
Bytecode: fix handling of temporary terms
They were broken by 49036f166d
2020-05-13 12:53:47 +02:00
Sébastien Villemot 49036f166d
Block decomposition: refactor code for computing temporary terms
In particular, in dynamic models, temporary terms are now computed for
derivatives w.r.t. exogenous, and also w.r.t. endogenous variables that do not
belong to the block.
2020-05-12 18:39:13 +02:00
Sébastien Villemot daa8d01686
Complete rewrite of the equation normalization symbolic engine 2020-04-02 19:19:57 +02:00
Sébastien Villemot e2d5a83592
Global reindentation 2019-12-20 16:59:30 +01:00
Houtan Bastani 137dc31bb0
remove unnecessary headers 2019-12-20 12:49:23 +01:00
Sébastien Villemot 031c0cff5f
Various code simplifications and modernizations 2019-12-16 19:42:59 +01:00
Sébastien Villemot 2a127b1f23
VAR/TCM models: use lag-equivalence relationship to compute maximum lags
This is made possible by the getLagEquivalenceClass() method introduced in the
previous commit.

Previously, the static version of the LHS expressions was used.

As a consequence, drop ModFile::diff_static_model, now useless.
2019-10-22 16:04:24 +02:00
Sébastien Villemot 8a83e08e79
Fix bug with diff or unary ops that have same static representation
Previously, for testing whether two diff() expressions or two unary ops were
the lead/lag of each other, the preprocessor would test whether they have the
same static representation. This is ok for simple expressions (e.g.
diff(x(-1))), but not for more complex ones (e.g. diff(x-y) and diff(x(-1)-y)
should not be given the same auxiliary variable).

This commit fixes this by properly constructing the equivalence relationship
and choosing a representative within each equivalence class. See the comments
above lag_equivalence_table_t in ExprNode.hh for more details.

Closes #27
2019-10-22 15:01:06 +02:00
Sébastien Villemot c5d223a79b
Fix semantics of ExprNode::maxLag(), maxLead() and maxLagWithDiffsExpanded() with constants
Those methods can return a negative value in some cases. For example,
maxLead(x₋₁) = −1.

But constants were always returning a value of zero, which means that we had
inconsistent behaviour like maxLead(x₋₁ + 2) = 0.

This commits fixes the behaviour by making these methods return the smallest
possible integer when called on constants.
2019-10-22 11:35:11 +02:00
Houtan Bastani 0b3cd3ec90
pac: fix parsing of linear combination for growth option 2019-10-03 18:26:09 +02:00
Sébastien Villemot 3941278832
Add more comments in routines for aux vars for unary ops / diff operators
By the way, do some small code simplifications.
2019-08-19 18:27:57 +02:00
Sébastien Villemot 17c4104275
ExprNode::removeTrendLeadLag(): pass map argument by const-reference rather than by value 2019-07-05 18:22:24 +02:00
Sébastien Villemot 1907249fac
Ask GCC to warn about C-style casts (-Wold-style-cast)
Adapt the code accordingly.
2019-04-23 12:54:11 +02:00
Sébastien Villemot b73d554ad2
Use Unicode copyright symbol (in UTF-8 encoding) 2019-04-16 11:35:31 +02:00
Sébastien Villemot 8dad93964d
Allow linear combination of targets in error correction term of trend component models 2019-03-29 17:06:24 +01:00
Sébastien Villemot 1793078ba2
Minor stylistic improvements 2019-03-18 18:49:55 +01:00
Houtan Bastani f1d1c1e1c1
trend_component_model: simplify AR 2019-03-15 12:27:32 +01:00
Houtan Bastani a3c08f932e
simplify code to find autoregressive matrix for VARs 2019-03-15 12:26:59 +01:00
Houtan Bastani 9b1b4113d9
pac: keep order of variables in ec part of pac equation and add scaling factor to output 2019-03-07 11:31:45 +01:00
Houtan Bastani 9963686e72
handle additive terms when PAC equation does NOT have non/optimizing agents 2019-03-05 12:20:45 +01:00
Houtan Bastani 5f013756f2 find additive parts to pac equation 2019-02-27 23:12:05 +01:00
Houtan Bastani effa40543e
pac: find correct target variable when pac equation accounts for share of optimizing agents 2019-02-25 18:46:44 +01:00
Houtan Bastani 240aba6709
move pac info out of pac expectation node 2019-02-20 15:35:13 +01:00
Houtan Bastani 34756833ae
pac: output info into substructures based on pac model name & equation tag 2019-02-19 18:32:42 +01:00
Houtan Bastani fc6d04b015
create A0 and A0star matrices for trend component models 2019-02-19 12:26:30 +01:00
Houtan Bastani 0ea84fa9a4
pac: allow steady state growth and model consistent expectation substitution in pac equation 2019-02-18 15:11:45 +01:00
Houtan Bastani 02ae0af3e5
change map type for readability 2019-01-29 17:43:17 +01:00
Houtan Bastani 90c45b2cd6
remove unused function added in d922ae8ffc 2019-01-28 15:34:38 +01:00
Houtan Bastani f5df7e7567
when an equation is of the form `X` = `constant`, replace all occurrences of `X` in other equations with `constant` 2019-01-28 15:32:12 +01:00
Houtan Bastani d922ae8ffc
pac_model: permit lag on growth option 2019-01-25 14:52:26 +01:00
Sébastien Villemot 82b1467074
Improve consistency of ExprNode methods for calculating max lead/lag
- ExprNode::maxLag() and ExprNode::maxLead() now take into account exogenous
  deterministic variables, for consistency with M_.maximum_{lead,lag}

- ExprNode::maxLag() no longer behaves as if diff() operators were
  expanded (i.e. it now returns 1 on diff(x(-1))), for consistency with
  maxEndoLag() and maxExoLag()

- New ExprNode::maxLagWithDiffsExpanded() method, that behaves as maxLag() used
  to behave (except that it also takes exogenous deterministic into account)
2018-12-05 15:30:03 +01:00