spedygiorgio / markovchain

Easy Handling Discrete Time Markov Chains
https://spedygiorgio.github.io/markovchain/
Other
105 stars 39 forks source link

verifyEmpiricalToTheoretical does not accept matrix input as data #188

Closed ebbertd closed 4 years ago

ebbertd commented 4 years ago

The verifyEmpiricalToTheoretical function does not accept a matrix as data input, even though the documentation for that function states that the data should be a matrix, character or list to be converted in a raw transition matrix. To reproduce follow these steps:

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=mc,object=theoreticalMc)

This results in the following error:

Warnmeldungen:
1: In verifyEmpiricalToTheoretical(data = mc, object = theoreticalMc) :
  The accuracy of the statistical inference functions has been questioned. It will be thoroughly investigated in future versions of the package.
2: In if (!(class(data) %in% c("matrix", "character", "numeric"))) stop("Error! Data should be either a raw transition matrix or \n                                                                  either a character or a numeric element") :
  Bedingung hat Länge > 1 und nur das erste Element wird benutzt
3: In if (class(data) %in% c("character", "numeric")) data <- createSequenceMatrix(stringchar = data) :
  Bedingung hat Länge > 1 und nur das erste Element wird benutzt

This is due to the output of class(mc) which returns [1] "matrix" "array" instead of just "matrix", which the function expects.