Learn R Programming

ctmcmove (version 1.2.10)

ctmc.sim: Code to simulate a continuous-time Markov chain.

Description

Simulates a CTMC with given rate matrix (Q) for a time (T), or until it reaches a final absorbing state.

Usage

ctmc.sim(Q,start.state=1,T=1,final.state=NA)

Value

ec

A vector of the sequential grid cells (the embedded chain) in the CTMC movement path

rt

A vector of residence times in each sequential grid cell in the CTMC movement path

Arguments

Q

A square matrix. Either a rate matrix or the infinitessimal generator of the CTMC.

start.state

An integer - the starting state for the simulation.

T

A numeric value greater than zero. The time window for simulating the CTMC will be [0,T].

final.state

Either NA or an integer. If an integer, the chain will be simulated until it enters the "final.state", at which time the simulation will be terminated.

Author

Ephraim M. Hanks

Details

This code uses the Gillespie algorithm to simulate a CTMC path in continuous time.

References

None

Examples

Run this code
## For example code, do
##
## > help(ctmcMove)

Run the code above in your browser using DataLab