Semi Structural models in Dynare


I am working at a central bank that is developing a semi-structural model following ECB-Base closely. We have developed some PAC blocks in matlab but recently noticed the SSM sections in the Dynare documentation under the model file [4.26]. We are very encouraged by these new features.

Unfortunately we can’t quite get them to work the way we want them to. There are two issues.

(1) We want to use a core VAR for expectations but it seems the var_expectations function constrains you to have the actual variables in the var determined by the var plus exogenous terms. For example we would want the output gap to be determined by the IS equation with VAR expectations but as things stand this seems impossible as the output gap is also determined by the VAR in the model.

Where this becomes an issue is when you simulate forward in time you want to update the inputs to the forecasting VAR with the outturns instead of relying on forecasts from the VAR from the initial conditions. We basically are running into the same issue as in this post:

(2) In our PAC equations we’d like the target in the ECM term to be in levels and the auxiliary VAR to forecast the growth rate of the target in a trend component form pinned with attractors for the growth rate. Is there a way to override the definition of the target variable in the pac equation?

Thanks in advance for any thoughts!

Hi, thank you very much for your interest in this feature. Unfortunately, we currently do not have resources devoted to public documentation of these features. As a free software project mostly run by volunteers, there probably won’t be a quick fix to remedy this situation. Because few institutions support Dynare’s development (see, the funding basis is rather tenuous. I apologize for not having better news.


I too have been puzzling over how to use the VAR/PAC capabilities included in Dynare versions 5.x. I have some comments about the two issues you raise.

(1) The documentation is not clear about the relationship between the auxiliary (VAR or PAC) model and the main model in which an expectation generated by the auxiliary model is needed. Call the first model auxmod and the second mainmod. In general, the variables in auxmod will be a subset of those in mainmod. The purpose of auxmod is to create a formula for the expectation of future values of a variable – the output gap for example – to be used in mainmod, based on the simple structure of auxmod. Since auxmod is linear, this formula will be a linear function of the variables in auxmod. The workflow involves first processing auxmod (ie, dynare auxmod) to create the formula and then placing this formula as an equation in mainmod. However, the Dynare reference manual fails to mention a key command involved in this workflow, which can be either

var_expectation.print(model name) or
pac.print(model name)

One of these commands needs to be in auxmod. Each command writes several files whose contents define the expectatations function in a way that can either be cut and pasted into mainmod or, perhaps, included in mainmod using Dynare’s macro processing language. If xyz is the name of the folder that contains auxmod, these files are written to either


(2) You wrote:

In our PAC equations we’d like the target in the ECM term to be in levels and the auxiliary VAR to forecast the growth rate of the target in a trend component form pinned with attractors for the growth rate.

This can be done, but to do so involves dealing with two issues. One is how to code the auxiliary VAR. The other involves undoing an error in the one of the Dynare .m files.

Let X be the target variable and DX be a separate variable that is the first difference of X. One could include an equation for DX in the auxiliary model, but the Dynare PAC implementation does not provide a way for the user to indicate that DX is the first difference of X. However, any equation for DX can be transformed into an equation for X by replacing all of its DX terms with diff(X) terms. Care needs to be taken in doing this, as the processor does not permit multiple occurences of diff(X(-j)) to be in the equation.

Suppose that the desired equation is:

  diff(DX) = c1*(GR(-1) - DX(-1)) + c2*diff(DX(-1)) + c3*diff(DX(-2)) + ... other terms

GR is the growth rate attractor. The form of the equivalent equation using X rather than DX will need to be:

  diff(X) = c1*GR(-1) + (1+c2-c1)*diff(X(-1)) + (c3-c2)*diff(X(-2)) - c3*diff(X(-3)) + ...

Now about the error in one of the .m files, specifically matlab/pac-tools/hVectors.m. At the bottom of this file are two formulas for the vector H1, whose contents are the coefficients of the formula for the PAC expectation of the weight sum of the future values of delta(X) based on the structure of the auxiliary model. The first formula, which is always used, is correct when the auxiliary model contains an equation for DX. But as I noted, there is no way to implement this. The second formula, which is never used, is correct when the auxiliary model contains an equation for X, which is the only option available. To get the correct outcome in the tests I have been running, I’ve had to edit hVectors.m to modify the following block of code

    switch auxmodel
      case {'var', 'trend_component'}
        h1 = A_1*A_b*(kron(iota(m, m)'*inv(eye(m)-G), H')*(tmp\kron(iota(m, m), iota(n, idns))));
      case 'Need to check in which case we should trigger this one...'
        h1 = A_1*A_b*(kron(iota(m, m)'*inv(eye(m)-G), (H'-eye(length(H))))*(tmp\kron(iota(m, m), iota(n, idns))));

to be simply

        h1 = A_1*A_b*(kron(iota(m, m)'*inv(eye(m)-G), (H'-eye(length(H))))*(tmp\kron(iota(m, m), iota(n, idns))));


Hope this helps.

1 Like

Thank you so much for this. Very kind of you to lay it out in such detail. I will try and implement this next week in a toy example and see how it goes !

Yesterday, I noticed in the notes for the new beta version of Dynare 6 that a major revision is in the works for the PAC code. Hopefully this will resolve the issues that this thread has discussed. I don’t see any documentation yet about how to use the new code.

Hi, Sorry for the late response.

Version 6, soon to be released, will include an option (in the pac_model command) to select the formula used to compute the weights on the auxiliary model variables in the PAC expectation. Actually, it’s around in the unstable version since quite some time, but I only pushed the documentation yesterday:|%20dl

I don’t think I understand the part of the discussion about DX and X. Whatever the auxiliary model is, Dynare will recast it as a companion VAR. If the auxiliary model is a trend_component model, the only way to do that is to rewrite it in levels:

I may be missing something, but I don’t think you have to do that manually, otherwise there is no point to using a trend_component model.

Regarding the first question, we provide undocumented routines to fetch equations from various mod files and put them in a single mod files. Typically you can organise your codes in different .mod
files, where you perform the estimation (this can be done equation per equation or as system of equations with undocumented routines) and compute the VAR or PAC expectations. Then you cherry pick the equations you want to keep in your model (with the cherrypick routine)
and aggregate the selected equations in a single mod file that you will use to simulate the semi structural model (this is done with the aggregate routine). The aggregate and cherrypick routines are available in the matlab folder. Small examples are provided here:

These routines work with any kind of equation. In the final routine the PAC or VAR expectations will be developed in a human readable format (ie without the auxiliary variables). All this works with a
backward or MCE version of the model.

We can help with this. However, since our resources are limited, as well as our interest in these models, not through the forum. Eventually we would like to organise a workshop on these
topics, but that will take some time.



Thanks for the detailed and helpful reply. Hopefully, I now have enough information to go ahead and code, estimate, and assemble final results for one of the FRB/US PAC equations.