seqtrate: Compute transition rates between states

View source: R/seqtrate.R

seqtrateR Documentation

Compute transition rates between states

Description

Returns a matrix with transition rates between states, computed from a set of sequences.

Usage

seqtrate(seqdata, sel.states = NULL, time.varying = FALSE, weighted = TRUE,
  lag = 1, with.missing = FALSE, count = FALSE, statl)

Arguments

seqdata

a sequence object as defined by the seqdef function.

sel.states

a list of states or events for which the transition rates will be computed. If omitted (default), transition rates are computed between the distinct states in seqdata (obtained with the alphabet function).

time.varying

Logical. If TRUE, return an array containing a distinct matrix for each time unit. The time is the third dimension (subscript).

weighted

Logical. If TRUE, compute transition rates using weights specified in seqdata.

lag

Integer. Time between the two states considered to compute transition rates (one by default).

with.missing

Logical. If FALSE (default value), returned transition rates ignore missing values.

count

Logical. Should counts of transition be returned instead of transition probabilities. Default is FALSE.

statl

Deprecated. Use sel.states instead.

Details

Transition rates are the probabilities of transition from one state to another observed in the sequence data. Substitution costs based on transition rates can be used when computing distances between sequences with the optimal matching method (see seqdist).

Value

a matrix of dimension ns*ns, where ns is the number of states in the alphabet of the sequence object.

Author(s)

Matthias Studer, Alexis Gabadinho, and Gilbert Ritschard

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

seqdist seqsubm alphabet.

Examples

  ## Loading the 'actcal' example data set
  data(actcal)

  ## Defining a sequence object with data in columns 13 to 24
  ## (activity status from January to December 2000)
  actcal.seq <- seqdef(actcal[,13:24])

  ## Computing transition rates
  seqtrate(actcal.seq)

  ## Computing transition rates between states "A" and "B" only
  seqtrate(actcal.seq, c("A","B"))

## ====================
## Example with weights
## ====================
data(ex1)
ex1.seq <- seqdef(ex1[,1:13], weights=ex1$weights)

seqtrate(ex1.seq, weighted=FALSE)
seqtrate(ex1.seq, weighted=FALSE, count=TRUE)

## weights are accounted for by default
seqtrate(ex1.seq)
seqtrate(ex1.seq, count=TRUE)


TraMineR documentation built on May 29, 2024, 5 a.m.