seqe2stm | R Documentation |
This function creates a matrix specifying for each state (given in row) to which state we fall when the event given in column happens.
seqe2stm(events, dropMatrix = NULL, dropList = NULL, firstState = "None")
events |
Character. The vector of all possible events. |
dropMatrix |
Logical matrix. Specifying the events to forget once a given event has occurred. |
dropList |
List. Same as |
firstState |
Character. Name of the first state, before any event has occurred. |
This function creates a matrix with in each cell the new state which results when the column event (column name) occurs while we are in the corresponding row state (row name). Such a matrix is required by TSE_to_STS
.
By default, a new state is created for each combination of events that already has occurred.
dropMatrix
and dropList
allow to specify which events should be "forgotten" once a given event has occurred.
For instance, we may want to forget the "marriage" event once the event "divorce" has occurred.
dropMatrix
specifies for each event given in row, the previous events, given in column that should be forgotten.
dropList
uses a list to specify the same thing. The form is list(event1=c(..., events to forget), event2=c(..., events to forget)).
See example below.
A matrix.
This function is a pre-release and further testing is still needed, please report any problems.
Matthias Studer
Ritschard, G., Gabadinho, A., Studer, M. & Müller, N.S. (2009), "Converting between various sequence representations", In Ras, Z. & Dardzinska, A. (eds) Advances in Data Management. Series: Studies in Computational Intelligence. Volume 223, pp. 155-175. Berlin: Springer.
TSE_to_STS
## Achieving same result using dropMatrix or dropList.
## List of possible events.
events <- c("marr", "child", "div")
dm <- matrix(FALSE, 3,3, dimnames=list(events, events))
dm[3, ] <- c(TRUE, TRUE, FALSE)
dm[1, 3] <- TRUE
## Using the matrix, we forget "marriage" and "child" events when "divorce" occurs.
## We also forget "divorce" after "marriage" occurs.
print(dm)
stm <- seqe2stm(events, dropMatrix=dm)
## Get same result with the dropList argument.
stmList <- seqe2stm(events, dropList=list("div"=c("marr", "child"), "marr"="div"))
## test that the results are the same
all.equal(stm, stmList)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.