G7 Commands: S¶
- save <savefile | “off”> [<datacommand>]
The save command opens a file of the name <savefile> to receive output produced by many of the command of G7, including type, f, fex, id, cc, (r)egress, matty, and other commands. The save file is closed and saving is terminated by:
save off
The default flag “-w” causes a new file to be created. The optional “-a” flag causes G7 to open an existing file and append text to the end. The save file represents a crucial step in the procedure of model building using the Build program. Normally, the procedure is as follows. One or more .REG (regression) files may be added during a G7 session to estimate the equations of a model. Each .REG file will include a save command, to save the regression results, as well as the steps of forming variables, using the various flavors of the f command. These files are usually given the file extension .SAV. Then the .SAV files are added by add commands in Build, or they may included in an Interdyme model using IdBuild’s iadd command.
Note that the save command also is a powerful tool for using G7 to create data files. You can use the G7 format command to control the width, decimal points, and observations per line of data series typed using either the type or stype commands.
The optional <datacommand> argument specifies how series will be printed out when using type. The default is for G7 to create an update command, to use for updating series in G7. However, other legal values of <datacommand> are:
- data:
write data cards
- update:
write “update” cards
- ovr:
write “ovr” fixes
- cta:
write “cta” fixes
- mul:
write “mul” fixes
- ind:
write “ind” fixes
- gro:
write “gro” fixes
- stp:
write “stp” fixes
- vdata:
write vdata cards for Vam
- vupdate:
write vupdate cards for Vam
- fix:
write LIFT style index fixes.
- dump:
write data in compact format.
- gf:
record estimated regression equations in G7 equation format.
Since Vam likes 4-digit dates, you can specify “yf 4” before using save to print vdata cards. Also, remember that you can insert comments into the save file using the ic command.
The “ovr”, “cta”, “mul”, “ind”, “gro”, and “stp” options above are for writing macro or vector fixes for Interdyme models. Remember that if you write a vector fix then you will need to hand-edit the file and change names like “out5” to “out 5”.
Related Topics: Build, Interdyme, Model Building, format, ic, listnamescol, print, sprint, stype, yearformat, zip
- <control>:
is a series from any bank (a.ctrl) or from any vector <b.vec2) or from any matrix(c.mat1.1) that contain the value to which the vector or matrix row or column is to be scaled.
For a vector:
- <vectorname>:
is the vector whose elements are to be scaled.
- <group>:
Optionally specifies which elements of the vector are to be scaled.
- <year>:
Optionally specifies a single year for which the elements of the vector are to be scaled. If not specified, the operation will be done over the current fdates.
- <rdscale>:
Optional argument of ‘r’ specifies that right direction scaling is to be used.
For a matrix:
- <matrixname>:
is the name of the matrix whose row or column is to be scaled.
- <r rnum>:
- <c cnum>:
specifies that a row or column is to be scaled and gives the number of the row or column.
- <colgroup>:
- <rowgroup>:
Optionally specifies which elements of the column or row are to be scaled.
- <year>:
Optionally specifies a single year for which the elements of the matrix are to be scaled. If not specified, the operation will be done over the current fdates.
- <rdscale>:
Optional argument of ‘r’ specifies that right direction scaling is to be used.
Example:
scale eqi2 bmf c 2This example scales column 2 of the matrix bm to sum to the control eqi2, for all years in the current fdates.
Example:
scale cont mat r 5 (1-10) 2000This example scales row 5, elements 1 to 10 of the matrix mat to sum to the control cont for the year 2000 only.
- second <on | off>
This command is used in estimating systemic two-stage least squares. This procedure is simple. Estimate the equations of the model by OLS or other single-equation method. Build the model with these equations and simulate it over the historical period. The simulated values of the endogenous variables are not influenced by the errors in the structural equations. They therefore may be used as regressors in the second stage to obtain estimates free of simultaneous equation bias. There are two variants of this procedure. In the first, the simulation is done using the simulated values for lagged values of endogenous variables; the other uses the actual values of these variables.
To perform the first variant, perform the simulation without any special command, copy the bank of simulation results to the G7 workspace, start G7, select the b option on the opening menu, do “bank bws” to put the actual values in the assigned bank, give the command “second on” so that f commands are ignored, and re-estimate the equations with the same add files as originally used. With second on, the dependent variable of the regression will be taken from the assigned bank; all others come from the workspace, which contains the simulated values. To turn off the second feature, the command is “second off”.
Related Topics: Build, Model Building
- seed(<integer>)
The seed command allows the user to reinitialize the random number generator. The random number generator is used with the @rand() and @normal() functions. The @rand() function draws from the uniform (0,1) distribution, and the @normal() function draws from the normal(0,1) distribution. If the seed command is called with identical arguments between calls to @rand() or @normal(), then these random number generators should return identical series.
Example:
seed(17568) f uni1 = @rand() seed(17568) f uni2 = @rand()
In this case, the series uni1 and uni2 will contain identical elements.
Related Topics: Functions, Particularly the @rand() and @normal()
For matrices, the show command has second format. The “view” argument must be one of the following:
- r:
for row
- c:
for column
- y:
for year.
If view is ‘r’, then <line> is the number of the row to be displayed. (A row is displayed as if it were a column.) If view is ‘c’, then <line> is the number of the column to be displayed. If view is ‘y’, then <line> is the year number.
Examples:
show b.am r 5 show b.am c 7 show b.am y 1997If <first_row> and <first_period> are specified for a vector, then the window will be scrolled so that the specified row and period will appear in the top left cell of the visible table. The same is available for displaying a row or a column of a matrix, where “view” is ‘r’ or ‘c’. If a single period of a matrix is displayed, where “view” is ‘y’, then the two arguments specify the cell to display in the top left corner.
If the title files that are specified in the Vam file are not found, then generic row and column titles will be created and displayed. If an alternative set of titles should be displayed, and those titles are stored in text files, then the file names for these alternative row and column titles may be specified at the end of the show command; “-rt” or “rowtitle” (or “-ct” or “columntitle”) and the filename indicate the appropriate file.
The Options menu item allows the user to control the number of decimal places, fonts, and colors of the display. The display can be copied to the clipboard in the usual way for Windows programs. The contents of the clipboard then can be copied into a spreadsheet such as Excel or into a table in a word processor. On the Copy menu, you may specify how much you want to be copied - just the numbers or also the frame. It is also possible to go in the other direction, from the spread sheet into the show window and thus into the Vam file.
Related Topics: gridtype
- sma <top> <first> <last> <order> [f]
To easily estimate a polynomial distributed lag, in which the lag coefficients are softly constrained to lie along a certain degree of polynomial, use the sma command, described here.
The sma command imposes a series of constraints that “softly” require the regression coefficients between <first> and <last> to lie on a polynomial of degree <order>. If the ‘f’ is present at the end, the polynomial is “free” at the end; without the f, the polynomial will be assumed to be zero for the coefficient after <last>.
Examples:
sma 100 a4 a9 3 f sma 100 a8 a16 1
Related Topics: Distributed Lags, Soft Constraints, con
- stack
The format for stack is exactly like that for sur (see below) except that “stack” replaces “sur”. With stack, no attention is paid to contemporaneous covariances. The point of stack is solely to impose soft constraints across regressions.
Limitation of stack and sur: G7’s limitation of 500 variables, counting dependent, intercepts,and independent variables, can quickly become binding in sur and stack, since it applies to the total variables in all equations involved in the sur or stack. This is far less restrictive than the 30-variable limit for older versions of G7.
Related Topics: sur
- stochastic < y | n >
Set stochastic to ‘y’ if you want to save the results of regressions as stochastic regressions. See the section on stochastic regressions for the details of how to do this.
Related Topics: Stochastic Regression
- store
This command stores the currently loaded vector back to the Vam file with the modifications that have been made. This store is automatic when a new load or implicit load is encountered. When a quit is encountered with an unstored loaded vector, the program automatically will store that vector.
Related Topics: load
For example,
str concept = "Output" str industry = "Coal Mining" str display = concept + "of the " + industry + " industry."
- str save <filename>
Store all defined strings in a text file <filename>. Afterward, the strings may be loaded into memory again.
For example,
str save MYSTRINGS.TXT add MYSTRINGS.TXT
- str store args <rootname>
Store all add-file or function arguments that are in scope in a series of strings. Each string name is created from the specified root name and the position (integer) of the argument in the argument list (e.g. root1, root2, …).
For example,
# Initialize a collection of series from a list of series names. Create new series or set existing series to zero. function Initialize{ str store args a do{ f %s( a%1 ) = 0 }(1 - %NARGS) } Initialize gdp consumption investment
- str print
Print each string to the screen.
- str clear [<stringname>]
Erase all defined strings from memory. If a string name is given, then that string will be removed from the list of user-defined strings.
- str replace [<stringname>] <”search_text”> <”replacement_text”>
This function operates on the string <stringname>, if provided, or the last line read by “str getline”. Any text in this string matched by the string <search_text> is replaced by the string <replacement_text>. Matching employs regular expressions as defined in the C++ Boost library. More details for regular expressions are provided on the following page.
Note
The Visual C++ Redistributable package must be installed in order to use some of the newest features. The VC++ installer should be available at C:PDGC++Install. Run this installer (run as Administrator if using Vista or Windows 7) before attempting to employ the “str replace” .
- str open <filename>
Open a file for parsing with the string .
- str close
Close the file that was opened with the str open .
- str getline [<string_name>]
Read a line of text from the file opened by str open. Store the text as a string named <string_name>. Store a copy of the string with the name “line;” this string may be referenced by related routines, but it does not appear in the list of user-defined strings.
- str parse [<string>] [“<separators>” [“<string_name>”]]
Split the string named <string> into words separated by any one of the characters listed as separators. If no string name is provided, then the routine acts on the last line read by str getline. The default separators list is composed of the space and tab characters, or “ \t”. The words are stored as a list of strings that may be accessed with the %w() function, which has a syntax similar to the %s() function described below. If a string name is suppied, it will be used as the root name of the stored words.
Note
The Visual C++ Redistributable package must be installed in order to use some of the newest features. The VC++ installer should be available at C:PDGC++Install. Run this installer (run as Administrator if using Vista or Windows 7) before attempting to employ the str replace.
- (subti)tle <text>
Provides <text> as a subtitle on subsequent graphs. Use subti with no following text to remove the subtitle.
- sur
The format for the sur command is shown by this example:
sur r y1 = x11, x12, ... ... r yn = xn1, xn2, ... con 10 1 = a2 + 4b5 + etc sma 100 a6 a12 1 do
After the sur command come all of the individual regressions. Any constraint or sma commands must come after the regressions. In the con and sma lines, a’s denote coefficients in the first regression; b’s coefficients in the second, and so on. Thus, a2 denotes the second coefficient of the first regression, and b5 denotes the fifth coefficient of the second regression.
The predicted values, dependent variables, and regression coefficients of the successive equations appear in the workspace file as predic1, depvar1, rcoef1, predic2, depvar2, rcoef2, etc. The results of the individual equations can be plotted by “gr *1”, “gr *2”, etc. The graph commands should follow the do command and each should be preceeded by an appropriate title command.
Related Topics: stack