rEMM (version 1.0-11)

transition: 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 TRACDS,character,character
transition(x, from, to, 
          type = c("probability", "counts", "log_odds"), prior = TRUE)
# S4 method for TRACDS
transition_matrix(x, 
          type = c("probability", "counts", "log_odds"), prior = TRUE)
# S4 method for 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.

Value

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

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\).

See Also

'>EMM which contains '>TRACDS

Examples

Run this code
# NOT RUN {
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"))
# }

Run the code above in your browser using DataCamp Workspace