Model Building

This help topic discusses some of the G7 commands that are useful for model building. See The Craft of Economic Modeling by Clopper Almon for more on the use of G7 and Build to build macroeconomic models.

save <filename>

Opens the named file which then receives all (ti)tle, f, fex, id, and cc commands exactly as they appear on the screen. It also catches the output of (ty)pe commands but with the (ty)pe changed to update. Most important, the file receives the results of regressions in the form of equations with the variable names and values of the regression coefficients. Use save off to close the saved file and stop saving. By convention, not necessity, all “save” files are given the extension “.SAV”.

f, fex, and fdup all do the same thing in G7, but when passed to Build through a G7 “save” file:

f:

Computes the left-side variable and puts it and all of the right-side variables into the workspace, and also puts an identity into the model.

fex:

Computes the left-left side variable and puts it into the workspace. It does NOT put the right-side variables into the workspace and does NOT put an identity into the model. It is used to define historical values of exogenous variables, such as tax rates, and historical values of dependent variables of behavioral equations.

fdup:

This has no effect whatsoever in Build.

id <identity>

This has no effect in G7 but, when passed to Build, puts all variables (without computing the left-side one) into the workspace and puts an identity into the model.

check <variable name> <tolerance>

This command can only be placed in a “master” file for input into Build. It causes the named variable to be checked for convergence to within the specified tolerance. The values of the checked variables will be printed on the screen as the model runs. It generally is necessary to check only a few of the variables in a model.

cc <C language statement>

This has no effect in G7 or Build, but the C-language statement is passed through to the file HEART.C, which contains the model written in the C language and is ready for compilation. Such passed-through statements may be used to do special tasks for which G7 and Build have no convenient mechanism – such as scaling one group of variables to sum to another variable. For many models, no cc statements are needed.

sty <variable name>

Silent type. Prints the variable to the file being saved, but does not show it on the screen. See also the type command.

Matrix Operations in Models

For models involving matrices that vary over time, the InterDyme system should be used. However, constant matrices can be built into a model as described here. The following matrix commands can be placed only in a master file for input into Build. When they are used, the value of dimmax in COMMON.INC must be set equal to the largest dimension of the largest matrix.

vec <y> = <n1>, <n2>, <x1>, <x2>, …, <xn>
vec <y> = <n1>, <n2>
Defines the vector <y> with <n1> rows and <n2> columns. The two-dimensional specification is used to distinguish between row vectors and column vectors. The vec command forms the vector <y> by putting the variables <x1>, <x2>, …, <xn> into the corresponding components of <y>. When the variables <x1>, <x2>,…, <xn> are not specified, the vec command defines a zero vector. In the following example, fd is a column vector and nulv is a row vector. ::

Example:

vec fd = 2,1,auto,food
vec nulv = 1,4
mat <y> = <n1>, <n2>, <filename>
mat <y> = <n1>, <n2>
Defines the matrix <y> with <n1> rows and <n2> columns. The entries of <y> are fetched from the given file <filename> row by row. When the file name is not specified, the mat command defines a zero matrix.

Example:

mat iomat = 78, 78, io77.usa
mat cmat  = 78, 34
mop <y> = <x1> + <x2> (matrix addition)
mop <y> = <x1> - <x2> (matrix subtraction)
mop <y> = <x1> * <x2> (matrix multiplication)
mop <y> = <x1>’ (transposition)
mop <y> = <x1> ^ <x2> (vector component-wise multiplication )
Performs matrix operations. When addition, subtraction, multiplication, or transpose is done, the resulting matrix is stored in matrix <y>. With the ^ operation, the i-th component of the vector <y> will be the product of the i-th components of vectors <x1> and <x2>. WARNING! All matrices and vectors should be defined by the mat command and vec command before using the mop command.