Profile.do must be stored in one of the paths searched by Stata. Stata automatically runs the script profile.do upon launch (if found). Version control systems can be used as an alternative or complement to Dropbox. All files stored on Dropbox have the same relative paths, which is helpful when writing scripts (more on this below). Dropbox makes it easy to share files with coauthors. It creates backups across multiple computers and the Dropbox server, and in my experience has fewer bugs than alternatives such as Box. I use Dropbox to sync my projects across environments. Stata provides native support for running Python code, which I do not discuss here.
Stata commands code#
I focus on a setting where code is written in Stata and R. But, setting up your environment like I do will make it easier to develop your analysis in environments with multiple computers and coauthors. Note that users are NOT required to do this in order to run my published code.
Stata commands install#
Likewise, if you install an add-on on your local computer, it will not be available to your collaborators.īelow I describe how I set up my working environment to address these challenges. You could manually change this pathname every time a different person or different computer runs the code, but this solution is cumbersome for large projects with many lines of code. A project’s location may be /Users/jreif/my-project on one computer and /Users/coauthor/my-project on another computer. Using multiple environments makes it hard to define the pathname (location) of a folder. I work on several projects at the same time, access them from multiple computers (laptop, home, work), and share them with multiple coauthors. If you encounter any difficulties let me know. Try it out and see how easy (or not!) it is to reproduce my example analysis. The guide includes an accompanying AEA-compliant sample replication package that you are free to use as a template.
Stata commands how to#
This guide describes how to set up a robust coding environment and write a “push-button” analysis in Stata.
Unfortunately, most researchers (myself included) received little or no training in how to organize projects, write code, or document analyses.
Stata commands professional#
The American Economic Association’s (AEA) new data and code availability policy aims to improve this situation by imposing professional standards for coding and documentation. Research suggests that the results from many published papers cannot be reproduced from the code and data provided by the original authors. Peer review rarely evaluates code, even though code often represents the bulk of the work. These recent developments introduce complexity and the potential for non-transparent errors. Cutting edge analyses may require thousands or millions of lines of code written in multiple languages.
Analyses employing confidential data must be performed remotely, often on a non-networked computer at a research data center. Research teams frequently include multiple people working at different universities. Researchers commonly estimate regressions with millions of observations derived from multiple datasets. Empirical research in economics has grown in importance thanks to improvements in computing power and the increased availability of rich datasets.