Author
Listed:
- Yunhan Liu
(Carleton University)
Abstract
Monte Carlo simulations in Stata are often constrained by the software’s memory architecture, particularly when the total number of replications required for inference or robustness checks is large. As memory consumption accumulates over the course of a simulation, performance can degrade severely, with many replications failing because of insufficient available RAM. This poster presents a procedure that bypasses these constraints by dividing the full simulation task into smaller, memory-manageable batches, which are executed independently in separate Stata sessions. The method relies on partitioning the total number of replications, R, into B batches of r replications each, where R=B×r. Each batch is encoded in a distinct Stata do-file, generated automatically via a short Python script. These batch files are then executed sequentially or in parallel using a Bash shell script. Because each batch runs in its own instance of Stata, memory usage is reset between runs, preventing the accumulation of data across replications. This approach allows simulations that were previously infeasible because of RAM limitations to run to completion. In addition to resolving memory constraints, the method enables embarrassingly parallel computation on multicore machines without requiring any specialized parallel-processing software. By assigning different batch files to different processor cores via concurrent shell calls, total run time can be substantially reduced. After a brief setup phase involving preprocessing and batch generation, the entire simulation can be launched with a single command. The proposed workflow improves the feasibility and efficiency of large-scale Monte Carlo experiments in Stata, especially in environments with modest hardware and limited software support for parallelization.
Suggested Citation
Handle:
RePEc:boc:cand25:07
Download full text from publisher
Corrections
All material on this site has been provided by the respective publishers and authors. You can help correct errors and omissions. When requesting a correction, please mention this item's handle: RePEc:boc:cand25:07. See general information about how to correct material in RePEc.
If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.
We have no bibliographic references for this item. You can help adding them by using this form .
If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your RePEc Author Service profile, as there may be some citations waiting for confirmation.
For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: Christopher F Baum (email available below). General contact details of provider: https://edirc.repec.org/data/stataea.html .
Please note that corrections may take a couple of weeks to filter through
the various RePEc services.