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

Making Stata estimation commands faster through automatic differentiation and integration with Python

Author

Listed:
  • Paul Lambert

    (University of Leicester
    Karolinska Institutet)

Abstract

Fitting complex statistical models to very large datasets can be frustratingly slow. This is particularly problematic if multiple models need to be fit, for example, when using bootstrapping, cross-validation, or multiple imputation. I will introduce the mlad command, as an alternative to Stata's ml command, to estimate parameters using maximum likelihood. Rather than writing a Stata or Mata function to calculate the likelihood, mlad requires this to be written in Python. A key advantage is that there is no need to derive the gradient vector or the Hessian matrix because these are obtained through automatic differentiation using the Python Jax module. In addition, the functions for the likelihood, gradients, and Hessian matrix are compiled and able to use multiple processors. This makes maximizing likelihoods using mlad easier to implement and substantially faster than using ml with the advantage that all results are returned to Stata. Implementing mlad on the author’s own estimation commands leads to speed improvements of 70–98% compared with ml. The syntax of mlad is almost identical to that of ml, making it easy for programmers to add an option to their estimation command so that users using large datasets can benefit from the speed improvements.

Suggested Citation

  • Paul Lambert, 2021. "Making Stata estimation commands faster through automatic differentiation and integration with Python," 2021 Stata Conference 24, Stata Users Group.
  • Handle: RePEc:boc:scon21:24
    as

    Download full text from publisher

    File URL: http://fmwww.bc.edu/repec/scon2021/US21_Lambert.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:scon21:24. 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.