IRIS Toolbox Reference Manual

Model File Language

Model file language is used to write model files. The model files are plain text files (saved under any filename with any extension) that describes the model: its equations, variables, parameters, etc. The model file, on the other hand, does not describe what 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 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.

Why do all the keywords (except pseudofunctions) start with an exclamation point? Why do the comments have the same style as in Matlab? Why do substitutions and steady-state references use the dollar sign? Because this way, you can get the model files syntax-highlighted in the Matlab editor. Syntax highlighting improves enormously the readability of the files, and helps understand the model more quickly. See the setup instructions for more details.

Variables, parameters, substitutions and functions

Equations

Linearised and log-linearised variables

Special operators

Pseudofunctions

Pseudofunctions do not start with an exclamation point.

Preparser control commands

Getting on-line help on model file language

When getting help on model file language, type the names of the keywords and commands without the exclamation point:

help modellang
help modellang/keyword
help modellang/command 
help modellang/pseudofunction

Matlab functions and user functions in model files

You can use any of the built-in functions (Matlab functions, functions within the Toolboxes you have on your computer, and so on). In addition, you can also use your own functions (written as an m-file) as long as the m-file is on the Matlab search path or in the current directory.

In your own m-file functions, you can also (optionally) supply the first derivatives that will be used to compute Taylor expansions when the model is being solved, and the second derivatives that will be used when the function occurs in a loss function.

When asked for the derivatives, the function is called with two extra input arguments on top of that function's regular input arguments. The first extra input argument is a text string 'diff' (indicating the call to the function is supposed to return a derivative). The second extra input argument is a number or a vector of two numbers; it determines with respect to which input argument or arguments the first derivative or the second derivative is requested.

For instance, your function takes three input arguments, myfunc(x,y,z). To be able to supply derivates avoiding thus numerical differentiation, the function must be written so that the following three calls

myfunc(x,y,z,'diff',1)
myfunc(x,y,z,'diff',2)
myfunc(x,y,z,'diff',3)

return the first derivative wrt to the first, second, and third input argument, respectively, while

myfunc(x,y,z,'diff',[1,2])

returns the second derivative wrt to the first and second input arguments. Note that second derivatives are only needed for functions that occur in an equation defining optimal policy objective, min.

If any of these calls fail, the respective derivative will be simply evaluated numerically.

Basic rules IRIS model files