esda.LOSH

class esda.LOSH(connectivity=None, inference=None)[source]

Local spatial heteroscedasticity (LOSH)

__init__(connectivity=None, inference=None)[source]

Initialize a losh estimator

Parameters:
connectivityscipy.sparse matrix object

the connectivity structure describing the relationships between observed units.

inferencestr

describes type of inference to be used. options are “chi-square” or “permutation” methods.

Attributes:
Hinumpy array

Array of LOSH values for each spatial unit.

ylagnumpy array

Spatially lagged y values.

yresidnumpy array

Spatially lagged residual values.

VarHinumpy array

Variance of Hi.

pvalnumpy array

P-values for inference based on either “chi-square” or “permutation” methods.

Methods

__init__([connectivity, inference])

Initialize a losh estimator

fit(y[, a])

Parameters:

get_params([deep])

Get parameters for this estimator.

set_params(**params)

Set the parameters of this estimator.

fit(y, a=2)[source]
Parameters:
ynumpy.ndarray

array containing continuous data

aint

residual multiplier. Default is 2 in order to generate a variance measure. Users may use 1 for absolute deviations.

Returns:
the fitted estimator.

Notes

Technical details and derivations can be found in [].

Examples

>>> import libpysal
>>> w = libpysal.io.open(libpysal.examples.get_path("stl.gal")).read()
>>> f = libpysal.io.open(libpysal.examples.get_path("stl_hom.txt"))
>>> y = np.array(f.by_col['HR8893'])
>>> from esda import losh
>>> ls = losh(connectivity=w, inference="chi-square").fit(y)
>>> np.round(ls.Hi[0], 3)
>>> np.round(ls.pval[0], 3)

Boston housing data replicating R spdep::LOSH() >>> import libpysal >>> import geopandas as gpd >>> boston = libpysal.examples.load_example(‘Bostonhsg’) >>> boston_ds = gpd.read_file(boston.get_path(‘boston.shp’)) >>> w = libpysal.weights.Queen.from_dataframe(boston_ds) >>> ls = losh(connectivity=w, inference=”chi-square”).fit(boston[‘NOX’]) >>> np.round(ls.Hi[0], 3) >>> np.round(ls.VarHi[0], 3)