rdistributionstochastic-process

Find limiting distribution of transition matrix and plot in R


may I know how I can find and plot the results of the limiting distribution or a unique stationary distribution of a transition matrix in R? (my goal is to have a unique and constant result instead of a random result)

This is the P matrix used:

P=matrix(c(0.2,0.3,0.5,0.1,0.8,0.1,0.4,0.2,0.4),nrow=3,ncol=3,byrow=TRUE)

Solution

  • I misspoke in my earlier answer. Either the sums of the rows or the column need to all be 1 for a transition matrix. It depends on whether you are using v'P or Pv to transition to the next step.
    I'll use Pv.
    For the limiting distribution to be stable, we must have: Pv = v, or (P - I)v = 0. So the limiting distribution is an eigenvector with eigenvalue 1. Then to be sure it's a distribution sum(v) == 1. Since your matrix has rows that sum to 1, not columns, we need to use the transpose of the matrix to calculate the eigenvalues:

    e <- eigen(t(P))$vectors[, 1]
    e <- e / sum(e)
    

    Gives:

    e
    [1] 0.1960784 0.5490196 0.2549020
    

    To check this:

    P=matrix(c(0.2,0.3,0.5,0.1,0.8,0.1,0.4,0.2,0.4),nrow=3,ncol=3, byrow = TRUE)
    ans <- e
    for (i in 1:1000) {
      ans <- ans %*% P
    }
    ans
    
    ans
              [,1]      [,2]     [,3]
    [1,] 0.1960784 0.5490196 0.254902
    

    Same, so it's stable. I'm not clear as to what you wanted to plot.