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

Object-Oriented Programming in Mata

Author

Listed:
  • Daniel C. Schneider

    (Max Planck Institute for Demographic Research, Rostock, Germany)

Abstract

Object-oriented programming (OOP) is a programming paradigm that ubiquitous in today's landscape of programming languages. OOP code proceeds by first defining separate entities - classes - and their relationships, and then lets them communicate with each another. Mata, Stata's matrix language, does have such OOP capabilities. In comparison to some other programming languages that are object-oriented, like Java or C++, Mata offers a lighter implementation, but does so by striking a nice balance between feature availability and language complexity. This talk explores OOP features in Mata by describing the code behind -dtms-, a community-contributed package for discrete-time multistate model estimation.*** Estimation in -dtms- proceeds in several steps, where each step can nest multiple results of the next level, thus building up a tree-like structure of results. The talk explains how this tree-like structure is implemented in Mata using OOP, and what the benefits of using OOP for this task are. These include easier code maintenance via a more transparent code structure, shorter coding time, and an easier implementation of efficient calculations. The talk will at first provide simple examples of useful classes; e.g., a class that represents a Stata matrix in Mata, or a class that can grab, hold, and restore Stata e()-results. More complex relationships among classes will then be explored in the context of the tree-like results structure of -dtms-. While topics covered will include such technically sounding concepts as class composition, self-threading code, inheritance, and polymorphism, an effort will be made to link these concepts to tasks that are relevant to Stata users that have already gained or are interested in gaining an initial proficiency of Mata.

Suggested Citation

  • Daniel C. Schneider, 2023. "Object-Oriented Programming in Mata," UK Stata Conference 2023 07, Stata Users Group.
  • Handle: RePEc:boc:lsug23:07
    as

    Download full text from publisher

    File URL: http://repec.org/lsug2023/Stata_UK23_Schneider.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: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.

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