I have a transition matrix with 4 rows and 16 columns, containing the probability to transition from one Wikipedia article to another. The sum of my rows have been normalised to equal 1.
Here is an overview:
dput(head(res,4))
structure(c(0.0269201326869099, 0.221418475097697, 0.0572200491955321,
0.0234890665263753, 0.0931927078903348, 0.203375737923007, 0.310133473123916,
0.220087000151008, 0.00266507896005217, 0.0293922008813503, 0.00467760796806323,
0.0045399854837374, 0.00598225170820221, 0.0235719630830631,
0.0370176216782935, 0.00138830028204416, 0.0424711519378526,
0.0206618441839195, 0.0414532844066293, 0.0344054908493962, 0.0334552465198038,
0.0453978548266401, 0.166498649139078, 0.0243074330084224, 0.391312976666383,
0.34181425126798, 0.131335940965361, 0.113533735696854, 0.190425562076493,
0.0283528727030847, 0.00129037461187951, 0.0467297003707005,
0.0281959683592753, 0.061278789390538, 0, 0.0299483162596755,
0, 0.0158809345638979, 0.0305254244122747, 0, 0.0255592413030535,
0, 0.0753659421750877, 0.0176874327161486, 0, 0, 0.0458082987217227,
0, 0.0268350769754189, 0, 0.0630670591556111, 0.260016464754222,
0, 0, 0.000846808339045929, 0.00347318631964031, 0.0287771823877973,
0.00253596075496799, 0.0145570385902657, 0.0108920681777219,
0.104207422528423, 0.00631911532385466, 0.0202024275172386, 0.209501819404054
), .Dim = c(4L, 16L), .Dimnames = list(c("Selected Disease Article",
"Selected Food Scandal Article", "Selected General Article",
"Selected Pathogen Article"), c("Animal health", "Biology", "Environment",
"Food industry", "General", "Human and animal health", "Human health",
"Medicine", "Other", "Related to a Food scandal", "Related to Antibiotic resistance",
"Related to Food poisoning", "Selected Disease Article", "Selected Food Scandal Article",
"Selected General Article", "Selected Pathogen Article")))
I followed the code below but I get stuck on the definition of my markov chain object
states <- as.character(1:16)
mc <- new(
"markovchain",
states = states,
byrow = TRUE,
transitionMatrix = res,
name = "random_walk");
I get the error: Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent
What is the problem in my code? Am I doing something wrong in the creation of my markov chain function?