`function(trans,initprob,N)'
{
BrokerPosition <- c("BP", "IP", "SP")
mysequence <- character()
firstposition <- sample(BrokerPosition, 1, rep=TRUE, prob=initprob)
mysequence[1] <- firstposition
for (i in 2:N) {
prevposition <- mysequence[i-1]
probabilities <- trans[prevposition,]
BPosition <- sample(BrokerPosition, 1, rep=TRUE, prob=probabilities)
mysequence[i] <- BPosition
}
return(mysequence)
}
这是一个模拟马尔可夫链的函数,但是每当我运行它时,我都会收到错误 no 'dimnames' attribute for array ,知道为什么会这样