Using the sample data from TraMineR::seqetm
data(actcal) actcal.seq <- seqdef(actcal,13:24, labels=c("FullTime", "PartTime", "LowPartTime", "NoWork"))
Your example looks like the output of print.stslist , which uses seqconc to create sequences
so i will create this sequence manaully
actcal.seqconc <- seqconc(actcal.seq)
This is the matrix. Therefore, we can simply apply this function to divide by - and then recombine with the transition states as you want. Below is the function:
transitions <- function(x, start = 'S') { x <- unlist(strsplit(x, '-') paste0(c(start, head(x, -1)), x, collapse = '-') } actcal.tseq <- as.matrix(apply( actcal.seqconc, 1, transitions))
If you want state transition rates to use seqtrate
seqtrate(actcal.seq) [>] computing transition rates for states A/B/C/D ... [-> A] [-> B] [-> C] [-> D] [A ->] 0.986991870 0.005203252 0.001084011 0.006720867 [B ->] 0.009700665 0.970343681 0.007760532 0.012195122 [C ->] 0.005555556 0.014814815 0.934259259 0.045370370 [D ->] 0.008705580 0.006279435 0.014985015 0.970029970
source share