giddy.markov.FullRank_Markov

class giddy.markov.FullRank_Markov(y)[source]

Full Rank Markov in which ranks are considered as Markov states rather than quantiles or other discretized classes. This is one way to avoid issues associated with discretization.

Parameters
yarray

(n, t) with t>>n, one row per observation (n total), one column recording the value of each observation, with as many columns as time periods.

Notes

Refer to [Rey14b] Equation (11) for details. Ties are resolved by assigning distinct ranks, corresponding to the order that the values occur in each cross section.

Examples

US nominal per capita income 48 states 81 years 1929-2009

>>> from giddy.markov import FullRank_Markov
>>> import libpysal as ps
>>> import numpy as np
>>> f = ps.io.open(ps.examples.get_path("usjoin.csv"))
>>> pci = np.array([f.by_col[str(y)] for y in range(1929,2010)]).transpose()
>>> m = FullRank_Markov(pci)
>>> m.ranks
array([[45, 45, 44, ..., 41, 40, 39],
       [24, 25, 25, ..., 36, 38, 41],
       [46, 47, 45, ..., 43, 43, 43],
       ...,
       [34, 34, 34, ..., 47, 46, 42],
       [17, 17, 22, ..., 25, 26, 25],
       [16, 18, 19, ...,  6,  6,  7]])
>>> m.transitions
array([[66.,  5.,  5., ...,  0.,  0.,  0.],
       [ 8., 51.,  9., ...,  0.,  0.,  0.],
       [ 2., 13., 44., ...,  0.,  0.,  0.],
       ...,
       [ 0.,  0.,  0., ..., 40., 17.,  0.],
       [ 0.,  0.,  0., ..., 15., 54.,  2.],
       [ 0.,  0.,  0., ...,  2.,  1., 77.]])
>>> m.p[0, :5]
array([0.825 , 0.0625, 0.0625, 0.025 , 0.025 ])
>>> m.fmpt[0, :5]
array([48.        , 87.96280048, 68.1089084 , 58.83306575, 41.77250827])
>>> m.sojourn_time[:5]
array([5.71428571, 2.75862069, 2.22222222, 1.77777778, 1.66666667])
Attributes
ranksarray

ranks of the original y array (by columns): higher values rank higher, e.g. the largest value in a column ranks 1.

parray

(n, n), transition probability matrix for Full Rank Markov.

steady_statearray

(n, ), ergodic distribution.

transitionsarray

(n, n), count of transitions between each rank i and j

fmptarray

(n, n), first mean passage times.

sojourn_timearray

(n, ), sojourn times.

__init__(self, y)[source]

Initialize self. See help(type(self)) for accurate signature.