gEconpy.model.perturbation.linearize_model#
- gEconpy.model.perturbation.linearize_model(variables, equations, shocks, order=1)#
Log-linearize a model around its steady state.
- Parameters:
- variables: List[TimeAwareSymbol]
List of all variables in the model, expressed at time t
- equations: List[sp.Expr]
List of equations that define the model.
- shocks: List[TimeAwareSymbol]
List of exogenous shocks in the model.
- order: int, default 1
Order of the linear approximation of the model. Currently only order = 1 is supported.
- Returns:
- Fs:
List[sp.Matrix] List of matrices representing the log-linearized model.
- not_loglin_variables:
sp.Symbol A special symbol created by the function that allows transformation between the log-linear and non-log-linear representations of the model. See the Notes for details.
- Fs:
Notes
Convert the non-linear model to its log-linear approximation using a first-order Taylor expansion around the deterministic steady state. The specific method of log-linearization is taken from ..[1]
\[F_1 T y_{t-1} + F_2 @ T @ y_t + F_3 @ T @ y_{t+1} + F4 \varepsilon_t = 0\]Each of F1, F2, F3, and F4 are the Jacobian matrices of the model equations with respect to the variables at time t-1, t, t+1, and the exogenous shocks, respectively.
The T matrix requires special note. It is a diagonal matrix with either the steady state value of the variable or 1, depending on whether the variable is log-linearized or not. Specifically:
\[T = \text{Diagonal}(y_{ss}^{1 - \text{not_loglin_variable})\]Where \(\text{not_loglin_variable}\) is a vector whose \(i\)-th value is zero if the \(i\)-th variable is log-linearized, and one otherwise. The \(T\) matrix arises from application of the chain rule. When a variable is assumed to be represented in logs, it is entered into all model equations as \(\exp(y)\) (indeed, Dynare requires the research to do exactly this). Having made this substitution, the partial derivative of a model equation \(f(exp(x))\) with respect to \(x\) is:
\[\frac{\partial f}{\partial x_ss} f(exp(x_ss)) = f'(exp(x_ss)) \cdot exp(x_ss)\]Since we interpret the variable \(y_{ss}\) as (implicitly) being in logs, this simplifies to \(f'(y_ss) \cdot y_{ss}\). On the other hand, if we are not log-linearizing the variable, the partial derivative is simply \(f'(y_ss)\). By setting the value of the exponent to 1 or 0, we can obtain the correct value of the derivative for each equation, with respect to each variable.
Evaluating the matrix multiplications between each \(F\) matrix and the \(T\) matrix, we obtain the following simplified expression:
\[A y_{t-1} + B y_t + C y_{t+1} + D \varepsilon = 0\]Matrices A, B, C, and D are returned by this function.
References
[1] gEcon User’s Guide, page 54, equation 9.9.