esda.Join_Counts¶
- class esda.Join_Counts(y, w, permutations=999)[source]¶
Binary Join Counts
- Parameters
- y
array
binary variable measured across n spatial units
- w
W
spatial weights instance
- permutations
int
number of random permutations for calculation of pseudo-p_values
- y
Notes
Technical details and derivations can be found in [].
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.join_counts import Join_Counts >>> jc = Join_Counts(y, w) >>> jc.bb 10.0 >>> jc.bw 4.0 >>> jc.ww 10.0 >>> jc.J 24.0 >>> len(jc.sim_bb) 999 >>> round(jc.p_sim_bb, 3) 0.003 >>> round(np.mean(jc.sim_bb), 3) 5.547 >>> np.max(jc.sim_bb) 10.0 >>> np.min(jc.sim_bb) 0.0 >>> len(jc.sim_bw) 999 >>> jc.p_sim_bw 1.0 >>> np.mean(jc.sim_bw) 12.811811811811811 >>> np.max(jc.sim_bw) 24.0 >>> np.min(jc.sim_bw) 7.0 >>> round(jc.chi2_p, 3) 0.004 >>> jc.p_sim_chi2 0.002
- Attributes
- y
array
original variable
- w
W
original w object
- permutations
int
number of permutations
- bb
float
number of black-black joins
- ww
float
number of white-white joins
- bw
float
number of black-white joins
- J
float
number of joins
- sim_bb
array
(if permutations>0) vector of bb values for permuted samples
- p_sim_bb
array
- (if permutations>0)
p-value based on permutations (one-sided) null: spatial randomness alternative: the observed bb is greater than under randomness
- mean_bb
float
average of permuted bb values
- min_bb
float
minimum of permuted bb values
- max_bb
float
maximum of permuted bb values
- sim_bw
array
(if permutations>0) vector of bw values for permuted samples
- p_sim_bw
array
(if permutations>0) p-value based on permutations (one-sided) null: spatial randomness alternative: the observed bw is greater than under randomness
- mean_bw
float
average of permuted bw values
- min_bw
float
minimum of permuted bw values
- max_bw
float
maximum of permuted bw values
- chi2
float
Chi-square statistic on contingency table for join counts
- chi2_p
float
Analytical p-value for chi2
- chi2_dof
int
Degrees of freedom for analytical chi2
- crosstab
DataFrame
Contingency table for observed join counts
- expected
DataFrame
Expected contingency table for the null
- p_sim_chi2
float
p-value for chi2 under random spatial permutations
- y
Methods
__init__
(y, w[, permutations])by_col
(df, cols[, w, inplace, pvalue, outvals])Function to compute a Join_Count statistic on a dataframe