spedygiorgio / markovchain

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

problem in markovchainFitList #75

Closed spedygiorgio closed 8 years ago

spedygiorgio commented 8 years ago

when trying to check the new features of rmarkovchain an error was raised : library(markovchain) data(holson) head(holson,n = 3)

fitting a NHDTMCs

nhmcFit<-markovchainListFit(holson[,2:12])

showing estimated DTMC for time 1 -> time 2 transitions

nhmcFit$estimate[[1]]

showing estimated DTMC for time 2 -> time 3 transitions

nhmcFit$estimate[[2]] nhmcFit$estimate ciao<-rmarkovchain(n=100,object=nhmcFit$estimate,what="matrix") ciao<-rmarkovchain(n=1000,object=nhmcFit$estimate,what="matrix") head(ciao)

ERROR

nhmcFit2<-markovchainListFit(ciao)

COULD YOU PLEASE CHECK

cryptomanic commented 8 years ago

The problem is because of rows whose sum is 0. Internal method matr2Mc has been modified to take care of such rows.

> nhmcFit2 <- markovchainListFit(ciao)
> nhmcFit2
$estimate
  list of Markov chain(s) 
Markovchain  1 
Unnamed Markov chain 
 A  3 - dimensional discrete Markov Chain characterized by following states: 
 1, 2, 3 
 The transition matrix  (by rows)  is defined as follows: 
          1          2         3
1 0.9393939 0.06060606 0.0000000
2 0.0000000 0.00000000 1.0000000
3 0.3333333 0.33333333 0.3333333

Markovchain  2 
Unnamed Markov chain 
 A  3 - dimensional discrete Markov Chain characterized by following states: 
 1, 2, 3 
 The transition matrix  (by rows)  is defined as follows: 
          1          2 3
1 0.9139785 0.08602151 0
2 1.0000000 0.00000000 0
3 0.0000000 1.00000000 0

Markovchain  3 
Unnamed Markov chain 
 A  2 - dimensional discrete Markov Chain characterized by following states: 
 1, 2 
 The transition matrix  (by rows)  is defined as follows: 
          1          2
1 0.9230769 0.07692308
2 0.7777778 0.22222222

Markovchain  4 
Unnamed Markov chain 
 A  2 - dimensional discrete Markov Chain characterized by following states: 
 1, 2 
 The transition matrix  (by rows)  is defined as follows: 
          1          2
1 0.9560440 0.04395604
2 0.7777778 0.22222222

Markovchain  5 
Unnamed Markov chain 
 A  2 - dimensional discrete Markov Chain characterized by following states: 
 1, 2 
 The transition matrix  (by rows)  is defined as follows: 
          1          2
1 0.9361702 0.06382979
2 0.8333333 0.16666667

Markovchain  6 
Unnamed Markov chain 
 A  2 - dimensional discrete Markov Chain characterized by following states: 
 1, 2 
 The transition matrix  (by rows)  is defined as follows: 
          1         2
1 1.0000000 0.0000000
2 0.8571429 0.1428571

Markovchain  7 
Unnamed Markov chain 
 A  3 - dimensional discrete Markov Chain characterized by following states: 
 1, 2, 3 
 The transition matrix  (by rows)  is defined as follows: 
          1          2         3
1 0.9797980 0.02020202 0.0000000
2 0.0000000 0.00000000 1.0000000
3 0.3333333 0.33333333 0.3333333

Markovchain  8 
Unnamed Markov chain 
 A  3 - dimensional discrete Markov Chain characterized by following states: 
 1, 2, 3 
 The transition matrix  (by rows)  is defined as follows: 
          1          2 3
1 0.9793814 0.02061856 0
2 1.0000000 0.00000000 0
3 0.0000000 1.00000000 0

Markovchain  9 
Unnamed Markov chain 
 A  2 - dimensional discrete Markov Chain characterized by following states: 
 1, 2 
 The transition matrix  (by rows)  is defined as follows: 
          1          2
1 0.9793814 0.02061856
2 0.6666667 0.33333333