Learn R Programming

smfsb (version 1.5)

rcfmc: Simulate a continuous time finite state space Markov chain

Description

This function simulates a single realisation from a continuous time Markov chain having a finite state space based on a given transition rate matrix.

Usage

rcfmc(n,Q,pi0)

Value

An R stepfun object containing the sampled path of the process.

Arguments

n

The number of states to be sampled from the Markov chain, including the initial state, which will be sampled using pi0.

Q

The transition rate matrix of the Markov chain, where each off-diagonal element Q[i,j] represents the rate of transition from state i to state j. This matrix is assumed to be square, having rows summing to zero.

pi0

A vector representing the probability distribution of the initial state of the Markov chain. If this vector is of length r, then the transition matrix P is assumed to be r x r. The elements of this vector are assumed to be non-negative and sum to one, though in fact, they will be normalised by the sampling procedure.

See Also

rfmc, stepfun

Examples

Run this code
plot(rcfmc(20,matrix(c(-0.5,0.5,1,-1),ncol=2,byrow=TRUE),c(1,0)))

Run the code above in your browser using DataLab