IDEAS home Printed from https://ideas.repec.org/p/boc/usug21/13.html

Computing score functions numerically using Mata

Author

Listed:
  • Álvaro A. Gutiérrez-Vargas

    (Research Centre for Operations Research and Statistics, KU Leuven)

Abstract

Specific econometric models - such as the Cox regression, conditional logistic regression, and panel-data models - have likelihood functions that do not meet the so-called linear-form requirement. That means that the model's overall log-likelihood function does not correspond to the sum of each observation's log-likelihood contribution. Stata's m1 command can fit said models using a particular group of evaluators: the d-family evaluators. Unfortunately, they have some limitations; one is that we cannot directly produce the score functions from the postestimation command predict. This missing feature triggers the need for tailored computational routines from developers that might need those functions to compute, for example, robust variance-covariance matrices. In this talk, I present a way to compute the score functions numerically using Mata's deriv() function with minimum extra programming other than the log-likelihood function. The procedure is exemplified by replicating the robust variance–covariance matrix produced by the clogit command using simulated data. The results show negligible numerical differences (e-09) between the clogit robust variance–covariance matrix and the numerically approximated one using Mata's deriv() function.

Suggested Citation

  • Álvaro A. Gutiérrez-Vargas, 2021. "Computing score functions numerically using Mata," London Stata Conference 2021 13, Stata Users Group.
  • Handle: RePEc:boc:usug21:13
    as

    Download full text from publisher

    File URL: http://fmwww.bc.edu/repec/usug2021/usug21_gutierrez-vargas.pdf
    File Function: presentation materials
    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. Yulia Marchenko, 2024. "Professional statistical development: What, why, and how," UK Stata Conference 2024 04, Stata Users Group.
    2. Daniel C. Schneider, 2023. "Discrete-time multistate regression models in Stata," German Stata Conference 2023 02, Stata Users Group.
    3. Daniel C. Schneider, 2023. "Object-Oriented Programming in Mata," UK Stata Conference 2023 07, 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:usug21:13. 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.