gEconpy.solvers.gensys.gensys#

gEconpy.solvers.gensys.gensys(g0, g1, c, psi, pi, div=None, tol=1e-08, return_all_matrices=True)#

Christopher Sim’s gensys.

Solves rational expectations equations by partitioning the system into stable and unstable roots, then eliminating the unstable roots via QZ decomposition.

System given as:

\begin{aligned} G_0 \cdot y_t &= G_1 \cdot y_{t-1} + c \\ &\quad + \psi \cdot z_t + \pi \cdot \eta_t \end{aligned}

with \(z_t\) an exogenous variable process and \(\eta_t\) being endogenously determined one-step-ahead expectational errors.

Returned system is:

\begin{aligned} y_t &= G_1 \cdot y_{t-1} + C + \text{impact} \cdot z_t \\ &\quad + ywt \cdot (I - fmat \cdot L^{-1})^{-1} \cdot fwt \cdot z_{t+1} \end{aligned}

If \(z_t\) is i.i.d., the last term drops out. If div is omitted from argument list, a \(div > 1\) is calculated.

Parameters:
g0np.ndarray

Coefficient matrix of the dynamic system corresponding to the time-t variables.

g1np.ndarray

Coefficient matrix of the dynamic system corresponding to the time t-1 variables.

cnp.ndarray

Vector of constant terms.

psinp.ndarray

Coefficient matrix of the dynamic system corresponding to the exogenous shock terms.

pinp.ndarray

Coefficient matrix of the dynamic system corresponding to the endogenously determined expectational errors.

divfloat

Threshold value for determining stable and unstable roots.

tolfloat, default: 1e-8

Level of floating point precision.

return_all_matrices: bool, default True

Whether to return all matrices or just the policy function.

Returns:
G1np.ndarray

Policy function relating the current timestep to the next, transition matrix T in state space jargon.

Cnp.ndarray

Array of system means, intercept vector c in state space jargon.

impactnp.ndarray

Policy function component relating exogenous shocks observed at the t to variable values in t+1, selection matrix R in state space jargon.

fmatnp.ndarray

Matrix used in the transformation of the system to handle unstable roots.

fwtnp.ndarray

Weight matrix corresponding to fmat.

ywtnp.ndarray

Weight matrix corresponding to the stable part of the system.

gevnp.ndarray

Generalized left and right eigenvalues generated by qz(g0, g1), sorted such that stable roots are in the top-left corner.

eutuple

Tuple of two values indicating existence and uniqueness of the solution, with the following meanings:

  • eu[0] = 1 for existence,

  • eu[1] = 1 for uniqueness.

  • eu[0] = -1 for existence only with not-s.c. z;

  • eu = [-2, -2] for coincident zeros.

looseint

Number of loose endogenous variables.

Notes

Adapted from http://sims.princeton.edu/yftp/gensys/mfiles/gensys.m

References

[1]

Sims, Christopher A. “Solving linear rational expectations models.” Computational Economics 20.1-2 (2002): 1.