spreg.diagnostics_probit.sp_tests

spreg.diagnostics_probit.sp_tests(regprob=None, obj_list=None)[source]

Calculates tests for spatial dependence in Probit models

Parameters:
regprobregression object from spreg

output instance from a probit model

obj_listlist

list of regression elements from both libpysal and statsmodels’ ProbitResults The list should be such as: [libpysal.weights, ProbitResults.fittedvalues, ProbitResults.resid_response, ProbitResults.resid_generalized]

Returns:
tuple with LM_Err, moran, ps as 2x1 arrays with statistic and p-value

LM_Err: Pinkse moran : Kelejian-Prucha generalized Moran ps : Pinkse-Slade

Examples

The results of this function will be automatically added to the output of the probit model if using spreg. If using the Probit estimator from statsmodels, the user can call the function with the obj_list argument. The argument obj_list should be a list with the following elements, in this order: [libpysal.weights, ProbitResults.fittedvalues, ProbitResults.resid_response, ProbitResults.resid_generalized] The function will then return and print the results of the spatial diagnostics.

>>> import libpysal
>>> import statsmodels.api as sm
>>> import geopandas as gpd
>>> from spreg.diagnostics_probit import sp_tests
>>> columb = libpysal.examples.load_example('Columbus')
>>> dfs = gpd.read_file(columb.get_path("columbus.shp"))
>>> w = libpysal.weights.Queen.from_dataframe(dfs)
>>> w.transform='r'
>>> y = (dfs["CRIME"] > 40).astype(float)
>>> X = dfs[["INC","HOVAL"]]
>>> X = sm.add_constant(X)
>>> probit_mod = sm.Probit(y, X)
>>> probit_res = probit_mod.fit(disp=False)
>>> LM_err, moran, ps = sp_tests(obj_list=[w, probit_res.fittedvalues, probit_res.resid_response, probit_res.resid_generalized])
PROBIT MODEL DIAGNOSTICS FOR SPATIAL DEPENDENCE
TEST                              DF         VALUE           PROB
Kelejian-Prucha (error)           1          1.721           0.0852
Pinkse (error)                    1          3.132           0.0768
Pinkse-Slade (error)              1          2.558           0.1097