The right way to code simulation studies in Stata
Tim Morris and
Michael Crowther ()
Additional contact information
Tim Morris: MRC Clinical Trials Unit, University College London
Michael Crowther: Biostatistics Research Group, Department of Health Sciences, University of Leicester
London Stata Conference 2019 from Stata Users Group
There are two broad approaches to coding a simulation study in Stata. The first is to write an rclass program that simulates and analyzes data before using the simulate command to repeat the process and store summaries of results. The second is to loop through repetitions and use the postfile family to store results. One favors the simulate approach because the code is much cleaner, so it is easier to spot mistakes. The other favors the postfile approach because it delivers a superior dataset summarizing simulation results. Both are good reasons. During yet another argument, we spotted a third approach that is unambiguously right because it uses cleanly structured code and delivers a useful dataset. This presentation will describe the issues with the simulate and postfile approaches before showing the correct approach. Simulation studies are an important element of statistical research, but they can be derailed, sometimes badly, by coding errors. The approach that gives both clean code and a usable dataset is worthwhile for all but the simplest simulation studies.
New Economics Papers: this item is included in nep-cmp
References: Add references at CitEc
Citations: Track citations by RSS feed
Downloads: (external link)
This item may be available elsewhere in EconPapers: Search for items with the same title.
Export reference: BibTeX
RIS (EndNote, ProCite, RefMan)
Persistent link: https://EconPapers.repec.org/RePEc:boc:usug19:07
Access Statistics for this paper
More papers in London Stata Conference 2019 from Stata Users Group Contact information at EDIRC.
Bibliographic data for series maintained by Christopher F Baum ().