giddy.markov.LISA_Markov¶
-
LISA_Markov.
spillover
(self, quadrant=1, neighbors_on=False)[source]¶ Detect spillover locations for diffusion in LISA Markov.
- Parameters
- quadrantint
which quadrant in the scatterplot should form the core of a cluster.
- neighbors_onbinary
If false, then only the 1st order neighbors of a core location are included in the cluster. If true, neighbors of cluster core 1st order neighbors are included in the cluster.
- Returns
- resultsdictionary
two keys - values pairs: ‘components’ - array (n, t) values are integer ids (starting at 1) indicating which component/cluster observation i in period t belonged to. ‘spillover’ - array (n, t-1) binary values indicating if the location was a spill-over location that became a new member of a previously existing cluster.
Examples
>>> import libpysal >>> from giddy.markov import LISA_Markov >>> f = libpysal.io.open(libpysal.examples.get_path("usjoin.csv")) >>> years = list(range(1929, 2010)) >>> pci = np.array([f.by_col[str(y)] for y in years]).transpose() >>> w = libpysal.io.open(libpysal.examples.get_path("states48.gal")).read() >>> np.random.seed(10) >>> lm_random = LISA_Markov(pci, w, permutations=99) >>> r = lm_random.spillover() >>> (r['components'][:, 12] > 0).sum() 17 >>> (r['components'][:, 13]>0).sum() 23 >>> (r['spill_over'][:,12]>0).sum() 6
Including neighbors of core neighbors >>> rn = lm_random.spillover(neighbors_on=True) >>> (rn[‘components’][:, 12] > 0).sum() 26 >>> (rn[“components”][:, 13] > 0).sum() 34 >>> (rn[“spill_over”][:, 12] > 0).sum() 8