G7 Commands: M¶
- madd <matrix A> = [bank letter.]<matrix B> + [bank letter.]<matrix C> [period]
The madd command performs addition or subtraction of two matrices and stores the results in a third. If the optional date <period> is absent, then the operation is done over the fdates range. If no bank letter is specified, the right-hand side matrices are assumed to be in the default Vam file.
Example:
fdates 1972 2020 madd A = B + C
This example forms A as the sum of B and C, over the period 1972 to 2020, with all matrices in the default Vam file.
Example:
fdates 1972 2020 madd A = e.B – e.C
This example forms A in the default Vam bank as the difference of B and C from bank ‘e’, over the period 1972 to 2020.
Related Topics: @bmk function, linv, mcopy, minv, mmult, mtrans
Related Topics: xl font
Related Topics: xl font
Related Topics: xl font
Related Topics: xl font
Form 1:
matdat gnp c cd cnd cs 1981.1 1513 950 146 359 445 1981.2 1512 949 140 361 448 1981.3 1522 956 143 361 450 ;Dates appear as the first number on each line. Here 1513 is the value of “gnp” in 1981.1, 1522 is the value in 1981.2, etc.
Form 2:
matdat 1981.1 gnp c cd cnd cs 1513 950 146 359 445 1512 949 140 361 448 1522 956 143 361 450 ;The date of the first observation appears on the command line, and no dates appear on subsequent lines. Use a semicolon to end the data. (You must have a semi-colon on the last line of data for either form.)
Here is yet another version of legal format for matdata.
Form 3:
matdat gnp out(1-4) 1981.1 1513 1512 1522 950 949 956 359 140 143 359 361 361 445 448 450;Here, series names are given immediately after matdat with starting date given as the last argument on the matdat line. The first series reads from the first line after the matdat, the second series reads from the second line, and so on. Note also that group definitions are allowed in this version.
Related Topics: data
Example:
matin govstr 1987 1 25 1 5 4 1 48 0 0 0 61 2 495 0 32 0 453 3 0 0 5 0 0 4 1344 0 0 0 1651 5 812 0 201 0 0 6 859 555 0 0 3012 ...The above example actually is used to introduce the distribution of government structures by 25 categories to 5 government types in IdLift. The data presented is for 1987, and covers rows 1 to 25 and columns 1 to 5 of the matrix. Four columns are to be skipped at the beginning of each line, and this is where we keep the row number, which serves to make the file easier to read.
- matin5 <matrix_name> <year>[<width> <decs> <IndexWidth>]
The matin5 command is another command for reading data for a matrix. These data are in a format called “punch5.” This is an input format for matrices that is useful when a significant number of the matrix elements may be zero. On each line, there are 5 cells (hence the name), and for each cell, the row, column and value are specified. For this command to work, a Vam file must be assigned and set as the default Vam file. In the above syntax, <matrix_name> is the name of the matrix as shown in VAM.CFG, <year> is the year of the data, <width>, <decs> and <IndexWidth> are optional arguments that specify the width of the data field for each cell, the number of decimal points, and the width of the field for the row and column indexes. The end of the matrix data is signaled either by a ‘;’ in the first space on a line or by the end of the file.
Here is a sample from the beginning of an A-matrix:
matin5 am 1977 9 5 3 # A-matrix for 1977. 83 rows and 83 columns. AM 1 1 0.245790 1 4 0.000220 1 8 0.000410 1 9 0.281300 1 10 0.058360 AM 1 11 0.002070 1 12 0.005680 1 13 0.000380 1 15 0.001700 1 16 0.003060 AM 1 22 0.089770 1 24 0.000070 1 48 0.001210 1 49 0.000130 1 50 0.000030
- maxobs <number>
This command sets the maximum number of observations that can be in any series in the workspace bank.
Example:
maxobs 1500
allows series with up to 1500 observations. The default value of maxobs is 600. Increasing the value slows down most data operations and may reduce the number of variables that can be included in any regression. If long series are to be stored in the workspace bank, the maximum number of observations in this bank should also be increased. This number is set at the end of the G.CFG file.
Note that you may delete the workspace bank and set all new parameters all in one fell swoop with the zap command.
Related Topics: G.CFG file, zap
- mcopy [bank letter.]<destination> = [bank letter.]<source> [<period>]
The mcopy command copies the matrix (or vector) from the source to the matrix (or vector) destination. If no bank letters are specified, then both the source and destination are assumed to be in the default Vam file. If a value is given for [period] then only the values for that period are copied. Otherwise, the starting period and ending period are determined by the fdates command.
Example:
vam \idlift\devel\hist b vam \idlift\model\hist a fdates 1972 2040 mcopy a.am = b.am
This example copies the matrix “am” from the IdLift development Vam file to the production Vam file for the period 1972 to 2040.
Note that the vc command also will copy vectors within the same Vam file, and the vc command also is capable of evaluating certain algebraic equations involving matrices.
Related Topics: Matrix Operations, madd, mmult, minv, linv, mtrans, vc
Related Topics: Drawing Graphs, graph
- minv [bank letter.]<matrix A> [period]
The minv command performs in-place matrix inversion. It works over the current fdates, or for the <period> specified.
Related Topics: Matrix Operations, linv, madd, mcopy, mtrans, mmult, vc
- missing <y | n> [<missing_text>]
This command does two things. First it tells G7 whether to rely on missing values to be present when performing regressions, interpolations, or other functions. When missing is set to “y”, then G7 will complain if missing values are in any of the data in a regression. Functions such as @benchmark and @lint rely on missing values to tell which periods of a series need to be filled. If missing is “n”, then G7 treats zeroes as missing values, and the regression command will not complain if there are zeroes.
The second function of the missing command is to supply some text to be displayed when missing values are present. A missing value is equal to -0.0000001, so by default it will be displayed as -0.0. However, by using the missing command, you can tell G7 to display missing values as “miss”, “N/A”, or some other character string. Just make sure that the <missing_text> is short enough to line up well with the other data being displayed.
You can convert the zeroes in a series to missing values by using the @miss() function. Conversely, you can convert missing values to zeroes using the @zeroes function.
Related Topics: Functions in G7, Missing Values
The asterisk (*) operator is matrix multiplication. If the matrices are conformable, then
mmult A = B*Cmultiples matrix B by matrix C and stores the result in matrix A. If a date is specified on the command line, the operation will be done for that period only. Otherwise, it is performed over the current fdates.
The apostrophe (’) operator forms the transpose of the first matrix and then calculates the matrix multiplication. If the matrices are conformable, then
mmult d.A = e.B'e.Cmultiples the transpose of matrix B in bank ‘e’ by matrix C in bank ‘e’ and stores the result in matrix A in bank ‘d’.
The slash (/) operator does element-by-element division. So,
mmult A = B / Cdivides each element of B by the corresponding element in C and places the result in A.
The ampersand (&) operator does element-by-element multiplication. So,
mmult A = B & Cmultiplies each element of B by the corresponding element in C, and places the result in A.
Related Topics: Matrix Operations, linv, madd, mcopy, minv, mtrans, vc
- mode <test | forecast> or mode <t | f>
mode determines what is to be done between <rdate2> and <rdate3>. The default mode is test. In that case, the values “predicted” by the equation for the period from <rdate2> to <rdate3> are compared to the actual data and SEE and MAPE parameters are computed for the test period. For forecast mode to work, the series for all independent variables except lagged values of the independent variable must extend to <rdate3>. Then, in forecast mode, two forecasts are made for the period from <rdate2> to <rdate3>. The first simply is the predicted value; the second is the predicted value plus the “rho adjustment” to take account of the error in the last period of fit.
- monup(mup) <series_name>
This command is used for updating a quarterly series with monthly data.
Example:
mup rtb 1983.3 9.120 9.390 9.050 8.710 8.710 8.960 1984.1 8.930 9.030 9.440;
“rtb” is a quarterly series being updated with monthly data. 9.120 is the value of rtb in July 1983; 9.390 is the value in August 1983, etc.. Note that quarterly dates are the first numbers on each line and three monthly observations must be present for each quarter.
- move <matrix> <up|down|left|right> <first> <last> <newfirst> [year]
This command moves a block a rows up or down, or moves a block of columns left or right, where:
- <matrix>:
is the name of a matrix whose rows or columns are to be moved.
- <up|down|left|right>:
indicates the direction of movement
- <first>:
indicates the first row or column of the block that is to be moved.
- <last>:
indicates the last row or column of the block that is to be moved.
- <newfirst>:
indicates the first row or column to which the block is to be moved.
- [year]:
specifies a single year. If not specified, the function will do the move for all years between the active fdates.
Example:
move fact left 2 4 1 1997
In this example, columns 2 through 4 are moved left and overwrite columns 1 through 3. Column 4 will be zero.
- mtrans <matrix A> [bank letter.]<matrix B> [period]
The mtrans command takes the transpose of the second matrix (B) and places it in the first matrix (A). The two matrices can be in different Vam files, but A must be in the default Vam bank. If no bank letter are specified for B, then B is assumed to be in the default Vam file.
mtrans A e.B
sets A to the transpose of B, where B is found in bank ‘e’.
Related topics: Matrix Operations, linv, madd, mcopy, minv, mmult, vc