sim_path {AalenJohansen} | R Documentation |
Simulate the path of a time-inhomogeneous (semi-)Markov process until a maximal time
Description
Simulate the path of a time-inhomogeneous (semi-)Markov process until a maximal time
Usage
sim_path(i, rates, dists, t = 0, u = 0, tn = Inf, abs = numeric(0), bs = NA)
Arguments
i |
The initial state, integer. |
rates |
The total transition rates out of states, a function with arguments state (integer), time (numeric), and duration (numeric) returning a rate (numeric). |
dists |
The distribution of marks, a function with arguments state (integer), time (numeric), and duration (numeric) returning a probability vector. |
t |
The initial time, numeric. |
u |
The initial duration (since the last transition), numeric. By default equal to zero |
tn |
The maximal time, numeric. By default equal to inifinity |
abs |
Vector indicating which states are absorbing. By default the last state is absorbing. |
bs |
Vector of upper bounds on the total transition rates. By default the bounds are determined using optimize, which might only identify a local maximum. |
Value
A list concerning jump times and states, with the first time being the initial time t and state and the last time being tn (if not absorbed)
Examples
jump_rate <- function(i, t, u){if(i == 1){3*t} else if(i == 2){5*t} else{0}}
mark_dist <- function(i, s, v){if(i == 1){c(0, 1/3, 2/3)} else if(i == 2){c(1/5, 0, 4/5)} else{0}}
sim <- sim_path(sample(1:2, 1), t = 0, tn = 2, rates = jump_rate, dists = mark_dist)
sim