seqecreate {TraMineR} | R Documentation |
Create an event sequence object from the given input.
seqecreate(data = NULL, id = NULL, timestamp = NULL, event = NULL, endEvent = NULL, tevent = "transition", use.labels=TRUE)
data |
A state sequence object (see seqdef ) or a data frame |
id |
Concerned sequence id's (integer), that is the 'id' column of the TSE format (ignored if data argument is provided). |
timestamp |
Time (double) at which events occur, that is the 'timestamp' column of the TSE format (ignored if data argument is provided). |
event |
Events that occurred at the specified time stamps, that is the 'event' column of the TSE format (ignored if data argument is provided). |
endEvent |
If specified this event will be considered as a flag for the end of observation time (total length of event sequences). |
tevent |
If data is a state sequence object either a transition matrix or a method to generate it (see seqetm ) |
use.labels |
If TRUE, transitions names are built from state labels rather than from the sequence alphabet. |
There are several ways to create an event sequence object. The first one is by providing the events in TSE format (see seqformat
), i.e. by providing three paired lists: id, timestamp and event, such that each triplet (id, timestamp, event) defines the event that occurs at time timestamp for case id. Several events at the same time for a same id are allowed. The lists can be provided with the arguments id
, timestamp
and event
. An alternative is by providing a data frame as data
argument in which case the function takes the required information from the "id", "timestamp" and "event" columns of that data frame.
The other way is to pass a state sequence object (as data
argument) and to perfom an automatic state-to-event conversion. The simplest way to make a conversion is by means of a predefined method (see seqetm
), such as "transition" (one distinct event per possible transition), "state" (one event when entering a new state) and "period" (a pair of events, one start-state event and one end-state event for each found transition). For a more customized conversion, you can specify a transition matrix in the same way as in seqformat
. Function seqetm
can help you in creating your transition matrix.
The resulting event sequence object can then be used in other 'seqe' methods, such as seqefsub
or seqeapplysub
.
seqformat
for converting between sequence formats,
seqefsub
for searching frequent subsequences,
seqecmpgroup
to search for discriminant subsequences,
seqeapplysub
for counting subsequence occurrences and more,
seqelength
about length (observation time) of event sequences,
seqdef
to create a state sequence object.
##Starting with states sequences ##Loading data data(biofam) ## Creating state sequences biofam.seq <- seqdef(biofam,10:25,informat='STS') ## Creating event sequences from biofam biofam.seqe <- seqecreate(biofam.seq) ## Loading data data(actcal.tse) ## Creating sequences actcal.seqe <- seqecreate(id=actcal.tse$id, timestamp=actcal.tse$time, event=actcal.tse$event) ##printing sequences actcal.seqe[1:10] ## Using the data argument actcal.seqe <- seqecreate(data=actcal.tse)