IDEAS home Printed from https://ideas.repec.org/p/boc/lsug23/09.html
   My bibliography  Save this paper

On the shoulders of giants: Writing wrapper commands in Stata

Author

Listed:
  • Sebastian Kripfganz

    (University of Exeter)

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.

Suggested Citation

  • Sebastian Kripfganz, 2023. "On the shoulders of giants: Writing wrapper commands in Stata," UK Stata Conference 2023 09, Stata Users Group.
  • Handle: RePEc:boc:lsug23:09
    as

    Download full text from publisher

    File URL: http://repec.org/lsug2023/Stata_UK23_Kripfganz.pdf
    Download Restriction: no
    ---><---

    More about this item

    NEP fields

    This paper has been announced in the following NEP Reports:

    Statistics

    Access and download statistics

    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:lsug23:09. 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.

    IDEAS is a RePEc service. RePEc uses bibliographic data supplied by the respective publishers.