The stat2003
package provides some functions about discrete-time Markov chains and certain birth-death type processes, which is suitable for students who are studying STAT2003 at University College London (UCL). This package can help students to study the course and understand Markov chains more clearly. It was created by Zhixiao Zhu as part of an undergraduate project at UCL during the 2016-17 academic year, supervised by Paul Northrop.
For discrete-time Markov chains the starting point is to create an object of class stat2003.d
that specifies the statspace of the chain, its transition matrix and the starting distribution.
P <- matrix(c(0, 1, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0,
0, 1/3, 0, 2/3, 0, 0, 0,
0, 0, 0, 0, 2/3, 1/3, 0,
0, 2/3, 0, 1/3, 0, 0, 0,
0, 0, 0, 0, 0, 1/3, 2/3,
0, 0, 0, 0, 0, 1/4, 3/4), nr = 7, nc=7, byrow = T)
# Input the transition matrix, initial distribution and statespace to
# create a new discrete-time finite statespace Markov chain in the class
# stat2003.d
MC <- new("stat2003.d", p_start = c(1/7, 1/7, 1/7, 1/7, 1/7, 1/7, 1/7), p = P,
statespace = LETTERS[1 : 7] )
A similar approach is used to specify continuous-time Markov chains of the birth-death type to create an object of class stat2003.bd
. Please see the help files ?stat2003
for further details and for functions that can be applied to objects of class stat2003.d
or stats2003.bd
.
To install the package from GitHub use:
library(devtools)
devtools::install_github("paulnorthrop/stat2003")
See the vignette stat2003-vignette
in `User guides, package vignettes and other documentation' for an overview of the package.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.