Spatial Regression Models (spreg)¶
spreg, short for “spatial regression,” is a python package to estimate simultaneous autoregressive spatial regression models. These models are useful when modeling processes where observations interact with one another. For more information on these models, consult the Spatial Regression short course by Luc Anselin (Spring, 2017), with the Center for Spatial Data Science at the University of Chicago:
Installation¶
spreg is installable using the Python Package Manager, pip. To install:
pip install spreg
Further, all of the stable functionality is also available in PySAL, the Python Spatial Analysis Library. PySAL can be installed using pip or conda:
pip install pysal #or
conda install pysal
API reference¶
Spatial Regression Models¶
These are the standard spatial regression models supported by the spreg package. Each of them contains a significant amount of detail in their docstring discussing how they’re used, how they’re fit, and how to interpret the results.
|
Ordinary least squares with results and diagnostics. |
|
ML estimation of the spatial lag model with all results and diagnostics; [Ans88] |
|
ML estimation of the spatial error model with all results and diagnostics; [Ans88] |
|
Spatial two stage least squares (S2SLS) with results and diagnostics; Anselin (1988) [Ans88] |
|
GMM method for a spatial error model, with results and diagnostics; based on Kelejian and Prucha (1998, 1999) [KP98] [KP99]. |
|
GMM method for a spatial error model with heteroskedasticity, with results and diagnostics; based on [ADKP10], following [Ans11]. |
|
GMM method for a spatial error model with homoskedasticity, with results and diagnostics; based on Drukker et al. |
|
GMM method for a spatial lag and error model with endogenous variables, with results and diagnostics; based on Kelejian and Prucha (1998, 1999) [KP98] [KP99]. |
|
GMM method for a spatial lag and error model with heteroskedasticity and endogenous variables, with results and diagnostics; based on [ADKP10], following [Ans11]. |
|
GMM method for a spatial lag and error model with homoskedasticity and endogenous variables, with results and diagnostics; based on Drukker et al. |
|
GMM method for a spatial error model with endogenous variables, with results and diagnostics; based on Kelejian and Prucha (1998, 1999) [KP98] [KP99]. |
|
GMM method for a spatial error model with heteroskedasticity and endogenous variables, with results and diagnostics; based on [ADKP10], following [Ans11]. |
|
GMM method for a spatial error model with homoskedasticity and endogenous variables, with results and diagnostics; based on Drukker et al. |
|
Two stage least squares with results and diagnostics. |
|
User class for 3SLS estimation |
Regimes Models¶
Regimes models are variants of spatial regression models which allow for structural instability in parameters. That means that these models allow different coefficient values in distinct subsets of the data.
|
Ordinary least squares with results and diagnostics. |
|
ML estimation of the spatial lag model with regimes (note no consistency checks, diagnostics or constants added) [Ans88]. |
|
ML estimation of the spatial error model with regimes (note no consistency checks, diagnostics or constants added); Anselin (1988) [Anselin1988] |
|
Spatial two stage least squares (S2SLS) with regimes; [Ans88] |
|
GMM method for a spatial error model with regimes, with results and diagnostics; based on Kelejian and Prucha (1998, 1999) [KP98] [KP99]. |
|
GMM method for a spatial error model with heteroskedasticity and regimes; based on Arraiz et al [ADKP10], following Anselin [Ans11]. |
|
GMM method for a spatial error model with homoskedasticity, with regimes, results and diagnostics; based on Drukker et al. |
|
GMM method for a spatial lag and error model with regimes and endogenous variables, with results and diagnostics; based on Kelejian and Prucha (1998, 1999) [KP98] [KP99]. |
|
GMM method for a spatial lag and error model with homoskedasticity, regimes and endogenous variables, with results and diagnostics; based on Drukker et al. |
|
GMM method for a spatial lag and error model with heteroskedasticity, regimes and endogenous variables, with results and diagnostics; based on Arraiz et al [ADKP10], following Anselin [Ans11]. |
|
GMM method for a spatial error model with regimes and endogenous variables, with results and diagnostics; based on Kelejian and Prucha (1998, 1999) [KP98] [KP99]. |
|
GMM method for a spatial error model with homoskedasticity, regimes and endogenous variables. |
|
GMM method for a spatial error model with heteroskedasticity, regimes and endogenous variables, with results and diagnostics; based on Arraiz et al [ADKP10], following Anselin [Ans11]. |
Diagnostics¶
Diagnostic tests are useful for identifying model fit, sufficiency, and specification correctness.
Calculates the f-statistic and associated p-value of the regression. |
|
|
Calculates the t-statistics (or z-statistics) and associated p-values. |
|
Calculates the R^2 value for the regression. |
Calculates the adjusted R^2 value for the regression. |
|
Calculates the standard error of the regression coefficients. |
|
Calculates the log-likelihood value for the regression. |
|
Calculates the Akaike Information Criterion. |
|
Calculates the Schwarz Information Criterion. |
|
Calculates the multicollinearity condition index according to Belsey, Kuh and Welsh (1980) [BKW05]. |
|
Jarque-Bera test for normality in the residuals. |
|
|
Calculates the Breusch-Pagan test statistic to check for heteroscedasticity. |
Calculates the White test to check for heteroscedasticity. |
|
|
Calculates the Koenker-Bassett test statistic to check for heteroscedasticity. |
Calculates the variance inflation factor for each independent variable. |
|
|
Likelihood ratio test statistic [Gre03] |
|
Lagrange Multiplier tests. |
|
Moran’s I for spatial autocorrelation in residuals from OLS regression |
|
Moran’s I test of spatial autocorrelation for IV estimation. |
|
Utility to compute standard error, t and p-value |
|
Likelihood Ratio test on off-diagonal elements of Sigma |
|
Lagrange Multiplier test on off-diagonal elements of Sigma |
|
Standard errors, t-test and p-value for lambda in SUR Error ML |
|
Lagrange Multiplier test on error spatial autocorrelation in SUR |
|
Lagrange Multiplier test on lag spatial autocorrelation in SUR |
References¶
- Aka74
Hirotugu Akaike. A new look at the statistical model identification. IEEE transactions on automatic control, 19(6):716–723, 1974.
- Ans88
Luc Anselin. Spatial Econometrics: Methods and Models. Kluwer, Dordrecht, 1988.
- Ans11
Luc Anselin. GMM estimation of spatial error autocorrelation with and without heteroskedasticity. Technical Report, GeoDa Center for Geospatial Analysis and Computation, 2011.
- ABFY96
Luc Anselin, Anil K Bera, Raymond Florax, and Mann J Yoon. Simple diagnostic tests for spatial dependence. Regional science and urban economics, 26(1):77–104, 1996.
- AK97
Luc Anselin and Harry H Kelejian. Testing for spatial error autocorrelation in the presence of endogenous regressors. International Regional Science Review, 20(1-2):153–182, 1997.
- ADKP10
Irani Arraiz, David M. Drukker, Harry H. Kelejian, and Ingmar R. Prucha. A spatial Cliff-Ord-type model with heteroskedastic innovations: Small and large sample results. Journal of Regional Science, 50(2):592–614, 2010. doi:10.1111/j.1467-9787.2009.00618.x.
- BKW05
David A Belsley, Edwin Kuh, and Roy E Welsch. Regression diagnostics: Identifying influential data and sources of collinearity. Volume 571. John Wiley & Sons, 2005.
- BP79
Trevor S Breusch and Adrian R Pagan. A simple test for heteroscedasticity and random coefficient variation. Econometrica: Journal of the Econometric Society, pages 1287–1294, 1979.
- DEP13
David M Drukker, Peter Egger, and Ingmar R Prucha. On two-step estimation of a spatial autoregressive model with autoregressive disturbances and endogenous regressors. Econometric Reviews, 32(5-6):686–733, 2013.
- DPR13
David M. Drukker, Ingmar R. Prucha, and Rafal Raciborski. A command for estimating spatial-autoregressive models with spatial-autoregressive disturbances and additional endogenous variables. The Stata Journal, 13(2):287–301, 2013. URL: https://journals.sagepub.com/doi/abs/10.1177/1536867X1301300203.
- Gre03
William H Greene. Econometric analysis. Pearson Education India, 2003.
- JB80
Carlos M Jarque and Anil K Bera. Efficient tests for normality, homoscedasticity and serial independence of regression residuals. Economics letters, 6(3):255–259, 1980.
- KP99
H H Kelejian and I R Prucha. A generalized moments estimator for the autoregressive parameter in a spatial model. Int. Econ. Rev., 40:509–534, 1999.
- KP98
Harry H Kelejian and Ingmar R Prucha. A generalized spatial two-stage least squares procedure for estimating a spatial autoregressive model with autoregressive disturbances. J. Real Estate Fin. Econ., 17(1):99–121, 1998.
- KBJ82
Roger Koenker and Gilbert Bassett Jr. Robust tests for heteroscedasticity based on regression quantiles. Econometrica: Journal of the Econometric Society, pages 43–61, 1982.
- S+78
Gideon Schwarz and others. Estimating the dimension of a model. The annals of statistics, 6(2):461–464, 1978.
- Whi80
Halbert White. A heteroskedasticity-consistent covariance matrix estimator and a direct test for heteroskedasticity. Econometrica: Journal of the Econometric Society, pages 817–838, 1980.