sim_markov_bridge: Simulate Markov chain bridge.

Description Usage Arguments Details Value See Also Examples

Description

sim_markov_bridge returns a simulated realisation of a Markov chain between two known values and times.

Usage

1
sim_markov_bridge(num_states, fixed_values, behav_params)

Arguments

num_states

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

fixed_values

List with components:

inc_times

Vector of length two, start and end times of the simulation.

inc_behavs

Vector of length two, start and end known values (behaviours) of the simulation.

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.

Details

Simulation is by rejection. Markov chain simulated forwards in time from the starting point, and then compared with the known end point. If the end point is correct, the simulation is accepted, otherwise it is rejected.

Value

List with the components:

accept

Binary element that the rejection simulation has been accepted/rejected. If rejected, this is the only return value.

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

Other Markov chain simulations: calc_markov_steady_state, sim_markov_backward, sim_markov_forward

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
end_points <- list(inc_times = c(0,10),
                   inc_behavs = c(1,3))
param <- list(lambda = c(0.1,0.2,0.3),
              q = matrix(c(NA,0.5,0.3,0.35,NA,0.7,0.65,0.5,NA),nrow=3))

set.seed(123) # simulation does not meet correct end point and is rejected
sim_markov_bridge(3, end_points, param)
# $accept
# [1] FALSE

set.seed(2712) # simultion is accepted
sim_markov_bridge(3, end_points, param)
# $accept
# [1] TRUE
#
# $times
# [1]  0.000000  5.694254  6.831134  7.503054 10.000000
#
# $states
# [1] 1 3 1 3 3

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