无法在R中拟合Markov模型

时间:2019-04-11 07:47:29

标签: r statistics markov-chains markov operations-research

我正在使用R做分配的马尔可夫过程。我已经设计了矩阵,但是问题是我无法将矩阵放入markov对象中。错误是说..

  

validObject(.Object)中的错误:

     

无效的类“ markovchain”对象:   1:错误!行总和不等于一个检查位置:2

     

无效的类“ markovchain”对象:2:错误!行总和不等于一张支票   职位:4

     

无效的类“ markovchain”对象:3:错误!行总和   不等于一个检查位置:6

     

此外:警告消息:

     

如果if(check == FALSE){:
    条件的长度> 1,并且只会使用第一个元素

这是我的代码

library(markovchain)
areaStates <- c("1","2","3","4","5","6","7")
areaMatrix <- matrix(data = c(0,0.2,0,0.2,0.2,0.2,0.2,
                              0.33,0,0.33,0.33,0,0,0,
                              0,0,1,0,0,0,0,
                              0.33,0.33,0.33,0,0,0,0,
                              1,0,0,0,0,0,0,
                              0.5,0,0,0,1,0,0.5,
                              0.5,0,0,0,0,0.5,0), byrow = T, nrow = 7,
                     dimnames = list(areaStates, areaStates))
area <- new("markovchain", states = areaStates, byrow = T,
                 transitionMatrix = areaMatrix, name = "Area")

0 个答案:

没有答案