Learn R Programming

asbio (version 1.9-7)

MC: Simple functions for MCMC demonstrations

Description

Function MC creates random Markov Chain from a transitions matrix. Function Rf presents proportional summaries of discrete states from MC. Function mat.pow finds the exponential expansion of a matrix. Required for finding the expectations of a transition matrix.

Usage

MC(T, start, length)
Rf(res)
mat.pow(mat, pow)

Arguments

T

A symmetric transition matrix.

start

Starting state

length

Length of the chain to be created

res

Results from MC.

mat

A symmetric matrix.

pow

Power the matrix is to be raised to.

Author

Ken Aho

Examples

Run this code
A <- matrix(nrow = 4, ncol = 4, c(0.5, 0.5, 0, 0, 0.25, 0.5, 0.25,0, 0, 0.25, 0.5, 0.25, 
0, 0, 0.5, 0.5), byrow = TRUE)
pi.0 <- c(1, 0, 0, 0)
Tp10 <- mat.pow(A, 10)
chain <- MC(A, 1, 100)
Rf(chain)

Run the code above in your browser using DataLab