EconPapers    
Economics at your fingertips  
 

On the shoulders of giants: Writing wrapper commands in Stata

Sebastian Kripfganz

UK Stata Conference 2023 from Stata Users Group

Abstract: For repeated tasks, it is convenient to use commands with simple syntax which carry out more complicated tasks under the hood. These can be data management and visualization tasks or statistical analyses. Many of these tasks are variations or special cases of more versatile approaches. Instead of reinventing the wheel, wrapper commands build on the existing capabilities by 'wrapping' around other commands. For example, certain types of graphs might require substantial effort when building them from scratch using Stata's -graph twoway- commands, but this process can be automized with a dedicated command. Similarly, many estimators for specific models are special cases of more general estimation techniques, such as maximum likelihood or generalized method of moments estimators. A wrapper command can be used to translate relatively simple syntax into the more complex syntax of Stata's -ml- or -gmm- commands, or even directly into the underlying -optimize()- or -moptimize()- Mata functions. Many official Stata commands can be regarded as wrapper commands, and often there is a hierarchical wrapper structure with multiple layers. For example, most commands for mixed-effects estimation of particular models are wrappers for the general -meglm- command, which itself just wraps around the undocumented -_me_estimate- command, which then calls -gsem-, which in turn initiates the estimation with the -ml- package. The main purpose of the higher-layer wrappers is typically syntax parsing. With every layer the initially simple syntax is translated into the more general syntax of the lower-layer command, but the user only needs to be concerned with the basic syntax of the lop-layer command. Similarly, community-contributed commands often wrap around official or other community-contributed commands. They may even wrap around packages written for other programming environments, such as Python. In this talk, I discuss different types of wrapper commands and focus on practical aspects of their implementation. I illustrate these ideas with two of my own commands. The new -spxtivdfreg- wrapper adds a spatial dimension to the -xtivdfreg- command (Kripfganz and Sarafidis, 2021) for defactored instrumental variable estimation of large panel data models with common factors. The -xtdpdgmmfe- wrapper provides a simplified syntax for the GMM estimation of linear dynamic fixed-effects panel data models with the -xtdpdgmm- command.

Date: 2023-09-10
New Economics Papers: this item is included in nep-ger
References: Add references at CitEc
Citations:

Downloads: (external link)
http://repec.org/lsug2023/Stata_UK23_Kripfganz.pdf

Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.

Export reference: BibTeX RIS (EndNote, ProCite, RefMan) HTML/Text

Persistent link: https://EconPapers.repec.org/RePEc:boc:lsug23:09

Access Statistics for this paper

More papers in UK Stata Conference 2023 from Stata Users Group Contact information at EDIRC.
Bibliographic data for series maintained by Christopher F Baum ().

 
Page updated 2025-03-19
Handle: RePEc:boc:lsug23:09