# Static variables in Dynare

Hi.
I know that Dynare solve the DSGE model in a state space form. In Blanchard-kahn(1980) we devide the endogenous variables into two different parts. State variables and non-predetermined variables. But in policy and transition functions Dynare gives equations structure for all endogenous variables.My question is that how Dynare include static variables into the Policy and transition functions?
In original Blanchard-kahn(1980) method we devide the variables into predetermined and non-predetermined variables and we do not include the static variables, but Dynare in it’s output report about the model in policy and transition functions shows equations relations for all endogenous variables including static variables.

1 Like

In Blanchard-Kahn, you need to substitute out all static variables to apply the approach. Dynare essentially uses the Schur approach of Klein (2000)

Thank so much Professor.
You are really very strong in DSGE models.
Therefore dynare employs Klein(2000) method and schur decomposition.

Solving rational expectations models at first order: what Dynare does, by Sébastien Villemot

Thank you so much professor. I think DSGE
Models are widespread and it takes many years to learn the details.

This excerpt from my lecture notes might help you regarding the guide of Villemot:

At period t, the model is given by:
\mathbb{E}_t \{ f\left(y_{t-1}^{*},y_t,y_{t+1}^{**},u_t\right) \}= 0
There are four types of endogenous variables:

• static variables: those that appear only at the current period, but not at the past or future period. Their number is n_{static}\leq n.
• purely backward (or predetermined) variables: those that appear only at the past period, possibly at the current period, but not at the future period. Their number is n_{pred}\leq n.
• purely forward variables: those that appear only at the future period, possibly at the current period, but not at the past period. Their number is n_{fwrd}\leq n.
• mixed variables: those that appear both at the past and future period, and possibly at the current period. Their number is n_{both}\leq n.

Note that each variables falls into one category, and we thus have the following identity: n=n_{static} + n_{pred} + n_{both} + n_{fwrd}. The state variables of the model, y_t^*, are the predetermined and mixed variables. Their number is n_{spred} = n_{pred} + n_{both}. We also define y_t^{**} as the mixed and forward variables, their number is n_{sfwrd} = n_{both} + n_{fwrd}. We also use Dynare’s specific ordering for variables (so-called DR-ordering), that is:
y_t = \begin{pmatrix} static\\ predetermined\\ mixed \\ forward \end{pmatrix}, y_t^* = \begin{pmatrix} predetermined\\ mixed\end{pmatrix}, and y_t^{**} = \begin{pmatrix} mixed \\ forward \end{pmatrix}

Then a dynamic equilibrium solution for this model class is equivalent to finding a function g, called policy-function or transition equation, for all endogenous variables:
y_t = g(y_{t-1}^*,u_t,\sigma)

Here it is useful to distinguish g for the different types of variables, i.e.
y_t^* = g^{*}(y_{t-1}^*,u_t,\sigma)
y_t^{**} = g^{**}(y_{t-1}^*,u_t,\sigma)
y_{t+1}^{**} = g^{**}(y_{t}^*,u_{t+1},\sigma) = g^{**}(g^{*}(y_{t-1}^*,u_t,\sigma),u_{t+1},\sigma).

The original model can then be written as a function of predetermined variables, current and future shocks, and the perturbation parameter:
F(y_{t-1}^*,u_t,\sigma,u_{t+1}) := f(y_{t-1}^*, g(y_{t-1}^*,u_t,\sigma), g^{**}(g^{*}(y_{t-1}^*,u_t,\sigma), u_{t+1}, \sigma), u_{t})
and you apply the perturbation technique on these functions.

### First-order approximation

