joincounts
import libpysal as lps
import numpy as np
import esda
import matplotlib.pyplot as plt
%matplotlib inline
w = lps.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
jc.crosstab
jc.expected
jc.chi2
jc.chi2_p
jc.p_sim_chi2
import seaborn as sns
f, ax = plt.subplots(1, figsize=(9, 9))
sns.distplot(jc.sim_chi2, rug=True, hist=False, ax=ax)
plt.axvline(jc.chi2, 0,0.17, color='r')
f, ax = plt.subplots(1, figsize=(9, 9))
sns.distplot(jc.sim_bb, rug=True, hist=False, ax=ax)
plt.axvline(jc.bb, 0,0.17, color='r')
plt.title('BB Counts')
f, ax = plt.subplots(1, figsize=(9, 9))
sns.distplot(jc.sim_bw, rug=True, hist=False, ax=ax)
plt.axvline(jc.bw, 0,0.17, color='r')
plt.title('WW Counts')