I am doing Markov process for my assignment using R. I already designed my matrix but the problem is I cannot put my matrix into markov object. The error is saying ..
Error in validObject(.Object) :
invalid class “markovchain” object: 1: Error! Row sums not equal to one check positions: 2
invalid class“markovchain” object: 2: Error! Row sums not equal to one check positions: 4
invalid class “markovchain” object: 3: Error! Row sums not equal to one check positions: 6
In addition: Warning message:
In if (check == FALSE) { :
the condition has length > 1 and only the first element will be used
Here is my code
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")