Skip to content

Overview of model source language

The model source language is used to describe all the elements of a model in human-readable form: variables, parameters, shocks, equations, etc. The model source is then translated to a structural model object.

Slang is a set of keywords that define the structure of model source files. The model source files are plain text files (saved under any file name with any extension) that describe the model: its equations, variables, parameters, etc. The model files do not describe what tasks to do with the model. To run the tasks you want to perform with the model, you need first to load the model file into Matlab using the Model.fromFile function. This function creates a model object. Then you write your own m-files using Matlab and Iris functions to perform the desired tasks with the model object.

When writing model files, you can also use the Iris preparsing commands that introduce tools for writing reusable and well-structured model code base and minimize repetitive model code writing tasks.

You can get the model source files syntax highlighted in the Matlab editor to improve the readability of the files, and helps navigate the model more quickly; see the setup instructions.

Guidelines

Topic Description
Writing source code Guideline for writing and structuring model source files
Declaring model names Declare model names: Variables, shocks, parameters
Writing model equations Write model equations

Categorical list of keywords

Declaring model names: Variables, parameters and shocks

Keyword Description
!transition-variables Declare names of transition variables
!transition-shocks Declare names of transition shocks
!measurement-variables Declare names fo measurement variables
!measurement-shocks Declare names of measurement shocks
!parameters Declare names of parameters
!exogenous-variables Declare names exogenous variables

Writing model equations

Keyword Description
!transition-equations Block of transition equations
!measurement-equations Block of measurement equations
!dtrends Block of deterministic trend equations
!links Define dynamic links
!preprocessor Preprocessing equations
!postprocessor Postprocessing equations

Controlling log status of variables

Keyword Description
!log-variables List of log-linearised variables
!all-but Inverse list of log-linearised variables

Defining autoswap pairs

Keyword Description
!autoswaps-simulate Definitions of variable-shock pairs to be autoswapped in dynamic simulations
!autoswaps-steady Definitions of variable-parameter pairs to be autoexogenized in steady-state calculations

Other keywords and syntax

Keyword Description
min Define loss function for optimal policy
!! Steady-state versions of equations
|| Separate alias from the rest of name or equation description
{...} Lag or lead
& Reference to the steady-state level of a variable
!ttrend Linear time trend in deterministic trend equations

Pseudofunctions

Note that pseudofunctions do not start with an exclamation point

Keyword Description
diff First difference pseudofunction
roc Gross rate of change pseudofunction
pct Percent change
difflog First log-difference pseudofunction
movavg Moving average pseudofunction
movgeom Moving geometric average pseudofunction
movprod Moving product pseudofunction
movsum Moving sum pseudofunction

Preparsing keywords

Keyword Description
% Line comments
%{ ... %} Block comments
<...>
!export Create exportable file to be saved in working directory.
!for For-loop control structure for automated creation of model source code
!function Create exportable m-file function to be saved in working directory
!if Choose block of code based on logical condition.
!import Include the content of another model file.
!substitutions Define text substitutions
!switch Switch among several cases based on expression.