Chapter 11: Markov Chains, Question 11 (pg.414)

Question

Assume that a manโ€™s profession can be classified as professional, skilled laborer, or unskilled laborer. Assume that, of the sons of professional men, 80 percent are professional, 10 percent are skilled laborers, and 10 percent are unskilled laborers. In the case of sons of skilled laborers, 60 percent are skilled laborers, 20 percent are professional, and 20 percent are unskilled. Finally, in the case of unskilled laborers, 50 percent of the sons are unskilled laborers, and 25 percent each are in the other two categories. Assume that every man has at least one son, and form a Markov chain by following the profession of a randomly chosen son of a given family through several generations. Set up the matrix of transition probabilities. Find the probability that a randomly chosen grandson of an unskilled laborer is a professional man.

Solution

We know that each element in the transition matrix can be calculated using the following formula: \[p_{ij}^n = \sum_{k=1}^r p_{ik}p_{kj}\] where \(r\) is the number of states in the system. We are given the probabilities for the transition matrix at stage 1 \((s_1)\), and we will use this to calculate the transition matrices for the next \(n\) stages.

We will first define \(r=3\) and our initial transition matrix, \(P^1\):

r <- 3
# transition matrix for stage 1
p1 <- matrix(c(0.8, 0.2, 0.25, 0.1, 0.6, 0.25, 0.1, 0.2, 0.5), 
             nrow=3, 
             ncol=3,
             dimnames = list(c('P', 'S', 'U'), c('P', 'S', 'U')))

p1
##      P    S   U
## P 0.80 0.10 0.1
## S 0.20 0.60 0.2
## U 0.25 0.25 0.5

Now we will define \(n=10\) as the total number of stages to calculate, a sequence from \(1:r\) that will be used to calculate the transition matrix, and a variable called \(prevMatrix\) that will store the transition matrix at the previous stage.

numStages <- 10
sumOver <- seq(r)
prevMatrix <- p1

Next, we will loop through each stage and print out the transition matrix. We will define a variable, \(tempMatrix\) to store the current results and overwrite the \(prevMatrix\) variable with the current transition matrix at the end of our calculation.

for (stage in seq(from=2,to=numStages)) {
  
  # define temp matrix for current stage results 
  tempMatrix <- matrix(c(0, 0, 0, 0, 0, 0, 0, 0, 0), 
               nrow=3, 
               ncol=3,
               dimnames = list(c('P', 'S', 'U'), c('P', 'S', 'U')))
  
  # calculate each element in the transition matrix at stage n
  for(i in seq(nrow(p1))){
    for(j in seq(ncol(p1))){
      tempMatrix[i,j] <- sum(prevMatrix[i,sumOver]*prevMatrix[sumOver,j])
    }
  }
  
  prevMatrix <- tempMatrix
  
  print(paste0('Tx matrix at stage ', stage ,': '))
  print(prevMatrix)
}
## [1] "Tx matrix at stage 2: "
##       P     S     U
## P 0.685 0.165 0.150
## S 0.330 0.430 0.240
## U 0.375 0.300 0.325
## [1] "Tx matrix at stage 3: "
##          P        S        U
## P 0.579925 0.228975 0.191100
## S 0.457950 0.311350 0.230700
## U 0.477750 0.288375 0.233875
## [1] "Tx matrix at stage 4: "
##           P         S         U
## P 0.5324701 0.2591882 0.2083417
## S 0.5183763 0.2683260 0.2132977
## U 0.5208543 0.2666221 0.2125237
## [1] "Tx matrix at stage 5: "
##           P         S         U
## P 0.5263971 0.2631054 0.2104975
## S 0.5262108 0.2632257 0.2105635
## U 0.5262438 0.2632044 0.2105518
## [1] "Tx matrix at stage 6: "
##           P         S         U
## P 0.5263158 0.2631579 0.2105263
## S 0.5263158 0.2631579 0.2105263
## U 0.5263158 0.2631579 0.2105263
## [1] "Tx matrix at stage 7: "
##           P         S         U
## P 0.5263158 0.2631579 0.2105263
## S 0.5263158 0.2631579 0.2105263
## U 0.5263158 0.2631579 0.2105263
## [1] "Tx matrix at stage 8: "
##           P         S         U
## P 0.5263158 0.2631579 0.2105263
## S 0.5263158 0.2631579 0.2105263
## U 0.5263158 0.2631579 0.2105263
## [1] "Tx matrix at stage 9: "
##           P         S         U
## P 0.5263158 0.2631579 0.2105263
## S 0.5263158 0.2631579 0.2105263
## U 0.5263158 0.2631579 0.2105263
## [1] "Tx matrix at stage 10: "
##           P         S         U
## P 0.5263158 0.2631579 0.2105263
## S 0.5263158 0.2631579 0.2105263
## U 0.5263158 0.2631579 0.2105263

We can see from the results, that our probabilities start to level out at stage 6. We can identify the probability that a randomly chosen grandson of an unskilled laborer is a professional man by looking at the transition matrix in row 1, column 1 \(p_{11}=0.5263158\).