Search for specific patterns in sequences

I use the TraMineR R-package to analyze academic research sequence.

I want to find a template that is defined as someone located in the target company, then exiting, then returning to the target company.

(simplified) I define state A as the target company; B as an external industrial company; and C as an internal industrial company.

So, I want to find sequences with specific ABA or ACA patterns.

Looking at this question ( Strange number of subsequences? ) And reading the user manual, especially the following snippets:

4.3.3 Subsequences A sequence u is a subsequence of x if all successive elements ui of u appear in x in the same order, which we simply denote by them. According to this definition, undivided states> may appear between the common for both sequences u and x. For example, u = S; M is a subsequence x = S; U; M; MC.

and

7.3.2 seqpm() , , . . , MTab, . , , . , MIndex, , . ( ). , rst seqconc TRUE.

, seqpm() - , .

, : --------------

, , ​​, :

seqpm(sequence,"ABA")

. ,

seqpm(sequence,"ABBBBBA")

, .

  • , , , - ?
  • , A B Back to A?
  • A , A?

!

+4
1

seqpm: " ", , . , ( ). , .

, , , seqecreate, seqefsub seqeapplysub. actcal, TraMineR.

library(TraMineR)
data(actcal)
actcal.seq <- seqdef(actcal[,13:24])

## displaying the first state sequences
head(actcal.seq)

## transforming into event sequences
actcal.seqe <- seqecreate(actcal.seq, tevent = "state", use.labels=FALSE)

## displaying the first event sequences
head(actcal.seqe)

## now searching for the subsequences
subs <- seqefsub(actcal.seqe, strsubseq=c("(A)-(D)","(D)-(B)"))
## and identifying the sequences that contain the subsequences
subs.pres <- seqeapplysub(subs, method="presence")
head(subs.pres)

## we can now, for example, count the sequences that contain (A)-(D)
sum(subs.pres[,1])
## or list the sequences that contain (A)-(D)
rownames(subs.pres)[subs.pres[,1]==1]

, .

+2

All Articles