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. In case a cell in the empirical transition matrix is >0 that is 0 in the theoretical transition matrix the null hypothesis is rejected.

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

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 results be 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. In case a cell in the empirical transition matrix is >0 that is 0 in the theoretical transition matrix the null hypothesis is rejected. In that case a p-value of 0 and statistic and dof of NA are returned.

a list of transition matrices?

References

Anderson and Goodman.

See also

markovchain

Author

Tae Seung Kang, Giorgio Alfredo Spedicato

Examples

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)
#> Testing markovianity property on given data sequence #> Chi - square statistic is: 0.28 #> Degrees of freedom are: 5 #> And corresponding p-value is: 0.9980024
assessOrder(sequence)
#> Warning: The accuracy of the statistical inference functions has been questioned. It will be thoroughly investigated in future versions of the package.
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> The assessOrder test statistic is: 1.55307e-31 #> The Chi-Square d.f. are: 2 #> The p-value is: 1
assessStationarity(sequence, 1)
#> Warning: The accuracy of the statistical inference functions has been questioned. It will be thoroughly investigated in future versions of the package.
#> Warning: Chi-squared approximation may be incorrect
#> Warning: Chi-squared approximation may be incorrect
#> The assessStationarity test statistic is: 0.1960191 #> The Chi-Square d.f. are: 0 #> The p-value is: 0
#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)
#> Testing whether the #> 0 1 2 #> 0 51 11 8 #> 1 12 31 9 #> 2 6 11 10 #> transition matrix is compatible with #> 0 1 2 #> 0 0.625 0.250 0.125 #> 1 0.250 0.500 0.250 #> 2 0.250 0.375 0.375 #> [1] "theoretical transition matrix" #> ChiSq statistic is 6.551795 d.o.f are 6 corresponding p-value is 0.3642899
#> $statistic #> 0 #> 6.551795 #> #> $dof #> [1] 6 #> #> $pvalue #> 0 #> 0.3642899 #>
data(kullback) verifyHomogeneity(inputList=kullback,verbose=TRUE)
#> Warning: The accuracy of the statistical inference functions has been questioned. It will be thoroughly investigated in future versions of the package.
#> Testing homogeneity of DTMC underlying input list #> ChiSq statistic is 275.9963 d.o.f are 35 corresponding p-value is 0
#> $statistic #> [1] 275.9963 #> #> $dof #> [1] 35 #> #> $pvalue #> [1] 0 #>