0

I am trying to use the markovchain package with a set of transition matrices but I am getting this error: Error in validObject(.Object) : invalid class “markovchain” object: Error! Rows of transition matrix do not sum to one I have checked here and it was suggested to reinstall the package directly from Git Hub, I did it but I am still getting the error. I checked that sum() gives 1 to be sure I am not making a mistake there. Here is a reproducible example:

devtools::install_github('spedygiorgio/markovchain')
library(markovchain)
stateNames <- c("high", "low", "med")

q0 <- new("markovchain", states = stateNames,
          transitionMatrix =matrix(c(0.04,0.04,0.08,0.01,0.01,0.14,
                                       0.14,0.16,0.38),
                              byrow = TRUE, nrow = 3), name = "state t0")

sum(0.04,0.04,0.08,0.01,0.01,0.14,
  0.14,0.16,0.38)

Regards

MyName
  • 89
  • 9

0 Answers0