estimateMarkovChain: Fit a first-Order Markov Chain to a Sequence of Finite...

View source: R/MarkovChains.R

estimateMarkovChainR Documentation

Fit a first-Order Markov Chain to a Sequence of Finite Symbols

Description

Estimates the transition matrix and stationary distribution of a first-order Markov chain from an observed sequence of symbols.

Usage

estimateMarkovChain(x, circular=TRUE)

Arguments

x

The sequence of observed symbols as a character vector.

purposes

circular

Should the sequence be treated as circular for the purpose of estimation? The default is ‘⁠TRUE⁠’.

Value

A list with class ‘⁠FiniteStateMarkovChain⁠’ having the following components:

trans.mat

The stochastic transition matrix estimated from x.

stat.dist

The stationary distribution estimated from x.

states

the state labels

Author(s)

Andrew Hart and Servet Martínez

See Also

markov.test, markov.disturbance, simulateMarkovChain

Examples

#Obtain a random 3 x 3 stochastic matrix with rows and columns labelled "A", "B", "C"
mat <- rstochmat(3, labels=c("A", "B", "C"))
mat

#Simulate a Markov chain of length 500 using mat as the transition matrix
seq <- simulateMarkovChain(500, mat)

#Estimate mat and the stationary distribution for the Markov chain which generated seq
estimateMarkovChain(seq)

spgs documentation built on Oct. 3, 2023, 5:07 p.m.