spedygiorgio / markovchain

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

Error! Rows of transition matrix do not sum to one #209

Closed newledge closed 2 years ago

newledge commented 2 years ago

library(markovchain) tm <- rbind( c(0.0000,0.0000,0.00000,0.00000,0.00000,0.50000), c(0.0000,0.0000,0.00000,0.50000,0.00000,0.50000), c(0.0000,0.0000,0.00000,0.66667,0.33333,0.00000), c(0.0000,0.5000,0.66667,0.00000,0.50000,0.00000), c(0.0000,0.0000,0.33333,0.50000,0.00000,1.00000), c(0.5000,0.5000,0.00000,0.00000,1.00000,0.00000) ) states <- c("conversion","null","start","1","2","3") mc <- new("markovchain", states=states, transitionMatrix=tm)

===================== Error in validObject(.Object) :Error! Rows of transition matrix do not sum to one

trans_matrix <- tm/rowSums(tm) mc <- new("markovchain", states=states, transitionMatrix=tm)

"trans_matrix" change "tm" value , I think not to change "tm" value ?