Page 425 # 18 Assume that a student going to a certain four-year medical school in northern New England has, each year, a probability \(q\) of flunking out, a probability \(r\) of having to repeat the year, and a probability \(p\) of moving on to the next year (in the fourth year, moving on means graduating).
Transition Matrix: \[ \begin{array}{c|cccccc} & F & 1 & 2 &3 &4 &G \\ \hline F & 1 & 0 & 0 & 0 & 0 & 0\\ 1 & q & r & p & 0 & 0 & 0\\ 2 & q & 0 & r & p & 0 & 0\\ 3 & q & 0 & 0 & r & p & 0\\ 4 & q & 0 & 0 & 0 & r & p\\ G.& 0 & 0 & 0 & 0 & 0 & 1\\ \end{array} \]
Canonical Form: \[ \begin{array}{ccccc|cc} & 1 & 2 &3 &4 &F &G \\ 1 & r & p & 0 & 0 & q & 0\\ 2 & 0 & r & p & 0 & q & 0\\ 3 & 0 & 0 & r & p & q & 0\\ 4 & 0 & 0 & 0 & r & q & p\\ \hline F & 0 & 0 & 0 & 0 & 1 & 0\\ G.& 0 & 0 & 0 & 0 & 0 & 1\\ \end{array} \]
#q matrix for transient state to transient state
q_matrix <- matrix(c(.2,.7,0,0,.0,.2,.7,0,0,0,.2,.7,0,0,0,.2), c(4,4), byrow = TRUE)
identity <- diag(4)
n_matrix <- solve(identity-q_matrix)
print(n_matrix)
## [,1] [,2] [,3] [,4]
## [1,] 1.25 1.09375 0.9570312 0.8374023
## [2,] 0.00 1.25000 1.0937500 0.9570312
## [3,] 0.00 0.00000 1.2500000 1.0937500
## [4,] 0.00 0.00000 0.0000000 1.2500000
The value in the first row, second column tells us that the time a beginning student can expect to be in the second year is about 1.09 years.
c_matrix <- matrix(c(1,1,1,1), nrow=4)
t_matrix <- n_matrix %*% c_matrix
print(t_matrix)
## [,1]
## [1,] 4.138184
## [2,] 3.300781
## [3,] 2.343750
## [4,] 1.250000
The time spent in medical school is the time until absorption. Here, the time until absorption starting from year 1 is about 4.14 years. This is equal to the sum of the values in the first row of the n_matrix, ie, the total time a beginning student is expected to spend in each of the four years, combined.
#r matrix for transient state to absorption state
r_matrix <- matrix(c(.1,0,.1,0,.1,0,.1,.7), nrow=4, byrow = TRUE)
b_matrix <- n_matrix %*% r_matrix
print(b_matrix)
## [,1] [,2]
## [1,] 0.4138184 0.5861816
## [2,] 0.3300781 0.6699219
## [3,] 0.2343750 0.7656250
## [4,] 0.1250000 0.8750000
The value in the first row corresponding to the second absorption state indicates that a student starting in the 1st year has about a 58.6% chance of graduating.