Is there any way of getting a matrix with the count of transitions between states?. Something similar to the "seqtrate()" but containing the number of transitions instead of just the transitions rate?

Thank you.


1 Answer 1


TraMineRhas no such function. However you can easily get a matrix of the count of transitions from the matrix TRATE of the transition probabilities by premultiplying this matrix by the vector of the total number of occurrences of the states in the L-1 first positions.

I illustrate using the the first 10 sequences of the actcal data set that ships with TraMineR.

## The sequence data are in columns 13 to 24
actcal.seq <- seqdef(actcal[,13:24])
s <- actcal.seq[1:10,]

## dropping last position in the sequences
s1 <- seqdef(s[,1:ncol(s)-1], alphabet=alphabet(s))
n1 <- colSums(seqistatd(s1)) # number of occurrence of each state

## and now the matrix of transition counts

This works for sequences of equal length. You will have to adapt the code if your sequences have different lengths because the last valid state in each sequence would not all be in the same column.

Hope this helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.