# Methods for Sequence Analysis

Sequence types

There are two kinds of sequences that can be anlyzed, state sequences and event sequences. State sequences describe the succession of states. In a social sciences setting such sequences could be the marital state of individuals, such as single, married or divorced. In a disease treatment study states could be pre-diagnosed, diagnosed, hospitalized, in rehab, in remission or cured. State sequences therefore consist of stretches of times during which an entity is in a particular state. Event sequences associate an event with a speciﬁc time point. In a business context an event sequence could consist of news events such as the appointment of new CEO, release of ﬁnancial ﬁgures, announcement of a new marketing campaign or a product launch. A state sequence can also give rise to an event sequence by considering the transitions from one state to another as an event.

Illustration of data structure

Consider a distance learning institution where students complete a prescribed number of courses at their own pace. At regular intervals, say monthly, the institution keeps track of the number of courses each student has passed. Suppose also that the students have to ﬁnish all the courses in a speciﬁed length of time. The states in which a student could be are the number of courses already passed by him. The state sequence for a student therefore starts with a number of zeros until he passes the ﬁrst module. Then there are 1’s, followed by 2’s and so forth. To be speciﬁc, let N be the time in which the students must complete the course, hence the sequence length. Let U be the number of courses to pass, hence the number passed at some point ranges from 0 to U. Suppose U =5. We then label the states as F, E, D, C, B and A corresponding to having passed 0,1,...,5 courses, respectively. Suppose there are M students or sequences.

I generated such sequences by randomly picking U =5 values from the time points 1,...,N, where N = 20, and sorting them. This gave the time points at which a student’s state changes from a lower level to one level higher. The ﬁrst few sequences are:
## V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20

## 1 F E E D D D D D D D D D C B B B A A A A

## 2 F F E D D D C C C B A A A A A A A A A A

## 3 F E E D D D D D D D D D D C C B B B B A

## 4 F E E E E E E D D C C C C C C B B A A A

## 5 F E E E E D D D D C C C B B B B B B B A

## 6 F F F F F E E E E E E D C C C C C B B A

Vizualization

Several kinds of plots can be produced to gain a visual impression of the data. Figure 1 shows two index plots, the ﬁrst one simply the ﬁrst 10 sequences and the second one with all the sequences but sorted by some criterion, here the average completion time for the courses of a sequence. The third plot is the state distribution plot, which gives the frequency of the states in the sequences at the various times. Figure 2 contains a plot of frequencies of modal states, mean time in each state and the transversal entropies.

------ Fig 1 & 2 here -------

Analyzing sequences with dissimilarities

There are several ways of measuring distance or dissimilarity between sequences. These use a distance matrix, computed by optimal matching of pairs of sequences. A portion of such a distance matrix is shown below.

------ Fig 3 here -------

Sequences of news: Specifics of studying corporate action sequences
{"ft_lang_label":"__label__en","ft_lang_prob":0.92913324,"math_prob":0.96553504,"size":3401,"snap":"2023-40-2023-50","text_gpt3_token_len":843,"char_repetition_ratio":0.16573447,"word_repetition_ratio":0.11492537,"special_character_ratio":0.2481623,"punctuation_ratio":0.092391305,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.98314923,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-30T03:36:00Z\",\"WARC-Record-ID\":\"<urn:uuid:3d5dc0de-e343-4a09-889f-033ebaafface>\",\"Content-Length\":\"63215\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:cd6da49e-d610-4e2e-8eeb-114207d4b0fd>\",\"WARC-Concurrent-To\":\"<urn:uuid:8feb58c1-3d0b-4c88-bbf8-62ba22cd190d>\",\"WARC-IP-Address\":\"157.90.150.134\",\"WARC-Target-URI\":\"https://www.eventstudytools.com/sequence-analysis\",\"WARC-Payload-Digest\":\"sha1:6XPDPQKHIJEIPPXDFNOQTK5VEHRZSM6R\",\"WARC-Block-Digest\":\"sha1:6AVDVRDVTULXR3X4MFWXBPQCSIUKDJAY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510575.93_warc_CC-MAIN-20230930014147-20230930044147-00817.warc.gz\"}"}