The first-order Taylor expansion of the i-th equation of F around \bar{r}=(\bar{x},0,0,0) is written in tensor notation as
\left[F(r)\right]^{i} \approx \left[F(\bar{r})\right]^i + \left[F_{x}\right]^i_{\alpha_1} \left[\hat{x}\right]^{\alpha_1} + \left[F_{u}\right]^i_{\beta_1} \left[u\right]^{\beta_1} + \left[F_\sigma\right]^i \sigma + \left[F_{u_{+}}\right]^i_{\delta_1} \left[u_{+}\right]^{\delta_1}
Taking the conditional expectation and setting it to zero, yields
\left[F(\bar{r})\right]^i + \left[F_{x}\right]^i_{\alpha_1} \left[\hat{x}\right]^{\alpha_1} + \left[F_{u}\right]^i_{\beta_1} \left[u\right]^{\beta_1} + \left[F_\sigma\right]^i \sigma + \left[F_{u_{+}}\right]^i_{\delta_1} \left[\Sigma^{(1)}\right]^{\delta_1}\sigma = 0
where \left[F(\bar{r})\right]^i =0 and \left[\Sigma^{(1)}\right]^{\delta_1} is the \delta_1 entry of \Sigma^{(1)}=E_t\{u_{t+1}\}=0. Note that this equation needs to be satisfied for any value of \hat{x}, u and \sigma. Therefore, the necessary and sufficient conditions to recover the first-order partial derivatives of g with respect to x, u and \sigma can be retrieved from

The computation is done in sequence, starting with g_x, then computing g_u, and lastly g_\sigma. Note that the first-order approximation entails solving a matrix polynomial equation instead of a linear one (as in higher orders) for which several algorithms exist in the literature (under the keyword solving rational expectations models). Also, at first-order only the first moment of future shocks enters the equations, which is assumed to be zero.

#### Recovering g_{x}

{[z_{x}]}_{\alpha_1} = \begin{bmatrix} {[I]}_{\alpha_1}\\ [g_{x}]_{\alpha_1}\\ {[g^{**}_{x}]}_{\rho_1}{[g^{*}_{x}]}^{\rho_1}_{\alpha_1}\\ 0 \end{bmatrix}
{[F_{x}]}^i_{\alpha_1} = {[f_{z}]}^i_{\gamma_1} {[z_{x}]}^{\gamma_1}_{\alpha_1} = {[f_{y_{-}^*}]}^i_{\alpha_1} + {[f_{y_0}]}^i_{\rho^0_1} {[g_{x}]}^{\rho^0_1}_{\alpha_1} + {[f_{y_{+}^{**}}]}^i_{\rho^{+}_1} {[g^{**}_{x}]}^{\rho^{+}_1}_{\rho_1} {[g^{*}_{x}]}^{\rho_1}_{\alpha_1} = 0
Tensor unfolding yields the corresponding matrix representation:
z_{x} = \begin{pmatrix} I\\ g_{x}\\ g^{**}_{x} g^{*}_{x}\\ 0 \end{pmatrix}
F_{x} = f_{x} z_{x} = f_{y_{-}^*} + f_{y_0} g_{x} + f_{y_{+}^{**}} g^{**}_{x} g^{*}_{x} = A g_{x} + f_{y_{-}^*} = 0
where
A = f_{y_0} + \begin{pmatrix} \underbrace{0}_{n\times n_{static}} &\vdots& \underbrace{f_{y^{**}_{+}} \cdot g^{**}_{x}}_{n \times n_{spred}} &\vdots& \underbrace{0}_{n\times n_{frwd}} \end{pmatrix} is the important perturbation matrix.

