IDEAS home Printed from https://ideas.repec.org/p/boc/lsug23/07.html

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
    ---><---

    References listed on IDEAS

    as
    1. William W. Gould, 2018. "The MATA Book: A Book for Serious Programmers and Those Who Want to Be," Stata Press books, StataCorp LLC, edition 1, number mata-book, March.
    Full references (including those not matched with items on IDEAS)

    Most related items

    These are the items that most often cite the same works as this one and are cited by the same works as this one.
    1. Álvaro A. Gutiérrez-Vargas, 2021. "Computing score functions numerically using Mata," London Stata Conference 2021 13, Stata Users Group.
    2. Yulia Marchenko, 2024. "Professional statistical development: What, why, and how," UK Stata Conference 2024 04, Stata Users Group.
    3. Daniel C. Schneider, 2023. "Discrete-time multistate regression models in Stata," German Stata Conference 2023 02, Stata Users Group.
    4. Yulia Marchenko, 2025. "Professional statistical software development: What, why, and how," 2025 Stata Conference 15, Stata Users Group.
    5. Álvaro A. Gutiérrez-Vargas, 2021. "Hunting for the missing score functions," 2021 Stata Conference 20, Stata Users Group.

    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.

    If CitEc recognized a bibliographic reference but did not link an item in RePEc to it, you can help with 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.