calc_reverse_markov_gen: Calculate the generator matrix of a Markov chain in reverse...

Description Usage Arguments Value See Also Examples

Description

calc_reverse_markov_gen returns the generator matrix of the Markov chain which is the time-reversed process of a given Markov chain.

Usage

1
calc_reverse_markov_gen(num_states, behav_params)

Arguments

num_states

Numeric, number of (behavioural) states in the Markov chain.

behav_params

List with components:

lambda

Vector of length num_states, switching rates out of each state.

q

Sqaure matrix size num_states, probability of switching from (row) each state to (column) another. Diagonal elements are NA.

Value

List with the components:

times

Vector, switching times of the simulation. Includes the fixed end points.

states

Vector, states at switching times of the simulation. Includes the fixed end points.

See Also

calc_markov_steady_state for calculating a Markov steady state/equilibrium distribution and sim_markov_backward for simulating from this reverse-time process.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# In a two state process, the reverse chain is equal to the forward chain
num_states <- 2
behav_params <- list(lambda = c(0.1,0.2),
                     q = matrix(c(NA,1,1,NA), nrow = 2))

calc_reverse_markov_gen(num_states, behav_params)
# $lambda
# [1] 0.1 0.2
# 
# $q
# [,1] [,2]
# [1,]   NA    1
# [2,]    1   NA


num_states <- 3
behav_params <- list(lambda = c(0.1,0.2,0.3),
                     q = matrix(c(NA,0.15/0.2,0.05/0.3,0.05/0.1,NA,0.25/0.3,0.05/0.1,0.05/0.2,NA),nrow=3))

calc_reverse_markov_gen(num_states, behav_params)
# $lambda
# [1] 0.1 0.2 0.3
# 
# $q
# [,1]      [,2]      [,3]
# [1,]        NA 0.8684211 0.1315789
# [2,] 0.4318182        NA 0.5681818
# [3,] 0.6333333 0.3666667        NA

a-parton/CTStepTurn documentation built on May 14, 2019, 4:17 p.m.