# esda.G_Local

class esda.G_Local(y, w, transform='R', permutations=999, star=False, keep_simulations=True, n_jobs=-1, seed=None, island_weight=0)

  Generalized Local G Autocorrelation

  Parameters:
    y `array`

      variable

    w `W` | `Graph`

      spatial weights instance as W or Graph aligned with y

    transform{‘R’, ‘B’}

      the type of w, either ‘B’ (binary) or ‘R’ (row-standardized)

    permutations `int`

      the number of random permutations for calculating pseudo p values

    star bool or `float`

      whether or not to include focal observation in sums (default: False) if the row-transformed weight is provided, then this is the default value to use within the spatial lag. Generally, weights should be provided in binary form, and standardization/self-weighting will be handled by the function itself.

    island_weight:

      value to use as a weight for the “fake” neighbor for every island. If numpy.nan, will propagate to the final local statistic depending on the stat_func. If 0, then the lag is always zero for islands.

  Attributes:
    y `array`

      original variable

    w `W` | `Graph`

      spatial weights instance as W or Graph aligned with y

    permutations `int`

      the number of permutations

    Gs `array`

      of floats, the value of the orginal G statistic in Getis & Ord (1992)

    EGs `float`

      expected value of Gs under normality assumption the values is scalar, since the expectation is identical across all observations

    VGs `array`

      of floats, variance values of Gs under normality assumption

    Zs `array`

      of floats, standardized Gs

    p_norm `array`

      of floats, p-value under normality assumption (one-sided) for two-sided tests, this value should be multiplied by 2

    sim `array`

      of arrays of floats (if permutations>0), vector of I values for permutated samples

    p_sim `array`

      of floats, p-value based on permutations (one-sided) null - spatial randomness alternative - the observed G is extreme

      > (it is either extremely high or extremely low)

    EG_sim `array`

      of floats, average value of G from permutations

    VG_sim `array`

      of floats, variance of G from permutations

    seG_sim `array`

      of floats, standard deviation of G under permutations.

    z_sim `array`

      of floats, standardized G based on permutations

    p_z_sim `array`

      of floats, p-value based on standard normal approximation from permutations (one-sided)

  Notes

  To compute moments of Gs under normality assumption, PySAL considers w is either binary or row-standardized. For binary weights object, the weight value for self is 1 For row-standardized weights object, the weight value for self is 1/(the number of its neighbors + 1).

  For technical details see [GO10] and [OG10].

  Examples

      >>> import libpysal
      >>> import numpy
      >>> numpy.random.seed(10)

  Preparing a point data set

      >>> points = [(10, 10), (20, 10), (40, 10), (15, 20), (30, 20), (30, 30)]

  Creating a weights object from points

      >>> w = libpysal.weights.DistanceBand(points,threshold=15)

  Preparing a variable

      >>> y = numpy.array([2, 3, 3.2, 5, 8, 7])

  Applying Getis and Ord local G test using a binary weights object

      >>> from esda.getisord import G_Local
      >>> lg = G_Local(y,w,transform='B')

  Examining the results

      >>> lg.Zs
      array([-1.0136729 , -0.04361589,  1.31558703, -0.31412676,  1.15373986,
              1.77833941])
      >>> round(lg.p_sim[0], 3)
      0.101

  p-value based on standard normal approximation from permutations >>> round(lg.p_z_sim[0], 3) 0.154

      >>> numpy.random.seed(10)

  Applying Getis and Ord local G* test using a binary weights object

      >>> lg_star = G_Local(y,w,transform='B',star=True)

  Examining the results

      >>> lg_star.Zs
      array([-1.39727626, -0.28917762,  0.65064964, -0.28917762,  1.23452088,
              2.02424331])
      >>> round(lg_star.p_sim[0], 3)
      0.101

      >>> numpy.random.seed(12345)

  Applying Getis and Ord local G test using a row-standardized weights object

      >>> lg = G_Local(y,w,transform='R')

  Examining the results

      >>> lg.Zs
      array([-0.62074534, -0.01780611,  1.31558703, -0.12824171,  0.28843496,
              1.77833941])
      >>> round(lg.p_sim[0], 3)
      0.103

      >>> numpy.random.seed(10)

  Applying Getis and Ord local G* test using a row-standardized weights object

      >>> lg_star = G_Local(y,w,transform='R',star=True)

  Examining the results

      >>> lg_star.Zs
      array([-0.62488094, -0.09144599,  0.41150696, -0.09144599,  0.24690418,
              1.28024388])
      >>> round(lg_star.p_sim[0], 3)
      0.101

  __init__(y, w, transform='R', permutations=999, star=False, keep_simulations=True, n_jobs=-1, seed=None, island_weight=0)

  Methods

  `__init__`(y, w[, transform, permutations, ...]) |
  `by_col`(df, cols[, w, inplace, pvalue, outvals]) | Function to compute a G_Local statistic on a dataframe
  `calc`() |

  classmethod by_col(df, cols, w=None, inplace=False, pvalue='sim', outvals=None, **stat_kws)

    Function to compute a G_Local statistic on a dataframe

    Parameters:
      df `pandas.DataFrame`

        a pandas dataframe with a geometry column

      cols `str` or `list` of `str`

        name or list of names of columns to use to compute the statistic

      w `W` | `Graph`

        spatial weights instance as W or Graph aligned with the dataframe. If not provided, this is searched for in the dataframe’s metadata

      inplace bool

        a boolean denoting whether to operate on the dataframe inplace or to return a series contaning the results of the computation. If operating inplace, the derived columns will be named ‘column_g_local’

      pvalue `str`

        a string denoting which pvalue should be returned. Refer to the the G_Local statistic’s documentation for available p-values

      outvals `list` of `strings`

        list of arbitrary attributes to return as columns from the G_Local statistic

      **stat_kws `dict`

        options to pass to the underlying statistic. For this, see the documentation for the G_Local statistic.

    Returns:
      `pandas.DataFrame`

        If inplace, None, and operation is conducted on dataframe in memory. Otherwise, returns a copy of the dataframe with the relevant columns attached.

  calc()