Q <- rbind(c(-0.5, 0.25, 0, 0.25), c(0.166, -0.498, 0.166, 0.166),
c(0, 0.25, -0.5, 0.25), c(0, 0, 0, 0))
## ppass[1,2](t) converges to 0.5 with t, since given in state 1, the
## probability of going to the absorbing state 4 before visiting state
## 2 is 0.5, and the chance of still being in state 1 at t decreases.
ppass.msm(qmatrix=Q, tot=2)
ppass.msm(qmatrix=Q, tot=20)
ppass.msm(qmatrix=Q, tot=100)
Q <- Q[1:3,1:3]; diag(Q) <- 0; diag(Q) <- -rowSums(Q)
## Probability of about 1/2 of visiting state 3 by time 10.5, the
## median first passage time
ppass.msm(qmatrix=Q, tot=10.5)
## Mean first passage time from state 2 to state 3 is 10.02: similar
## to the median
efpt.msm(qmatrix=Q, tostate=3)
Run the code above in your browser using DataLab