Search code examples
rtraminer

How to create a state sequence from an event sequence in TraMineR?


I've created a state sequence using the code:

comp.seq <- seqdef(comp,NULL,states=comp.scodes,labels=comp.labels, alphabet=comp.alphabet,right="Z",left="Z")

then i created a event sequence from that using:

comp.seqe<-seqecreate(comp.seq,tevent="state", use.labels=FALSE)

Then I searched for subsequences using:

subs <- seqefsub(comp.seqe,strsubseq=c("(A)-(C)-(A)"))

Now all I wanna do is create some plots of the resulting sequences. But I found out that there are no plotting functions like seqplot for event sequences, thus I'd like to convert the resulting event sequences into state sequences. Is it possible ? I've tried seqdef() with the subs object but wasn't successful. Is it the appropriate function?

Thanks


Solution

  • Look at this answer for how to convert event sequences in time stamped event (TSE) format to state sequences. And here you will find a solution for putting the outcome of seqefsub into TSE form.

    Note that plots for state sequences may not be suited for rendering the outcome of seqefsub. The returned subsequences have no time stamp, which will result in an state alignment without sound meaning. Why not simply using plot(subs), or the seqpcplot function if you are interested in the order of the events. seqpcplot accepts directly event sequences objects as input, and the outcome of seqefsub is such an object.