At this stage equations for the PV variables are created by var_expectation(varexp) or pac_expectation(pacman) which can be found then in the generated .inc files.
It is preferable to have them appear directly in the .mod file of the model.
Here is one way of doing it. Say we cherrypick a pac equation from an estimation file. Then the generated simulation file used afterward to aggregate a big model shall automatically include an equation for expectation variable used in this pac equation.
Edited
Designs
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
Activity
Sort or filter
Newest first
Oldest first
Show all activity
Show comments only
Show history only
Anastasia Zhchanged title from Equations for expectation variables in the .mod file to Equations for expectation variables in the .mod file of a model
changed title from Equations for expectation variables in the .mod file to Equations for expectation variables in the .mod file of a model
If I understand your point, it already works like this (for the backward version of the model). When you do the aggregation a build the mod that will be used in a simulation context, you have the equations for the present values (PV is then a linear combination of the variables appearing in the companion VAR considered as an auxiliary model).
@stepan-a Thank you. I tried and it works indeed. With a small bemol: in a new aggregated model sometimes parameters go after variables.
For example: originally we have
[name='zpac'] diff(z) = lambda*(e_c_m*(x1(-1)-z(-1)) + c_z_1*diff(z(-1)) + c_z_2*diff(z(-2)) + pac_expectation(pacman) + c_z_s*s + c_z_dv*diff(v) ) + (1-lambda)*( cy*y + cx*x) + c_z_u*u + c_z_dx2*diff(x2) + ez;
and in aggregated model we obtain:
[name='z'] diff(z) = lambda*(e_c_m*(x1(-1)-z(-1))+c_z_1*diff(z(-1))+c_z_2*diff(z(-2))+zpac_PE+s*c_z_s+diff(v)*c_z_dv)+(1-lambda)*(y*cy+x*cx)+u*c_z_u+diff(x2)*c_z_dx2+ez; with "s*c_z_s" and "diff(v)*c_z_dv".
I already observed this last year, ECB also complained about this (minor) issue, I thought this was fixed... We need to revisit the issue apparently. I am not sure I have an example where this happens.
I didn't manage to run your codes (didn't try to fix them). It appears that it is not obvious to fix this unfortunate behaviour in the processor... So it will probably have to wait. Meanwhile, if your problem is to look at the expanded equations, you can use the print_equations command. This routine prints all the equations where a variable appears. The routine has two arguments, the first one is the name of the variable, the second one (optional) is a boolean variable that you have to set to true if you wish to expand the expectations with the companion VAR variables. There is an example here. This routine does not rely on the preprocessor's JSON output to print the expanded expressions for the expectation terms (VAR or PAC), so there is no issue with the ordering of the parameters and variables.
I have added a nocommutativity option to the dynare command, that should solve the problem of parameters sometimes going after variables. Note however that we do not make it the default, because it may potentially have a performance impact on the preprocessing stage (at least for some models).
@sebastien, I just realized that nocommutativity option does not go on well with pac.estimate.nls. The problem arise when computing residuals, there is a +at the end of the rhs of r. Here is the error message:
Error using PrixValeurAjouteeEstimation.ssr_b1_sm_2_cherrypick
Error: File: ssr_b1_sm_2_cherrypick.m Line: 17 Column: 1287
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched
delimiters.
@Anastasia Can you send the file +PrixValeurAjouteeEstimation.ssr_b1_sm_2_cherrypick.m. Something is probably wrong in the NLS routine (when writing the sum of square residuals function).
Sure, here they are: one file is ok - without nocommutativity option, another one corresponds to the problem I described - with nocommutativity option.