[Traminer-users] state subsequences and event subsequences

Matthias Studer Matthias.Studer at unige.ch
Fri Mar 18 11:54:09 CET 2011


Dear Claire,

You can do that by transforming a state sequence to a event sequence 
object and then run seqefsub. There are two ways to do it:

First, generating only one event for each state (like a DSS)

library(TraMineR)
data(mvad)
mvad.labels <- c("employment", "further education", "higher education",
     "joblessness", "school", "training")
mvad.scodes <- c("EM", "FE", "HE", "JL", "SC", "TR")
mvad.seq <- seqdef(mvad, 15:86, states = mvad.scodes, labels = mvad.labels)

## This will create an event sequence, each event being entering a given 
state
seqeDSS <- seqecreate(mvad.seq, tevent="state")
## Print the first event sequence
print(seqeDSS[1])
seqefsub(seqeDSS, pMinSupport=0.01)


Second, repeating each state according to the length of each episode

## Utility to function to create an event sequence with repeated states

RepeatedState2Event <- function(seqdata){
     tse <- data.frame(id=rep(1:nrow(seqdata), ncol(seqdata)), 
event=unlist(seqdata), timestamp =sort(rep(0:(ncol(seqdata)-1), 
nrow(seqdata))))
     tse <- tse[order(tse$id, tse$timestamp, tse$event), ]
     return(seqecreate(tse))
}


mvseqe <- RepeatedState2Event(mvad.seq)
print(mvseqe[1])
## This takes some time to compute see below
seqefsub(mvseqe, pMinSupport=0.2, maxK=4)

The algorithm used by TraMineR is not designed to handle a lot of events 
per sequence. As such, you will have to specify a maximum length for the 
subsequence to search (with parameter maxK). Otherwise the number of 
possible subsequences is getting too big.

I recommend you to use the first approach.

Hope this helps.
Matthias Studer




Le 17.03.2011 12:45, Claire Lemercier a écrit :
> Dear list members,
> I have a question about the possibility to perform something like what 
> seqefsub does (listing frequent subsequences), but for subsequences of 
> states (those defined at page 83 of the manual), not subsequences of 
> events.
> e.g. I am looking for a list of the most frequent subsequences of 
> states, like "Being Married""Being Divorced" (possibly with other 
> states in between, as it is a subsequence) and not "Getting 
> Married""Getting Divorced" (subsequence of events)
> Does my question make sense, and is it possible to do this with TraMineR?
> All the best,
> Claire.
>
> _______________________________________________
> Traminer-users mailing list
> Traminer-users at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/traminer-users 
>



More information about the Traminer-users mailing list