Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

seqtransn

Number of transitions in a sequence


Description

Computes the number of transitions (state changes) in each sequence of a sequence object.

Usage

seqtransn(seqdata, with.missing=FALSE, norm=FALSE, pweight=FALSE)

Arguments

seqdata

a state sequence object as defined by the seqdef function.

with.missing

logical: should non-void missing values be treated as a regular state? If FALSE (default) missing values are ignored.

norm

logical. If set as TRUE, the number of transitions is divided by its theoretical maximum, the length of the sequence minus 1. When the length of the sequence is 1, the normalized value is set as 0 (non-normalized value).

pweight

logical. EXPERIMENTAL! If set as TRUE, when counting transitions each transition does not account for 1 but for its probability (transition rate) as observed in the data.

Details

A transition in a sequence is a state change between time/position t and t+1. For example, the sequence "A-A-A-A-B-B-A-D-D-D" contains 3 transitions. The maximum number of transitions a sequence can contain is l-1 where l is the length of the sequence. The number of transitions is obtained by subtracting 1 to the length of the the Distinct Successive State (DSS) sequence.

Value

a state sequence object containing the number of transitions of each sequence in the object given as argument.

Author(s)

Alexis Gabadinho (with Gilbert Ritschard for the help page)

References

Gabadinho, A., G. Ritschard, N. S. Müller and M. Studer (2011). Analyzing and Visualizing State Sequences in R with TraMineR. Journal of Statistical Software 40(4), 1-37.

See Also

Examples

## Creating a sequence object from columns 13 to 24
## in the 'actcal' example data set
data(actcal)
actcal.seq <- seqdef(actcal,13:24)

## Computing the number of transitions
actcal.trans <- seqtransn(actcal.seq)

## Displaying the DSS for the first 10 sequences
actcal.trans[1:10]

## Example with with.missing argument
data(ex1)
ex1.seq <- seqdef(ex1, 1:13)

seqtransn(ex1.seq)
seqtransn(ex1.seq, with.missing=TRUE)

TraMineR

Trajectory Miner: a Toolbox for Exploring and Rendering Sequences

v2.2-1
GPL (>= 2)
Authors
Alexis Gabadinho [aut, cph], Matthias Studer [aut, cph] (<https://orcid.org/0000-0002-6269-1412>), Nicolas M"{u}ller [aut], Reto B"{u}rgin [aut], Pierre-Alexandre Fonta [aut], Gilbert Ritschard [aut, cre, cph] (<https://orcid.org/0000-0001-7776-0903>)
Initial release
2020-10-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.