Code

The \solve\code\ subdirectory contains the code for solving the linearized version of a model (solvea.m, solveb.m, checksolve.m, solver.m, qzdiv.m, qzswitch.m).

Additional files used in the examples, but of more general applicability, have been collected here.

For a more complete description of each file, type at the Matlab prompt 'help file'.

.m files

 bisect Finds the root of a given function using bisection. chroot Checks the accuracy of the feedback part of the solution (matrix A). If A fails the accuracy test, it tries to improve it. LC checksolve Checks the accuracy of the solution matrices A and B. LC derivmat Returns the derivative of row line, line=1,...,M, of (Mx1) function at the point x, and an estimate of the derivative error (in %). HS-VV covsp Computes the covariance matrix C(t)=E[y(t)*y(t-t)'] integrating (Gauss-Legendre quadrature) over [-p,p] the spectral density of y(t) = [z(t); x(t)]. z(t) = A * z(t-1) + B * s(t) x(t) = G1 * z(t-1) + G2 * s(t) s(t) = P * s(t-1) + e(t), Var(e(t))=Ve It allows HP filtering of y(t). gauleg Given the lower and upper limit of integration, this routine returns two vectors containing the abscissas and weights of Gauss-Legendre n-point quadrature formula. hptrend Detrends time series with Hodrick-Prescott (HP) filter. EM npdf Computes the pdf of the standard normal distribution. pentle Solves a pentadiagonal system of linear equations. EM solvea Computes the feedback part of the policy rule (the matrix A) finding the zero of a matrix polynomial. LC qzdiv Takes upper triangular matrices A, B, orthonormal matrices Q, Z, rearranges them so that all non-zero elements are in lower right corner, while preserving upper triangularity, orthonormal properties and Q'AZ' and Q'BZ'. CS qzswitch Takes upper triangular matrices A, B, orthonormal matrices Q, Z, interchanges diagonal elements i and i+1 of both A and B, while maintaining Q'AZ' and Q'BZ' unchanged. CS solveb Computes the feedforward part of the policy rule (the matrix B) solving a system of linear equations, conditional on A. LC solver Solves for the matrix R used to compute the matrix, B, in the case where there is partial information. LC spectral Gives the spectral denstiy of y(t) = [z(t); x(t)] at frequency w in [-p,p] z(t) = A * z(t-1) + B * s(t) x(t) = G1 * z(t-1) + G2 * s(t) s(t) = P * s(t-1) + e(t), Var(e(t))=Ve suptitle Puts a title above all subplots. DT trile Solves a tridiagonal system of linear equations. EM tsemat Finds the Taylor series expansion of a matrix function. HS-VV

LC = Lawrence Christiano

EM = Ellen McGrattan

CS = Chris Sims

HS = Henry Siu

DT = Drea Thomas

VV = Victor Valdivia