Multiscale Geographically Weighted Regression (MGWR)

mgwr is a Python implementation of multiscale geographically weighted regression for investigating process spatial heterogeneity and scale. It incorporates the widely used approach to modeling process spatial heterogeneity - Geographically Weighted Regression (GWR) as well as the newly proposed approach - Multiscale GWR (MGWR) which relaxes the assumption that all of the processes being modeled operate at the same spatial scale. Inferences are available for both approaches.

Installation

mgwr supports python 3.5 and 3.6 only. Please make sure that you are operating in a python 3 environment.

Installing released version

mgwr is available on the Python Package Index. Therefore, you can either install directly with pip from the command line:

pip install -U mgwr

or download the source distribution (.tar.gz) and decompress it to your selected destination. Open a command shell and navigate to the decompressed folder. Type:

pip install .

Installing development version

Potentially, you might want to use the newest features in the development version of mgwr on github - pysal/mgwr while have not been incorporated in the Pypi released version. You can achieve that by installing pysal/mgwr by running the following from a command shell:

pip install https://github.com/pysal/mgwr/archive/master.zip

You can also fork the pysal/mgwr repo and create a local clone of your fork. By making changes to your local clone and submitting a pull request to pysal/mgwr, you can contribute to the mgwr development.

API reference

GWR Model Estimation and Inference

mgwr.gwr.GWR(coords, y, X, bw[, family, …])

Geographically weighted regression.

mgwr.gwr.GWRResults(model, params, predy, S, …)

Basic class including common properties for all GWR regression models

mgwr.gwr.GWRResultsLite(model, resid, influ, …)

Lightweight GWR that computes the minimum diagnostics needed for bandwidth selection

MGWR Estimation and Inference

mgwr.gwr.MGWR(coords, y, X, selector[, …])

Multiscale GWR estimation and inference.

mgwr.gwr.MGWRResults(model, params, predy, …)

Class including common properties for a MGWR model.

Utility Functions

Kernel Specification

mgwr.kernels.Kernel(i, data[, bw, fixed, …])

GWR kernel function specifications.

mgwr.kernels.local_cdist(coords_i, coords, …)

Compute Haversine (spherical=True) or Euclidean (spherical=False) distance for a local kernel.

Bandwidth Selection

mgwr.sel_bw.Sel_BW(coords, y, X_loc[, …])

Select bandwidth for kernel

Visualization

utils.shift_colormap(cmap[, start, …])

Function to offset the “center” of a colormap.

utils.truncate_colormap(cmap[, minval, …])

Function to truncate a colormap by selecting a subset of the original colormap’s values

utils.compare_surfaces(\*args, \*\*kwargs)

References

BKW80

D. A. Belsey, E. Kuh, and R. E. Welsch. Regression Diagnostics: Identifying Influential Data and Sources of Collinearity. Wiley, New York, 1980.

BFC99

Chris Brunsdon, A Stewart Fotheringham, and Martin Charlton. Some notes on parametric significance tests for geographically weighted regression. Journal of Regional Science, 39(3):497–524, 1999.

BFC08

Chris Brunsdon, A Stewart Fotheringham, and Martin Charlton. Geographically weighted regression: a method for exploring spatial nonstationarity. Encyclopedia of Geographic Information Science, pages 558, 2008.

dSF16

Alan Ricardo da Silva and A. Stewart Fotheringham. The multiple testing issue in geographically weighted regression. Geographical Analysis, 48(3):233–247, 2016. URL: https://onlinelibrary.wiley.com/doi/abs/10.1111/gean.12084, arXiv:https://onlinelibrary.wiley.com/doi/pdf/10.1111/gean.12084, doi:10.1111/gean.12084.

FB99

A Stewart Fotheringham and Chris Brunsdon. Local forms of spatial analysis. Geographical Analysis, 31(4):340–358, 1999.

FBC02

A. Stewart Fotheringham, Chris Brunsdon, and Martin Charlton. Geographically Weighted Regression: The Analysis of Spatially Varying Relationships. John Wiley & Sons, February 2002. ISBN 978-0-470-85525-6.

FO16

A. Stewart Fotheringham and Taylor M. Oshan. Geographically weighted regression and multicollinearity: dispelling the myth. Journal of Geographical Systems, 18(4):303–329, 2016. URL: http://dx.doi.org/10.1007/s10109-016-0239-5, doi:10.1007/s10109-016-0239-5.

FYK17

A. Stewart Fotheringham, Wenbai Yang, and Wei Kang. Multiscale geographically weighted regression (mgwr). Annals of the American Association of Geographers, 107(6):1247–1265, 2017. URL: http://dx.doi.org/10.1080/24694452.2017.1352480, arXiv:http://dx.doi.org/10.1080/24694452.2017.1352480, doi:10.1080/24694452.2017.1352480.

HFCC10

P. Harris, A. S. Fotheringham, R. Crespo, and M. Charlton. The Use of Geographically Weighted Regression for Spatial Prediction: An Evaluation of Models Using Simulated Data Sets. Mathematical Geosciences, 42(6):657–680, June 2010. URL: http://link.springer.com/article/10.1007/s11004-010-9284-7, doi:10.1007/s11004-010-9284-7.

NFBC05

T Nakaya, AS Fotheringham, Chris Brunsdon, and Martin Charlton. Geographically weighted poisson regression for disease association mapping. Statistics in Medicine, 24(17):2695–2717, 2005.

OF17

Taylor M. Oshan and A. Stewart Fotheringham. A Comparison of Spatially Varying Regression Coefficient Estimates Using Geographically Weighted and Spatial-Filter-Based Techniques: A Comparison of Spatially Varying Regression. Geographical Analysis, June 2017. URL: http://doi.wiley.com/10.1111/gean.12133, doi:10.1111/gean.12133.

Whe07

David C. Wheeler. Diagnostic Tools and a Remedial Method for Collinearity in Geographically Weighted Regression. Environment and Planning A, 39(10):2464–2481, October 2007. URL: http://epn.sagepub.com/content/39/10/2464, doi:10.1068/a38325.

YFL+19

Hanchen Yu, Alexander Stewart Fotheringham, Ziqi Li, Taylor Oshan, Wei Kang, and Levi John Wolf. Inference in multiscale geographically weighted regression. Geographical Analysis, 2019. URL: https://onlinelibrary.wiley.com/doi/abs/10.1111/gean.12189, arXiv:https://onlinelibrary.wiley.com/doi/pdf/10.1111/gean.12189, doi:10.1111/gean.12189.