Description Usage Arguments Details Value Author(s) See Also Examples

Simulates a first-order Markov chain.

1 | ```
simulateMarkovChain(n, trans.mat, init.dist=NULL, states=colnames(trans.mat))
``` |

`n` |
the length of the sample path to simulate. |

`trans.mat` |
The transition matrix of the Markov chain to simulate. |

`init.dist` |
The initial distribution to use for starting the simulation. If it is not specified, the stationary distribution of the Markov chain will be computed from trans.mat and used to start the simulation in the steady state. |

`states` |
This argument can be used to override the labels on the transition matrix (if any) and name the states output on the sample path. |

trans.mat must be a stochastic matrix. It must either have both row and
column names, in which case they must agree, or no row and column names at all.
The row/column names will be used to label the states visited by the Markov
chain in the sample path simulated. If states is specified, it will be
used to label the states of the Markov chain instead of the row/column names of
trans.mat, in which the length of states must agree with the
dimension of trans.mat. If trans.mat has no row/column names and
states is not specified, then the states of the Markov chain will be
labelled *1,…,n*, where *n* is the dimension of trans.mat.

A vector of length n containing a realisation of the specified Markov chain.

Andrew Hart and Servet Mart<ed>nez

`estimateMarkovChain`

, `rstochmat`

, `rcspr2mat`

1 2 | ```
simulateMarkovChain(50, matrix(c(.8, .2, .2, .8), ncol=2))
simulateMarkovChain(50, rstochmat(3), states=c("yes", "no", "maybe"))
``` |

spgs documentation built on July 21, 2017, 9:02 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.