rmarkov {MCMCprecision} | R Documentation |
Generate a sample of a discrete-state Markov chain
Description
Generates a sequence of discrete states from a discrete-time Markov chain with transition matrix P
.
Usage
rmarkov(n, P, start = rep(1, ncol(P)))
Arguments
n |
length of the generated sequence. |
P |
transition matrix (rows are normalized to sum to 1). |
start |
vector with nonnegative values that defines the discrete starting
distribution at t=0 ( |
Examples
P <- matrix(c(.30, .50, .20,
.05, .25, .70,
.00, .10, .90), 3, 3, byrow=TRUE)
rmarkov(50, P)
[Package MCMCprecision version 0.4.0 Index]