transitions | R Documentation |
Transitions between elements of a sequence
transitions(S, strucmat = NULL, xstart = TRUE, xstop = FALSE, out = "ml")
S |
character, the sequence |
strucmat |
an optional matrix with column and row names (see details and examples) |
xstart |
logical, should start state be included |
xstop |
logical, should end state be included |
out |
character: either |
usage of strucmat
might be helpful for at least tow reasons:
1) if there are constraints on the possible transitions. For example, a start cannot be followed by a stop (that wouldn't be a sequence). Such impossible transitions are indicated by 0 in this matrix.
2) if sequences are analysed that not all contain the same/complete set of elements. This might be useful if you want to generate matching outputs even though the actual observed sequences (and hence the result of the function) might differ (e.g. in the case of letter transitions in words)
Alger, S. J., Larget, B. R., & Riters, L. V. (2016). A novel statistical method for behaviour sequence analysis and its application to birdsong. Animal behaviour, 116, 181-193.
transitions("AAAAABBC", out="ml") transitions("AAAAABBC", out="bayes") smat <- matrix(1, ncol=3, nrow=4); colnames(smat) <- c("A", "B", "C"); rownames(smat) <- c("start", "A", "B", "C") transitions("AAAAABBC", out="ml", strucmat = smat) transitions("AAAAABBC", out="bayes", strucmat = smat) # errors: # transitions("AAAAABBC", out="ml", strucmat = smat, xstop = TRUE) # transitions("AAAAABBC", out="bayes", strucmat = smat, xstop = TRUE) # add a stop column, but constrain that starts cannot be followed by stops smat <- cbind(smat, 1); colnames(smat)[4] <- "stop"; smat[1, 4] <- 0 transitions("AAAAABBC", out="ml", strucmat = smat, xstop = TRUE) transitions("AAAAABBC", out="bayes", strucmat = smat, xstop = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.