File Exchange

image thumbnail

Automatic Solution and Log Linearisation of DSGE Models

version (3.7 KB) by Tom Holden
Code to analytically log linearise DSGE models in Matlab. Requires the symbolic toolbox.


Updated 04 Jun 2012

View License

PURPOSE: Performs log-linearisation.
SYNTAX: result = LogLin( VarEndoNames, VarExoNames, Parameters, Equations, SolveMode, EvalMode, EvalString, Digits );
EXAMPLE: result = LogLin( { 'R', 'A' }, { 'EPSILON' }, { 'beta', 'rho' }, { 'beta * R * A / A(+1) = 1', 'A = A(-1) ^ rho * exp( EPSILON )' }, 2, 2 );
OUTPUT: result: a cell array of log-linearised equations, with __d appended to variable names that are deviations from steady state.
INPUT: VarEndoNames: a cell array of endogenous variable names
% VarExoNames: a cell array of exogenous variable names
% Parameters: a cell array of parameter names
% Equations: a cell array of equations, in Dynare notation
% SolveMode: specifies how the steady state is found
% SolveMode = 0 ---> the steady state is not found, instead __s is appended to the variable names
% SolveMode = 1 ---> the steady state is found analytically
% SolveMode = 2 ---> the steady state is found analytically, allowing all algebraic manipulations
% SolveMode = 3 ---> the steady state is found analytically, assuming real values
% SolveMode = 4 ---> the steady state is found numerically
% EvalMode: specifies any processing of the found equations
% EvalMode = 0 ---> no additional processing
% EvalMode = 1 ---> simplification
% EvalMode = 2 ---> simplification, allowing all algebraic manipulations
% EvalMode = 3 ---> numeric evaluation, to Digits precision
% EvalString: string of comma delimited equations, useful for specifying parameters or your own computed steady state values (e.g. 'beta=0.99,rho=1/2', or 'A=1')
Digits: (optional) the number of digits of accuracy for numerical compuations
Copyright © 2011 Tom Holden ( )

Cite As

Tom Holden (2020). Automatic Solution and Log Linearisation of DSGE Models (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

Tom Holden

Rodrigo: You need at least r2016b. See

When using this new version this error message appears

Undefined function or variable 'newline'.

Error in LogLin (line 59)
nl = newline;


Fix works - thank you Tom. I'm not sure how to revise my ratings below. I would give it 5/5 stars.

Tom Holden

There's a fix for the bug mentioned by Brian here:

Does not seem capable of handling equations without lags/leads, e.g. aggregate resource constraints. Useful as a check on log-linearization by hand.

Tom Holden

I personally use Dynare almost exclusively. This is just for the rare times when people on insist on working with a log-linearised model.


What's the difference (advantage or disadvantage), between this model and dynare, do you recomend to use it for large DSGE models, does it provide a log-linearization result as equation.


Previous uploaded file accidentally contained both old and new code.

Typo correction (6 arguments are OK).

Removed mention of GPL from description.

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux