transition: Access Transition Probabilities/Counts in an EMM

transitionR Documentation

Access Transition Probabilities/Counts in an EMM

Description

Calculates individual transition probabilities/counts or a complete transition matrix for an EMM (which contains "TRACDS").

Usage

## S4 method for signature 'TRACDS,character,character'
transition(x, from, to, 
          type = c("probability", "counts", "log_odds"), prior = TRUE)
## S4 method for signature 'TRACDS'
transition_matrix(x, 
          type = c("probability", "counts", "log_odds"), prior = TRUE)
## S4 method for signature 'TRACDS'
initial_transition(x, 
          type = c("probability", "counts", "log_odds"), prior = TRUE)

Arguments

x

an object of class "EMM"/"TRACDS".

from, to

Names a states. If to is missing, from has to contain a matrix with two columns (a from column and a to column as returned by transitions).

type

What should be calculated?

prior

add one to each transition count. This is equal to starting with a uniform prior for the transition count distribution, i.e., initially all transitions are equally likely.

Details

Log odds are calculated as ln(a/(1/n)) where a is the probability of the transition and n is the number of states in the EMM. 1/n is the probability of a transition under the null model which assumes that the transition probability from each state to each other state (including staying in the same state) is the same, i.e., the null model has a transition matrix with all entries equal to 1/n.

Value

A scalar (for transition), a square matrix (for transition_matrix) or a vector (for initial_transition).

See Also

EMM which contains TRACDS

Examples

data("EMMTraffic")
emm <- EMM(measure="eJaccard", threshold=0.2)
emm <- build(emm, EMMTraffic)

## get transition matrix
transition_matrix(emm, type="count", prior=FALSE)
transition_matrix(emm, type="count")
transition_matrix(emm, prior=FALSE)
transition_matrix(emm)

## get initial state probabilities
initial_transition(emm)

## access individual transition probability (state 1 -> 2)
transition(emm, "1","2")

## get counts for all existing transitions
tr <- transitions(emm)
tr
cbind(as.data.frame(tr), counts=transition(emm, tr, type="counts"))

rEMM documentation built on June 26, 2022, 1:06 a.m.