G7 Commands: I

ic <comment>

The ic (insert comment) command is used to put comments (lines beginning with ‘#’) into save files. This can be useful when you are writing a G7 data file and would like to put titles or comments next to each data series.

Related Topics: Comments, save

id <identity expression>

The id command 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. The syntax for the expression is the same as the f command.

Example:

ti 4. Additions and Alterations
fex cst4h = cst4$/hhld
r cst4h = ddi87h, rcmor, ratdif[1], hhead, singsh
id cst4$ = cst4h*hhld
gr *

This example is one of the construction equations from the IdLift model. The id statement is used here so that there will be a statement in the model to create cst4$ after calculating the regression. However, we don’t want the regression runstream to recalculate the value of cst4$ and put it into the workspace bank since the proper values of this series already were put into the bank by the previous fex statement.

Related Topics: Model Building, f, fdup, fex

if( [comparisons] ){ […] }
[ else if( [comparisons] ){ […] } ]
[ else{ […] } ]
The if command evaluates a series of logical expressions. If the arguments are true, then the following block of code, contained in a set of brackets, is executed. If the argument is false, then else if statements are processed in the same way. If all if and else if arguments are false, then the code following the final else command is processed.

Three types of comparisons are allowed. First, a number may be compared to a second number. Second, a single number may be given and implicitly compared to zero. Finally, a string may be compared to a second string.

Valid comparisons between two strings, with the comparison based on the lexicographical ordering, or between two numbers are

<:

is LESS THAN

<=:

is LESS THAN OR EQUAL TO

==:

is EQUALS

>=:

is GREATER THAN OR EQUAL TO

>:

is GREATER THAN

!=:

is NOT EQUALS

!:

is the logical negation operator. If given before a number, then the result is FALSE if the number is nonzero and the result is TRUE if the number is zero. If given before a set of parentheses, then the result is FALSE if the expression within the parentheses is TRUE, and the result is TRUE if the expression within the parentheses is FALSE.

Additional string comparison tools include:

strcmpi(<string1>,<string2>)

Compares string1 and string2, without case sensitivity. Value is TRUE if strings match.

strncmp(<string1>,<string2>,<N>)

Compares the first N characters of string1 and string2, with case sensitivity. Value is TRUE if the first N characters of the strings match.

strncmpi(<string1>,<string2>,<N>)

Compares the first N characters of string1 and string2, without case sensitivity. Value is TRUE if the first N characters of strings match.

Note

These routines have been replaced by the %strcmpi(), %strncmp(), and %strncmpi() routines.

Multiple comparisons may be performed, with the following operators joining them

||:

Logical OR, which returns TRUE if either the left hand side or the right hand side is TRUE.

&&:

Logical AND, which returns TRUE if both the left hand side and the right hand sides are TRUE, and returns FALSE otherwise.

The following list of keywords may be used:

NARGS:

The number of arguments passed to a function or to an add file.

exists(<series name>):

The presence of a series in a data bank can be tested. “exists(a.x)” returns true if variable x is found in bank a.

eval(series, date):

A number may be retrieved from a data bank for comparison. The value of series in period date is retrieved, either from the workspace or from the specified bank. The value may be compared to a scalar or to a second eval result.

Note

These routines have been replaced by the %NARGS, %exists(), and %getval() routines.

Comparisons may be evaluated as a group by surrounding them with parentheses. Blocks of code following the arguments must be surrounded by brackets {}.

Examples:

if( 1 - 2 < -0.5 )  { ic Subtraction }
if( 2 < 3 && 3 <= 4){ ic Multiple evaluations }
if( 2 < 3 || 3 <= 4){ ic Multiple evaluations with OR }
if( 1 == 1 )        { ic Equality }
else if( !0 )       { ic Else if and negation }
else                { ic Else }
if( D != N ){ ic String inequality comparisons }
if( D <= N ){ ic String less than or equal to }
if( mod(7,2) == 1 ) { ic Modulo arithmetic }
do{
   if( %1 == 3){
      ic Continuing on Iteration %1
      continue
      }           if( %1 == 5 ){
      ic Breaking on Iteration 5
      break
      }
          if( %1 > 5 ){ return ERR }
          }( 1-10 )
(in)dex <base date> <guide> <vector name>
(in)dex <base data> <guide> <groupname>
A quick way to fill in values of a vector so that they all grow at the same rate is to use of the index command. It is used in conjunction with a guide series, a previously established single-variable time series, whose growth rates will be applied to the elements of the vector. It acts over the range of the currently specified fdates.

For example, if “years” is the name of a series of the numbers of years – 1980, 1981, etc. – then to make all elements of the vector “pce” grow by 2.0 percent per year from 1999 to 2010, the following commands can be used:

f  g02 = @exp(0.02*(years - 1980))
index 1999 g02 pce

The use of groups is allowed in the names of series to be affected. To use groups, we must first use the load command to load the vector into memory. For example, to move only the sectors 1,7, and 9 of pce, we could do:

group 1 7 9
load pce
index 1999 g02 :

Recall that : is the name of the dynamic group, if it exists. To move just the sectors in the static or named group ConsumerDurables, the command would be:

load pce
index 1999 g02 :ConsumerDurables

To index only a specific vector element like “exp2”, the command would be

index 1999 g02 exp2

Provision of a vector or matrix name without a sector number means to move the whole vector or matrix by the index. This device can be used to project a whole input-output matrix, say, am, to be constant, as in this example:

fdates 1998 2020
f one = 1
index 1998 one am

A matrix name followed without a space by a sector number means to move that row of the matrix by the guide. Thus, “am2” means move the second row of the am matrix by the guide.

If <guide> is the name of a vector and <name> is the name of a matrix, then the rows of the matrix are indexed by the corresponding elements of the vector. If an element of the vector is zero in the base year, the corresponding rows of the matrix are unchanged. This feature works for both standard and packed matrices. It can be used to apply across-the-row coefficient change to an input-output matrix. For example, if mover is a vector, we can make each row of the am matrix follow the index of the corresponding element of mover with:

fdates 1998 2020
index 1998 movers am

In applying this sort of across-the-row coefficient change, one usually does not want it to apply to the diagonal elements, for they have little to do with the technological changes affecting other coefficients. For this, we would use the diagextract and diaginsert commands to save the diagonal first, then do the indexing, and then put the diagonal back into the matrix, as in the following example:

fdates 1998 2020
diagextract am diags
index 1998 movers am
diaginsert am diags

Related Topics: diagextract, diaginsert, fdates, group, rowscale

ipch [<which>] <label> <sector> [<type>] [<psn1>] … [<psnN>] [extra <var1> .. <varN>]

The ipch (Interdyme punch) command is used to create equation files for use in building Interdyme models, where:

<which>:

is the suffixed number

<label>:

is the name of the vector for which the equation is estimated

<sector>:

is the number of the sector to which the equation applies

<type>:

is a character (‘a’, ‘b’, etc.) that signals the type of form of the equation. The type should not be a numeral.

<psn1>:

(optional) the column number in the matrix where the first regression coefficient belongs.

<psnN>:

The column number in the matrix where the n’th regression coefficient belongs.

At the end of the command, type the word “extra” (without the quotes), and then type several variable names that hold the values of extra parameters you would like to pass to the file. For example, for an investment equation, which calculates capital stocks, and replacement investment, a physical service life is needed to calculated the spill rate. The following code would write the physical life at the end of the parameter list:

f plf1 = 4.9
r eqi1 = out1, out1[1], out1[2]
ipch eqi 1 a extra plf1

The ipch is not useful unless an equation file has already been opened with the punch command. See the Interdyme manual, chapter 4, for more information on the punch and ipch commands, and for details on detached-coefficient equations in Interdyme.

Related Topics: Interdyme Models, eqpunch, pch, punch, zip

intvar <prefix> <date1> <date2> [<date3> <date4> … <dateN>]

The intvar command makes up linear interpolation functions between the given dates. Each linear interpolation function begins at 0 and remains at 0 until its particular time interval comes; then it rises by 1 each period until the end of its interval. After that, it remains constant at whatever value it has reached. For example, if the <prefix> is “tax”, and we have 6 dates, 6 linear interpolation functions will be created, with names “tax1”, “tax2”, …, “tax6”. Then, if we regress a policy variable, such as the federal tax rate, on these functions, the predicted values from the regression take the shape of a set of spliced line segments, approximating the curve of the left hand side variable. For example, to approximate the federal personal tax rate in the Quest model, use:

r pitfBR = tax1, tax2, tax3, tax4, tax5, tax6

Related Topics: Optimization