{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How `linearsolve` Works\n", "\n", "The equilibrium conditions for most DSGE models can be expressed as a vector function $F$:\n", "\n", "\\begin{align}\n", "f(E_t X_{t+1}, X_t, \\epsilon_{t+1}) = 0,\n", "\\end{align}\n", "\n", "where 0 is an $n\\times 1$ vector of zeros, $X_t$ is an $n\\times 1$ vector of endogenous variables, and $\\epsilon_{t+1}$ is an $m\\times 1$ vector of exogenous structural shocks to the model. $E_tX_{t+1}$ denotes the expecation of the $t+1$ endogenous variables based on the information available to decision makers in the model as of time period $t$. \n", "\n", "The function $f$ is often nonlinear. Because the values of the endogenous variables in period $t$ depend on the expected future values of those variables, it is not in general possible to compute the equilibirum of the model by working directly with the function $f$. Instead it is often convenient to work with a log-linear approximation to the equilibrium conditions around a non-stochastic steady state. In many cases, the log-linear approximation can be written in the following form:\n", "\n", "\\begin{align}\n", "A E_t\\left[ x_{t+1} \\right] & = B x_t + \\left[ \\begin{array}{c} \\epsilon_{t+1} \\\\ 0 \\end{array} \\right],\n", "\\end{align}\n", "\n", "where the vector $x_{t}$ denotes the log deviation of the variables in $X_t$ from their steady state values. Given the function $f$, `linearsolve` computes matrices $A$ and $B$ numerically as:\n", "\n", "\\begin{align}\n", "A & = \\left[ \\frac{\\partial \\log f_1 }{\\partial \\log X_{t+1} } \\left(\\bar{X} \\right) - \\frac{\\partial \\log f_2 }{\\partial \\log X_{t+1} } \\left(\\bar{X} \\right) \\right]\n", "\\end{align}\n", "\n", "and:\n", "\n", "\\begin{align}\n", "B & = -\\left[ \\frac{\\partial \\log f_1 }{\\partial \\log X_{t+1} } \\left(\\bar{X} \\right) - \\frac{\\partial \\log f_2 }{\\partial \\log X_{t} } \\left(\\bar{X} \\right) \\right]\n", "\\end{align}\n", "\n", "The variables in $x_t$ are grouped in a specific way: $x_t = [s_t; u_t]$ where $s_t$ is an $n_s \\times 1$ vector of predetermined (state) variables and $u_t$ is an $n_u \\times 1$ vector of nonpredetermined (forward-looking) variables. $\\epsilon_{t+1}$ is an $n_s\\times 1$ vector of i.i.d. shocks to the state variables $s_{t+1}$. $\\epsilon_{t+1}$ has mean 0 and diagonal covariance matrix $\\Sigma$. The solution to the model is a pair of matrices $F$ and $P$ such that:\n", "\n", "\\begin{align}\n", "u_t & = Fs_t\\\\\n", "s_{t+1} & = Ps_t + \\epsilon_{t+1}.\n", "\\end{align}\n", "\n", "`linearsolve` computes the matrices $F$ and $P$ are using the [Klein (2000)](http://www.sciencedirect.com/science/article/pii/S0165188999000457) solution method which is based on the generalized Schur factorization of the marices $A$ and $B$. The solution routine incorporates many aspects of his Klein's Matlab program [solab.m](http://paulklein.ca/newsite/codes/codes.php). See Chapters 2 and 4 of [Structural Macroeconometrics](https://press.princeton.edu/titles/9622.html) by DeJong and Dave for a deeper descriptions of log-linearization and Klein's solution method." ] } ], "metadata": { "anaconda-cloud": {}, "celltoolbar": "Raw Cell Format", "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" } }, "nbformat": 4, "nbformat_minor": 1 }