rcfmc: Simulate a continuous time finite state space Markov chain

Description Usage Arguments Value See Also Examples

View source: R/rcfmc.R

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

1
rcfmc(n,Q,pi0)

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.

Value

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

See Also

rfmc, stepfun

Examples

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

smfsb documentation built on Aug. 30, 2018, 5:04 p.m.