Additional linearsolve Functions

linearsolve.ir(f, p, eps, s0=None)

Simulates a model in the following form:

(1)\[\begin{split}u_t &= fs_t + \epsilon_{t} \\\end{split}\]
(2)\[\begin{split}s_{t+1} &= ps_t \\\end{split}\]

where \(s_t\) is an (n_states x 1) vector of state variables, \(u_t\) is an (n_costates x 1) vector of costate variables, and \(\epsilon_t\) is an (n_states x 1) vector of exogenous shocks.

Parameters:
  • f (Numpy.ndarray) – Coefficnent matrix of appropriate size

  • p (Numpy.ndarray) – Coefficnent matrix of appropriate size

  • eps (Numpy.ndarray or list) – T x n_states array of exogenous shocks.

  • s0 (Numpy.ndarray or list) – 1 x n_states array of zeros of initial state value. Optional; Default: 0.

Returns:

Array containing two arrays: one corresponding to simulated \(u_t\) values and the other to simulated \(s_t\) values.

Return type:

Numpy.ndarray

linearsolve.klein(a=None, b=None, c=None, phi=None, n_states=None, eigenvalue_warnings=True)

Solves linear dynamic models with the form of:

(3)\[A E_tx_{t+1} = Bx_t + Cz_t\]

with \(x_t = [s_t; u_t]\) where \(s_t\) is a vector of predetermined (state) variables and \(u_t\) is a vector of nonpredetermined costate variables. \(z_t\) is a vector of exogenous forcing variables with autocorrelation matrix \(\Phi\). The solution to the model is a set of matrices \(f, n, p, l\) such that:

(4)\[u_t = fs_t + nz_t\]
(5)\[s_{t+1} = ps_t + lz_t.\]

The solution algorithm is based on Klein (2000) and his solab.m Matlab program.

Parameters:
  • a (Numpy.ndarray) – Coefficient matrix on future-dated variables

  • b (Numpy.ndarray) – Coefficient matrix on current-dated variables

  • p (Numpy.ndarray) – Coefficient matrix on exogenous forcing variables

  • phi (Numpy.ndarray or list) – Autocorrelation of exogenous forcing variables

  • n_states (int) – number of state variables

  • eigenvalue_warnings – Whether to print warnings that there are too many or few eigenvalues. Default: True

Returns:

  • f (Numpy.ndarray) - Coefficient matrix on state vector in control equation

  • p (Numpy.ndarray) - Coefficient matrix on state vector in state equation

  • n (Numpy.ndarray) - Coefficient matrix on forcing vector in control equation

  • l (Numpy.ndarray) - Coefficient matrix on forcing vector in state equation

  • stab (int) - Indicates solution stability and uniqueness. stab =1: too many stable eigenvalues, stab = -1: too few stable eigenvalues, stab = 0: just enough stable eigenvalues

  • eig (Numpy.ndarray) - Generalized eigenvalues from the Schur decomposition