Learn R Programming

markovchain (version 0.6.9)

verifyMarkovProperty: Various functions to perform statistical inference of DTMC

Description

These functions verify the Markov property, assess the order and stationarity of the Markov chain.

This function tests whether an empirical transition matrix is statistically compatible with a theoretical one. It is a chi-square based test

Verifies that the s elements in the input list belongs to the same DTMC

Usage

verifyMarkovProperty(sequence, verbose = TRUE)

assessOrder(sequence, verbose = TRUE)

assessStationarity(sequence, nblocks, verbose = TRUE)

verifyEmpiricalToTheoretical(data, object, verbose = TRUE)

verifyHomogeneity(inputList, verbose = TRUE)

Arguments

sequence
An empirical sequence.
verbose
Should test resuls been printed out?
nblocks
Number of blocks.
data
matrix, character or list to be converted in a raw transition matrix
object
a markovchain object
inputList
A list of items that can coerced to transition matrices

Value

Verification result

a list with following slots: statistic (the chi - square statistic), dof (degrees of freedom), and corresponding p-value

a list of transition matrices?

References

Anderson and Goodman.

See Also

markovchain

Examples

Run this code
sequence <- c("a", "b", "a", "a", "a", "a", "b", "a", "b",
              "a", "b", "a", "a", "b", "b", "b", "a")
mcFit <- markovchainFit(data = sequence, byrow = FALSE)
verifyMarkovProperty(sequence)
assessOrder(sequence)
assessStationarity(sequence, 1)


#Example taken from Kullback Kupperman Tests for Contingency Tables and Markov Chains

sequence<-c(0,1,2,2,1,0,0,0,0,0,0,1,2,2,2,1,0,0,1,0,0,0,0,0,0,1,1,
2,0,0,2,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,2,1,0,
0,2,1,0,0,0,0,0,0,1,1,1,2,2,0,0,2,1,1,1,1,2,1,1,1,1,1,1,1,1,1,0,2,
0,1,1,0,0,0,1,2,2,0,0,0,0,0,0,2,2,2,1,1,1,1,0,1,1,1,1,0,0,2,1,1,
0,0,0,0,0,2,2,1,1,1,1,1,2,1,2,0,0,0,1,2,2,2,0,0,0,1,1)

mc=matrix(c(5/8,1/4,1/8,1/4,1/2,1/4,1/4,3/8,3/8),byrow=TRUE, nrow=3)
rownames(mc)<-colnames(mc)<-0:2; theoreticalMc<-as(mc, "markovchain")

verifyEmpiricalToTheoretical(data=sequence,object=theoreticalMc)


data(kullback)
verifyHomogeneity(inputList=kullback,verbose=TRUE)

Run the code above in your browser using DataLab