esda.Join_Counts

class esda.Join_Counts(y, w, permutations=999, drop_islands=True)[source]

Binary Join Counts

Parameters:
y : array

binary variable measured across n spatial units

w : W | Graph

spatial weights instance as W or Graph aligned with y

permutations : int

number of random permutations for calculation of pseudo-p_values

y[source]

original variable

Type:

array

w[source]

original w object

Type:

W

permutations[source]

number of permutations

Type:

int

bb[source]

number of black-black joins

Type:

float

ww[source]

number of white-white joins

Type:

float

bw[source]

number of black-white joins

Type:

float

J[source]

number of joins

Type:

float

sim_bb[source]

(if permutations>0) vector of bb values for permuted samples

Type:

array

p_sim_bb[source]
(if permutations>0)

p-value based on permutations (one-sided) null: spatial randomness alternative: the observed bb is greater than under randomness

Type:

array

mean_bb[source]

average of permuted bb values

Type:

float

min_bb[source]

minimum of permuted bb values

Type:

float

max_bb[source]

maximum of permuted bb values

Type:

float

sim_bw[source]

(if permutations>0) vector of bw values for permuted samples

Type:

array

p_sim_bw[source]

(if permutations>0) p-value based on permutations (one-sided) null: spatial randomness alternative: the observed bw is greater than under randomness

Type:

array

mean_bw[source]

average of permuted bw values

Type:

float

min_bw[source]

minimum of permuted bw values

Type:

float

max_bw[source]

maximum of permuted bw values

Type:

float

chi2[source]

Chi-square statistic on contingency table for join counts

Type:

float

chi2_p[source]

Analytical p-value for chi2

Type:

float

chi2_dof[source]

Degrees of freedom for analytical chi2

Type:

int

crosstab[source]

Contingency table for observed join counts

Type:

DataFrame

expected[source]

Expected contingency table for the null

Type:

DataFrame

p_sim_chi2[source]

p-value for chi2 under random spatial permutations

Type:

float

drop_islands[source]

Whether or not to preserve islands as entries in the adjacency list. By default, observations with no neighbors do not appear in the adjacency list. If islands are kept, they are coded as self-neighbors with zero weight. See libpysal.weights.to_adjlist().

Type:

bool (default True)

Examples

>>> import numpy as np
>>> import libpysal
>>> w = libpysal.weights.lat2W(4, 4)
>>> y = np.ones(16)
>>> y[0:8] = 0
>>> np.random.seed(12345)
>>> from esda import Join_Counts
>>> jc = Join_Counts(y, w)
>>> jc.bb
np.float64(10.0)
>>> jc.bw
np.float64(4.0)
>>> jc.ww
np.float64(10.0)
>>> jc.J
np.float64(24.0)
>>> len(jc.sim_bb)
999
>>> round(jc.p_sim_bb, 3)
np.float64(0.003)
>>> round(np.mean(jc.sim_bb), 3)
np.float64(5.547)
>>> np.max(jc.sim_bb)
np.float64(10.0)
>>> np.min(jc.sim_bb)
np.float64(0.0)
>>> len(jc.sim_bw)
999
>>> jc.p_sim_bw
np.float64(1.0)
>>> np.mean(jc.sim_bw)
np.float64(12.811811811811811)
>>> np.max(jc.sim_bw)
np.float64(24.0)
>>> np.min(jc.sim_bw)
np.float64(7.0)
>>> round(jc.chi2_p, 3)
np.float64(0.004)
>>> jc.p_sim_chi2
np.float64(0.008)

Notes

Technical details and derivations can be found in [Cliff and Ord, 1981].