sampleDMC: Sample discrete Markov chains

Description Usage Arguments Details Value References See Also Examples

View source: R/models.R

Description

This function draws independent random samples of a discrete Markov chain.

Usage

1
sampleDMC(pInit, Q, n = 1)

Arguments

pInit

an array of length K, containing the marginal distribution of the states for the first variable.

Q

an array of size (p-1,K,K), containing a list of p-1 transition matrices between the K states of the Markov chain.

n

the number of independent samples to be drawn (default: 1).

Details

Each element of the output matrix is an integer value between 0 and K-1. The transition matrices contained in Q are defined such that P[X_{j+1}=k|X_{j}=l]=Q[j,l,k].

Value

A matrix of size n-by-p containing the n observed Markov chains of length p.

References

\insertRef

sesia2019SNPknock

See Also

Other models: sampleHMM

Examples

1
2
3
4
5
p=10; K=5;
pInit = rep(1/K,K)
Q = array(stats::runif((p-1)*K*K),c(p-1,K,K))
for(j in 1:(p-1)) { Q[j,,] = Q[j,,] / rowSums(Q[j,,]) }
X = sampleDMC(pInit, Q, n=20)

SNPknock documentation built on May 18, 2019, 1:03 a.m.