giddy.rank.Theta¶
- class giddy.rank.Theta(y, regime, permutations=999)[source]¶
Regime mobility measure. [Rey04]
For sequence of time periods Theta measures the extent to which rank changes for a variable measured over n locations are in the same direction within mutually exclusive and exhaustive partitions (regimes) of the n locations.
Theta is defined as the sum of the absolute sum of rank changes within the regimes over the sum of all absolute rank changes.
- Parameters:
- yarray
(n, k) with k>=2, successive columns of y are later moments in time (years, months, etc).
- regimearray
(n, ), values corresponding to which regime each observation belongs to.
- permutationsint
number of random spatial permutations to generate for computationally based inference.
Examples
>>> import libpysal as ps >>> from giddy.rank import Theta >>> import numpy as np >>> f=ps.io.open(ps.examples.get_path("mexico.csv")) >>> vnames=["pcgdp%d"%dec for dec in range(1940,2010,10)] >>> y=np.transpose(np.array([f.by_col[v] for v in vnames])) >>> regime=np.array(f.by_col['esquivel99']) >>> np.random.seed(10) >>> t=Theta(y,regime,999) >>> t.theta array([[0.41538462, 0.28070175, 0.61363636, 0.62222222, 0.33333333, 0.47222222]]) >>> t.pvalue_left array([0.307, 0.077, 0.823, 0.552, 0.045, 0.735]) >>> t.total array([130., 114., 88., 90., 90., 72.]) >>> t.max_total 512
- Attributes:
- ranksarray
ranks of the original y array (by columns).
- regimesarray
the original regimes array.
- totalarray
(k-1, ), the total number of rank changes for each of the k periods.
- max_totalint
the theoretical maximum number of rank changes for n observations.
- thetaarray
(k-1,), the theta statistic for each of the k-1 intervals.
- permutationsint
the number of permutations.
- pvalue_leftfloat
p-value for test that observed theta is significantly lower than its expectation under complete spatial randomness.
- pvalue_rightfloat
p-value for test that observed theta is significantly greater than its expectation under complete spatial randomness.
Methods
__init__
(y, regime[, permutations])