Use of State Sequence Analysis in Pharmacoepidemiology: A Tutorial

Int J Environ Res Public Health. 2021 Dec 20;18(24):13398. doi: 10.3390/ijerph182413398.


While state sequence analysis (SSA) has been long used in social sciences, its use in pharmacoepidemiology is still in its infancy. Indeed, this technique is relatively easy to use, and its intrinsic visual nature may help investigators to untangle the latent information within prescription data, facilitating the individuation of specific patterns and possible inappropriate use of medications. In this paper, we provide an educational primer of the most important learning concepts and methods of SSA, including measurement of dissimilarities between sequences, the application of clustering methods to identify sequence patterns, the use of complexity measures for sequence patterns, the graphical visualization of sequences, and the use of SSA in predictive models. As a worked example, we present an application of SSA to opioid prescription patterns in patients with non-cancer pain, using real-world data from Italy. We show how SSA allows the identification of patterns in prescriptions in these data that might not be evident using standard statistical approaches and how these patterns are associated with future discontinuation of opioid therapy.

Keywords: data-mining; pharmacoepidemiology; state-sequence analysis.

Publication types

  • Research Support, Non-U.S. Gov't

MeSH terms

  • Analgesics, Opioid*
  • Cluster Analysis
  • Humans
  • Pharmacoepidemiology*
  • Practice Patterns, Physicians'
  • Prescriptions
  • Sequence Analysis


  • Analgesics, Opioid