This brings those models in line with stochastic models.
However note that transformation is still not exactly the same on stochastic
and deterministic models, because there is no need to take into account the
Jensen inequality on the latter. In deterministic models, there is a one-to-one
mapping between exogenous with lead/lags and auxiliaries, while in stochastic
models, an auxiliary endo may correspond to a more complex nonlinear expression.
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
– 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)
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.
— fix segfault due to bad handling of iterators while erasing elements of a set
— fix logic for excluding endogenous variable when it is present on the LHS
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.
By default, the preprocessor is supposed to only do the “unary ops”
transformation in the equations of VAR/PAC/trend component models.
However, the implementation was slightly different so far. It would detect
candidates to this transformation in the chosen equations, but it would then
perform the substitution in *all* equations.
This could lead for crashes, for example if the chosen equation contains
log(X(-1)), but another (non-chosen) equation has log(X(-2)). Then this latter
expression, even though it belongs to the same lag-equivalence class, is not
properly handled, causing a segfault.
Also do a few related cosmetic changes.