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:
- connectivity
W|Graph spatial weights instance as W or Graph aligned with y
- inference
python:str describes type of inference to be used. options are “chi-square” or “permutation” methods.
- connectivity
- Attributes:
- Hi
numpyarray Array of LOSH values for each spatial unit.
- ylag
numpyarray Spatially lagged y values.
- yresid
numpyarray Spatially lagged residual values.
- VarHi
numpyarray Variance of Hi.
- pval
numpyarray P-values for inference based on either “chi-square” or “permutation” methods.
- Hi
Methods
__init__([connectivity, inference])Initialize a losh estimator
fit(y[, a])get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
set_fit_request(*[, a])Request metadata passed to the
fitmethod.set_params(**params)Set the parameters of this estimator.
- fit(y, a=2)[source]¶
- Parameters:
- y
numpy.ndarray array containing continuous data
- a
python:int residual multiplier. Default is 2 in order to generate a variance measure. Users may use 1 for absolute deviations.
- y
- Returns:
thefitted 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)
- set_fit_request(*, a: bool | None | str = '$UNCHANGED$') LOSH¶
Request metadata passed to the
fitmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.- Parameters:
- a
python:str,python:True,python:False, orpython:None, default=sklearn.utils.metadata_routing.UNCHANGED Metadata routing for
aparameter infit.
- a
- Returns:
- self
object The updated object.
- self