In this post, I want to run an example of absorbing states in stochastic processes. This example is based on Example 3.29 in *Introduction to Stochastic Processes* in R by Robert Dobrow.

# Data

The data I have assembled is based on IRDS reports from my own University of California at Merced.

```
# weights
weights <- c(20, 70, 0, 0, 10, 0,
0, 5, 89, 0, 6, 0,
0, 0, 3, 94, 3, 0,
0, 0, 0, 24, 1, 76,
0, 0, 0, 0, 100, 0,
0, 0, 0, 0, 0, 100)
sparse_weights <- weights[weights > 0]
# transition matrix (row stochastic)
P <- matrix(weights, nrow = 6, byrow = TRUE)*0.01
# states
rownames(P) <- c("Freshman", "Sophomore", "Junior", "Senior", "Dropped", "Graduated")
colnames(P) <- c("Freshman", "Sophomore", "Junior", "Senior", "Dropped", "Graduated")
P
```

```
## Freshman Sophomore Junior Senior Dropped Graduated
## Freshman 0.2 0.70 0.00 0.00 0.10 0.00
## Sophomore 0.0 0.05 0.89 0.00 0.06 0.00
## Junior 0.0 0.00 0.03 0.94 0.03 0.00
## Senior 0.0 0.00 0.00 0.24 0.01 0.76
## Dropped 0.0 0.00 0.00 0.00 1.00 0.00
## Graduated 0.0 0.00 0.00 0.00 0.00 1.00
```

This formulation assumes that about 10 percent of students drop after the first year, and about 24 percent of seniors continue to take classes into the fifth year or more.

# Network Graph

```
library(igraph)
network <- graph_from_adjacency_matrix(P, mode = "directed", weighted = TRUE)
plot(network,
edge.arrow.size = 0.5,
edge.color = "#D4AE00",
edge.label = sparse_weights,
layout = layout_in_circle(network))
```

# Absorbing States

```
# canonical form
Q <- P[1:4, 1:4]
R <- P[1:4, 5:6]
# fundamental matrix (inverse of (I - Q))
fundamental_matrix <- solve(diag(4) - Q)
# absorption
absorption <- fundamental_matrix %*% R
round(100*absorption)
```

```
## Dropped Graduated
## Freshman 22 79
## Sophomore 10 91
## Junior 4 97
## Senior 1 100
```

This model predicts that, starting with incoming students, about 79 percent of those students will eventually graduate while about 21 percent will eventually drop from UC Merced enrollment.