18
Stata Technical Bulletin
STB-20
. xi: regress y i.agegrp*wgt
i.agegrp Iagegr-l-4 (naturally coded; Irep78-1 omitted)
i.agegrp*wgt IaXwgt-l-4 (coded as above)
(output fromregressappears)
is
. xi i.agegrp*wgt
i.agegrp Iagegr.l-4 (naturally coded; Irep78.1 omitted)
i.agegrp*wgt IaXwgt-l-4 (coded as above)
. regress y Iagegr* IaXwgt*
(output from regress appears)
Warnings
1. When you use xi, either as a prefix or a command by itself, xi first drops all previously created interaction variables—variables
starting with capital I. Do not name your variables starting with this letter.
2. xi creates new variables in your data; most are bytes but interactions with continuous variables will have the storage
type of the underlying continuous variable. You may get the message “no room to add more variables”. If so, you must
repartition memory; see [4] memory.
3. When using xi with an estimation command, you may get the message “matsize too small”. If so, see [5u] matsize.
ssi6
Routines to speed Monte Carlo experiments
William Gould, Stata Corporation, FAX 409-696-4601
The syntax of the post commands is
postfile varlist using filename [, every(#) replace ]
post exp exp ... exp
postclos
These commands are utilities to assist Stata programmers in performing Monte Carlo type experiments. postfile declares the
variable and file names of a (new) Stata data set for containing results. post adds a new observation to the declared data set.
postclos declares an end to the posting of observations. All three commands manipulate the new results data without disturbing
the data in memory. After postclos, the new data set contains the posted results and may be loaded with use; see [5d] save.
Options
every (#) specifies how often posted results are to be written to disk. post attempts to be efficient by buffering results and
writing to disk only occasionally. every() should not be specified; the default value every(32)—23 for non-Intercooled
versions of Stata—is believed to be fastest. If every () is specified, it is taken as merely a suggestion; values that are too
large (larger than 208 for Intercooled and 23 for regular Stata) are treated as meaning every(32) and every(23).
replace indicates that the file specified (may) already exist and, if it does, postfile may erase the file and create a new one.
Remarks
Persons performing Monte Carlo experiments in Stata have, in the past, employed one of two programming approaches.
The first, originally suggested by Hamilton (1991), might be called the display-and-infile method. The basic idea is to start a
session log, display the results of the calculations on the screen (and therefore into the log), close the log, and read back the
results:
set more 1
log using filename
repeat {
draw a sample
make a calculation
display the results of the calculation
}
log close
infile the results previously displayed