Learn R Programming

asbio (version 1.0-5)

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 expnasion of a martix. 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.

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