Solving this system boils down to finding a solution to linearized rational expectations models, for which several algorithms have been proposed. The main idea is to first transform the system such that static endogenous variables no longer appear via a QR decomposition of the submatrix of f_{y_0} corresponding to columns for static endogenous variables, as derivatives with respect to static variables only appear in f_{y_{0}} and g_{y^*}. Then the core of the algorithm boils down to a generalized Schur decomposition (also known as the QZ decomposition) and a specific reordering such that stable generalized eigenvalues come first. After imposing two conditions: first, a squareness condition (the so-called Blanchard and Kahn (1980) order condition) and, second, a non-singularity condition (the so-called Blanchard and Kahn (1980 rank condition), we are able to find a stable and unique solution for the coefficients in g_x that correspond to predetermined, mixed and forward variables. Undoing the QR decomposition yields an invertible linear system to retrieve the coefficients corresponding to static variables. Experience shows that this algorithm is more generic and more efficient, especially for large models, than other algorithms proposed in the literature.

#### Recovering g_{u}

{[z_{u}]}_{\beta_1} = \begin{bmatrix} 0\\ [g_{u}]_{\beta_1}\\ {[g^{**}_{x}]}_{\delta_1}{[g^{*}_{u}]}^{\delta_1}_{\beta_1}\\ {[I]}_{\beta_1} \end{bmatrix}
{[F_{u}]}^i_{\beta_1} = {[f_{z}]}^i_{\gamma_1} {[z_{u}]}^{\gamma_1}_{\beta_1} = {[f_{y_0}]}^i_{\rho^0_1} {[g_{u}]}^{\rho^0_1}_{\beta_1} + {[f_{y_{+}^{**}}]}^i_{\rho^{+}_1} {[g^{**}_{x}]}^{\rho^{+}_1}_{\rho_1} {[g^{*}_{u}]}^{\rho_1}_{\beta_1} + {[f_{u}]}^i_{\beta_1}= 0
Tensor unfolding yields the corresponding matrix system:
z_{u} = \begin{pmatrix} 0\\ g_{u}\\ g^{**}_{x} \cdot g^{*}_{u}\\ I \end{pmatrix}
F_{u} = f_{z} z_{u} = f_{y_0} g_{u} + f_{y_{+}^{**}} g^{**}_{x} g^{*}_{u} + f_{u}= A g_u + f_u = 0
As we already computed g_x, and hence A, taking the inverse of A yields g_u.

#### Recovering g_{\sigma}

{[z_{\sigma}]} = \begin{bmatrix} 0\\ {[g_{\sigma}]}\\ {[g^{**}_{x}]}_{\rho_1} {[g^{*}_{\sigma}]}^{\rho_1} + {[g^{**}_{\sigma}]}\\ 0 \end{bmatrix}
{[F_{\sigma}]}^i = {[f_{z}]}^i_{\gamma_1} {[z_{\sigma}]}^{\gamma_1} = {[f_{y_0}]}^i_{\rho^0_1} {[g_{\sigma}]}^{\rho^0_1} + {[f_{y_{+}^{**}}]}^i_{\rho^{+}_1} {[g^{**}_{x}]}^{\rho^{+}_1}_{\rho_1} {[g^{*}_{\sigma}]}^{\rho_1} + {[f_{y_{+}^{**}}]}^i_{\rho^{+}_1} {[g^{**}_{\sigma}]}^{\rho^{+}_1} = 0
Tensor unfolding yields the corresponding matrix system:
z_{\sigma} = \begin{pmatrix} 0\\ g_{\sigma}\\ g^{**}_{x} g^{*}_{\sigma} + g^{**}_{\sigma} \\ 0 \end{pmatrix}
F_{\sigma} = f_{z} z_{\sigma} = f_{y_0} g_{\sigma} + f_{y_{+}^{**}} g^{**}_{x} g^{*}_{\sigma} + f_{y_{+}^{**}} g^{**}_{\sigma} = S g_{\sigma} = 0
where
S = A + \begin{pmatrix} \underbrace{0}_{n \times n_{static}}&\vdots & \underbrace{0}_{n \times n_{pred}} & \vdots & \underbrace{f_{y^{**}_{+}}}_{n \times n_{sfwrd}} \end{pmatrix}

As we already computed g_x, and hence S, taking the inverse of S yields
g_\sigma = 0

This is a manifestation of the certainty equivalence property of the first order approximation. Even though agents take the effect of future shocks into account when optimizing, in a linearization to the first-order the policy rules and transition equations do not depend on the size of the structural shocks. In this sense future uncertainty does not matter.

I did not understand anything from your notation.

No problem Just have a look into the Villemot paper then. He uses a + superscript when I used ** and a - superscript when I used *.

Dear all,

I have a follow-up question on this topic. I want to find the steady state for a system of equations using Dynare, but I have 4 static variables that I need to substitute out to be able to check the BK-conditions. I have equations that describe the static behaviour of the 4 variables, but I cannot solve explicitly for them. How can I proceed here?

Simon

I am not sure what you mean. The BK conditions are local stability condition, i.e. for linear difference equations. In linear equations, it is always possible to explicitly solve (unless the rank condition is not satisfied).

To make it more clear:
I am dealing with the following system (for a project in Environmental Macro). I want to find the steady state values for V^C_{iK_i}, V^C_{jK_j} V_{iR_i}^{C}, V_{jR_j}^C V_{iP}^C+V_{jP}^C, V_i^C+V_j^C, K_i, K_j, R_i, R_j, P. The system of difference equations is given by:

\begin{align*} V^C_{iK_i}&=\beta p V_{iK_i}^{A+}\tilde AF_{K_i}+\beta (1-p)V_{iK_i}^{C+}\tilde AF_{K_i}, \: i=1,2, \\ V_{iR_i}^{C}&=\beta p V_{iR_i}^{A+}+\beta (1-p)V^{C+}_{iR_i}, \: i=1,2,\\ V_{iP}^C+V_{jP}^C&=\beta(1-\gamma) p' (V_i^{C+}+V_j^{C+})-\beta(1-\gamma) p'( V_i^{A+}+ V_j^{A+})-\beta(1-p)(1-\gamma)(V_{jP}^{C+}+ V_{iP}^{C+}). \\ V_i^C+V_j^C&= U(C_i)+U(C_j)+\beta p[V_i^{A+}+V^{A+}_j]+\beta(1-p)[V_i^{C+}+V_j^{C+}],\\ K_i^+&=AK_i^\alpha E_i^\kappa -C_i, \: i=1,2, \\ R_i^+&=R_i-E_i, \: i=1,2, \\ P^+&=\psi(E_1+E_2)+(1-\gamma)P. \end{align*}
I also know that static equations for E_i, E_j, C_i, C_j are given by:
\begin{align} \text{w.r.t. } E_i:\: &\beta H(P^+) [V_{i K_i}^{A+}(1-\pi_i)AF_{E_i}-V_{i R_i}^{A+}]+\beta H'(P^+) \psi V_i^{A+} \nonumber \\ &+\beta [1-H(P^+)][V_{i K_i}^{C+}AF_{E_i}-V_{i R_i}^{C+}+V_{i P}^{C+}\psi]-V_i^{C+}\beta H'(P^+)\psi \nonumber \\ &+ \beta H'(P^+)V_j^{A+}\psi + \beta[1-H(P^+)]V_{j P}^{C+}\psi - V_j^{C+}\beta H'(P^+)\psi=0, \: i,j=1,2, \: i\neq j,\nonumber \\ \text{w.r.t. } C_i: \: &U'(C_i)-\beta H(P^+)V_{i K_i}^{A+}-\beta [1-H(P^+)]V_{i K_i}^{C+}=0, \: i=1,2. \nonumber \end{align}
So I want to substitute out E_i, E_j, C_i, C_j of the system by means of the equations above, but I cannot solve them explicitly, I think. Is there a way to work this out with Dynare?

I still don’t understand what you are trying to do. Is it about the steady state computations or manually computing the solution based on Blanchard/Kahn?
In Dynare, there is no point of replacing static variables manually. The solution algorithm will handle that for you.

Dear Prof. dr. Pfeifer,

My goal is to find the steady state values of the first system above using the command ‘steady’ in Dynare. The system contains 11 equations and 15 variables, 11 of which have their own difference equation. The other 4,E_i,E_j,C_i,C_j, are static and I want to get rid of them. The values for the 4 static variables are determined by the 2nd set of equations.

My question is then: can I feature the second set of equations aswell in my matlab file so that I do not (if it is even possible to do so) have to solve the second set explicitly for E_i,E_j,C_i,C_j?

I hope this makes it more clear.

Kind regards,

Simon

In steady state, you will have a system of 15 static equations in 15 unknowns. There is no meaningful distinction between static and dynamic variables. That nonlinear equation system needs to be solved.

Dear prof. dr. Pfeifer,

Thank you very much for your response, it is clear now.

Kind regards,

Simon