The name is absent



22


Stata Technical Bulletin


STB-20


Summary

There is no question that the display-and-infile approach is the fastest way to run simulations in Stata. The 10,000-
replication simulation presented above, I estimate, would have taken only 8.5 minutes rather than the 13.5 minutes actually
observed. Nevertheless, I continue to reject using that method because it does not allow me to maintain logs of what I have done.
Moreover, it is easy to misinterpret these timings unless one remembers that they are absolute, not relative. For instance, the
difference in execution time for 10,000 replications is 5 minutes and that difference remains 5 minutes regardless of the complexity
of the simulation. Thus, I recently performed simulations involving bootstrapped quantile regression (10,000 replications of 50
replications, meaning estimation of 500,000 quantile regressions). This simulation took over 8 hours. The difference in execution
time between the logable buffered append and display-and-infile is still only 5 minutes.

More importantly, buffered append is substantially faster than the simple append method—in fact, regressions of time on
number of replications suggest that the buffered append method is nearly twice as fast once the fixed costs of the routines are
eliminated (for buffered append, each added replication is estimated as costing .0847 seconds; for the simple append, .1604
seconds; and the ratio is thus .1604/.0847 ≈ 1.89). As boot and bsqreg are currently implemented in terms of the simple-append
method, a doubling of performance should be possible by reimplementing these routines in terms of post.

References

Hamilton, L. C. 1991. ssi1: Monte Carlo simulation. Stata Technical Bulletin 1: 25-28.

ssi6.1 Simplified Monte Carlo simulations

William Gould, Stata Corporation, FAX 409-696-4601

The syntax of the simul command is

simul progname, reps(#) [ args (whatever) dots ]

simul eases the programming task of performing Monte Carlo type simulations. progname is the name of a program that
performs a single simulation. Typing ‘simul
progname, reps(#) ’ iterates progname for # replications and collects the results.

simul calls progname two ways. At the outset, simul issues “progname ?” and expects progname to set the global macro
$S_1 to contain a list of variable names under which results are to be stored. Thereafter, simul issues straight “
progname” calls
and expects it to perform a single simulation and to store the results using post. Details of post can be found in the insert
above, but enough information is provided below to use post successfully.

Options

reps(#) is not optional—it specifies the number of replications to be performed.

args (whatever) specifies any arguments to be passed to progname on invocation. The query call is then of the form “progname
w whatever
” and subsequent calls of the form “progname whatever”.

dots requests a dot be placed on the screen at the beginning of every call to progname, thus providing entertainment during a
long simulation.

Remarks

progname must have the following outline:

program define progname

if l.'f-..==..?.. {

global S_1 "aaribble names'1
exit

perform single simulation

post results

end



More intriguing information

1. Prevalence of exclusive breastfeeding and its determinants in first 6 months of life: A prospective study
2. The name is absent
3. Qualifying Recital: Lisa Carol Hardaway, flute
4. The Interest Rate-Exchange Rate Link in the Mexican Float
5. The name is absent
6. The name is absent
7. The name is absent
8. INSTITUTIONS AND PRICE TRANSMISSION IN THE VIETNAMESE HOG MARKET
9. The name is absent
10. The name is absent
11. A Note on Costly Sequential Search and Oligopoly Pricing (new title: Truly Costly Sequential Search and Oligopolistic Pricing,)
12. Critical Race Theory and Education: Racism and antiracism in educational theory and praxis David Gillborn*
13. The name is absent
14. Monetary Discretion, Pricing Complementarity and Dynamic Multiple Equilibria
15. Graphical Data Representation in Bankruptcy Analysis
16. The name is absent
17. Exchange Rate Uncertainty and Trade Growth - A Comparison of Linear and Nonlinear (Forecasting) Models
18. The name is absent
19. ARE VOLATILITY EXPECTATIONS CHARACTERIZED BY REGIME SHIFTS? EVIDENCE FROM IMPLIED VOLATILITY INDICES
20. Empirical Calibration of a Least-Cost Conservation Reserve Program