How to introduce definitions / auxiliary variables

Hi

is there a way to introduce “auxiliary variables”, that will not be treated as proper variables but just as definitions? (I am referring to a different type of auxiliary than the dynare manual)

Say you have a model with 3 variables and 3 equations

f(x,y,z)=0
g(x,y,z)=0
z=h(x,y)

Is it possible to define the model as one of 2 variables and 1 auxiliary, where the auxiliary is defined by z=h(x,y)? Such that when dynare reads z in equations 1 and 2 it replaces it by h(x,y)?

Of course one could simply replace z=h(x,y) in the first 2 equations, but that makes the code hard to read. Or one could keep z as a proper variable, but my model is already very large and I look for ways to reduce the dimensionality (nr of variables).

Many thanks!
Dominik

1 Like

I am not sure I understand the part about reduction of dimensionality, but it seems model-local variables (#-operator) are what you are looking for.

Yes, exactly! I will try later, but I think this is exactly what I was looking for. Thanks a lot!

regarding dimensionality: Such model local variables do not increase the number of variables (the length of oo_.endosimul, for example).

No, they do not. But that also means that you cannot easily access their value.

If you declare local variables dynare will just replace them and then solve the model afterwards. That can be very helpful, mostly if you are not interested in analyzing these variables further (e.g. defining the marginal utilities, or Stochastic Discount Factor; it can help you a lot in simplifying the length of your equations but you may be only interested in consumption as such).

However, if you do want to define other variables and analyze them, you may want to include them later in your .mod file, that is, after you’ve made sure your model is working. For example: if you have a model in terms of Labor and Capital only and later want to see how the IRF of the output looks.

In this latter case the main caveat is that you have to declare the new variable and include it in the .mod file, but ALSO to declare its steady state counterpart in the _steadystate file.