Example of Markov Chain from Book (Example 8.2)

probmat  =  {{1/3, 1/3, 1/3}, {0.7, 0.3, 0.0}, {1.0, 0.0, 
            0.0}};
MatrixForm[probmat]

Clear[pi]
pi[0] := {1, 0, 0}
pi[n_]  :=  Dot[pi[n - 1], probmat]
Table[pi[i], {i, 1, 12}];
TableForm[%]

Clear[pi]
pi[0] := {0, 1, 0}
pi[n_]  :=  Dot[pi[n - 1], probmat]
Table[pi[i], {i, 1, 12}];
TableForm[%]

Clear[pi]
pi[0] := {0.1, 0.4, 0.5}
pi[n_]  :=  Dot[pi[n - 1], probmat]
Table[pi[i], {i, 1, 12}];
TableForm[%]

eq1  =  
      pi1  ==  Part[Dot[{pi1, pi2, pi3}, probmat], 
          1]
eq2  =  
      pi2  ==  Part[Dot[{pi1, pi2, pi3}, probmat], 
          2]
eq3  =  
      pi3  ==  Part[Dot[{pi1, pi2, pi3}, probmat], 
          3]
Solve[{eq1, eq2, eq3}, {pi1, pi2, pi3}]

Solve[{pi1 == 3  pi3, pi2 == 1.42857  pi3, 
        pi1 + pi2 + pi3 == 1}, {pi1, pi2, pi3}]

Relation to the Social Mobility Model

probmat  =  {{0.81, 0.15, 0.04}, {0.10, 0.80, 0.10}, {0.05, 0.20, 
            0.75}};
MatrixForm[probmat]

pi[0] := {8/30, 10/30, 12/30}
pi[n_]  :=  Dot[pi[n - 1], probmat]
data  =  Table[N[pi[i]], {i, 0, 20}];
TableForm[data]
TableForm[Round[data*30000]]

<< Graphics`MultipleListPlot`

data1  =  
      Table[{i - 1, Round[30000*Part[data, i, 1]]}, {i, 1, 
          21}]
data2  =  
        Table[{i - 1, Round[30000*Part[data, i, 2]]}, {i, 1, 
            21}];
data3  =  
        Table[{i - 1, Round[30000*Part[data, i, 3]]}, {i, 1, 
            21}];
plot2  =  
      MultipleListPlot[data1, data2, data3, PlotJoined -> True, 
        Frame -> True, 
        FrameLabel -> {"Time in Years", "Population"}]
plot2  =  MultipleListPlot[data1, data2, data3]

Sensitivity Analysis

probmat  =  {{81/100, 15/100, 4/100}, {10/100, 80/100, 
            10/100}, {5/100, (20 + λ)/100, (75 - λ)/
              100}};
MatrixForm[probmat]

eq1  =  
      pi1  ==  Part[Dot[{pi1, pi2, pi3}, probmat], 
          1]
eq2  =  
      pi2  ==  Part[Dot[{pi1, pi2, pi3}, probmat], 
          2]
eq3  =  
      pi3  ==  Part[Dot[{pi1, pi2, pi3}, probmat], 
          3]
Solve[{eq1, eq2, eq3}, {pi1, pi2, pi3}]
Simplify[%]

Solve[{pi1 == (1/23) pi3 (30 + λ), 
        pi2 == (1/230) pi3 (455 + 19 λ), 
        pi1 + pi2 + pi3 == 1}, {pi1, pi2, pi3}]

pi1 = ((10 (30 + λ))/(985 + 29 λ))
pi2 = -((-455 - 19 λ)/(985 + 
              29 λ))
pi3 = (230/(985 + 29 λ))

Plot[{pi1, pi2, pi3}, {λ, -25, 25}, Frame -> True, 
      FrameLabel -> {"lambda", "Probabilities"}]