#show markov chain definition
showClass("markovchain")
#create a simple markov chains
simpleMc<-new("markovchain", states=c("a","b"),
transitionMatrix=matrix(c(0.4,0.6,.3,.7),nrow=2,byrow=TRUE))
#power
simpleMc^4
#some methods
steadyStates(simpleMc)
simpleMc[2,1]
t(simpleMc)
#conditional distributions
conditionalDistribution(simpleMc, "b")
#example for predict method
sequence<-c("a", "b", "a", "a", "a", "a", "b", "a", "b", "a", "b", "a", "a", "b", "b", "b", "a")
mcFit<-markovchainFit(data=sequence)
predict(mcFit$estimate, newdata="b",n.ahead=3)
#example of summary
summary(simpleMc)
plot(simpleMc)Run the code above in your browser using DataLab