EconPapers    
Economics at your fingertips  
 

Object-Oriented Programming in Mata

Daniel C. Schneider ()
Additional contact information
Daniel C. Schneider: Max Planck Institute for Demographic Research, Rostock, Germany

UK Stata Conference 2023 from Stata Users Group

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.

Date: 2023-09-10
New Economics Papers: this item is included in nep-ger
References: View complete reference list from CitEc
Citations:

Downloads: (external link)
http://repec.org/lsug2023/Stata_UK23_Schneider.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:07

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