IDEAS home Printed from
   My bibliography  Save this paper

Using Stata for sequence analysis


  • Brendan Halpin

    (University of Limerick)


Sequence analysis (SA) is a very different way of looking at categorical longitudinal data, such as life-course or labor-market histories (or any ordered categorical data, for that matter). Instead of focusing on transition rates (for example, via hazard rate, Markov or panel models), it takes individual time series and compares them as wholes. It has significant advantages at a descriptive and exploratory level and can help detect patterns that conventional methods will overlook. As availability of longitudinal data increases, this becomes a significant advantage. SA hinges on defining measures of similarity between sequences, typically to generate data-driven classifications, for example, by cluster analysis. Most SA uses the optimal matching distance, but other measures are in use. There is some controversy about the applicability of SA algorithms to social science data and about their parameterization. Comparison of different methods and parameterizations helps clarify the issues. For a long time, TDA was the only package social scientists had access to for SA, but in recent years, both Stata and R have had relevant functionality, in Stata's case provided by the sq and sadi packages. In this talk, I will discuss the current state of the sadi package. sadi differs from sq in being based on a plugin; therefore, it is significantly faster: many of the distance measures are computationally intensive, and typically, N(N-1)/2 comparisons will be made for N observations. sadi also provides additional distance measures, including dynamic Hamming, time-warp edit distance, and a version of Elzinga's number of matching subsequences measure. It includes tools for inspecting and graphing sequence data and for comparing distance measures and the resulting cluster analyses. I will also briefly discuss the advantages and disadvantages of using plugins rather than Mata and make some remarks about cross-compiling plugins under Linux.

Suggested Citation

  • Brendan Halpin, 2014. "Using Stata for sequence analysis," United Kingdom Stata Users' Group Meetings 2014 02, Stata Users Group.
  • Handle: RePEc:boc:usug14:02

    Download full text from publisher

    File URL:
    File Function: presentation materials
    Download Restriction: no

    More about this item


    Access and download statistics


    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:usug14:02. 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: .

    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.