Learn R Programming

LaMa (version 1.0.0)

tpm_cont: Calculation of continuous time transition probabilities

Description

A continuous-time Markov chain is described by an infinitesimal generator matrix \(Q\). When observing data at time points \(t_1, \dots, t_n\) the transition probabilites between \(t_i\) and \(t_{i+1}\) are caluclated as

\(\Gamma(\Delta t_i) = \exp(Q \Delta t_i)\),

where \(\exp()\) is the matrix exponential. The mapping \(\Gamma(\Delta t)\) is also called the Markov semigroup. This function calculates all transition matrices based on a given generator and time differences.

Usage

tpm_cont(Q, timediff)

Value

An array of transition matrices of dimension c(N,N,n-1)

Arguments

Q

Infinitesimal generator matrix of the continuous-time Markov chain of dimension c(N,N)

timediff

Time differences between observations of length n-1 when based on n observations

Examples

Run this code
# building a Q matrix for a 3-state cont.-time Markov chain
Q = diag(3)
Q[!Q] = rexp(6)
diag(Q) = 0
diag(Q) = - rowSums(Q)

# draw time differences
timediff = rexp(1000, 10)

Gamma = tpm_cont(Q, timediff)

Run the code above in your browser using DataLab