mgwr
multiscale geographically weighted regression
What it is and what it does
MGWR is a Python implementation of multiscale geographically weighted regression, a statistical method for modeling spatial relationships where regression coefficients vary across geographic locations. It extends traditional GWR by allowing different spatial scales (bandwidths) for different covariates, capturing the idea that some processes operate at finer or coarser geographic resolutions than others.
The package handles model calibration for Gaussian, Poisson, and binomial probability distributions; bandwidth selection via golden section or equal interval search; spatial prediction; and model diagnostics including multiple hypothesis test correction and local collinearity assessment. It builds on sparse generalized linear modeling (spglm) and integrates with the PySAL ecosystem (libpysal, spreg). Parallel computing is available for computationally intensive GWR and MGWR workflows.
Use it for:
- Analyze how housing price determinants vary geographically—e.g., proximity to transit matters more in urban areas than rural ones.
- Model disease incidence or health outcomes across regions where risk factors operate at different spatial scales.
- Estimate local effects of environmental variables (pollution, temperature) on ecological or agricultural outcomes.
- Conduct spatial heterogeneity tests to determine whether a global regression model is appropriate or if local variation is significant.
- Generate spatially-varying predictions and confidence intervals for regression surfaces across a study region.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Calibrates multiscale and traditional geographically weighted regression (GWR/MGWR) models to analyze spatial heterogeneity in regression relationships across geographic regions.
Yes. The package is production-stable, actively maintained, has no known vulnerabilities, and low installation friction. It fills a specialized but well-established niche in spatial statistics. Install it if you need to model geographic variation in regression relationships; skip it if your analysis is non-spatial or you need only global regression coefficients.
Install
mgwr on PyPI
pip
pip install mgwruv
uv add mgwrpoetry
poetry add mgwrInstalling mgwr
Before you install
Low friction installation with a pure-Python wheel. The package depends on five established scientific libraries (scipy, numpy, libpysal, spglm, spreg) that are well-maintained and widely available. Maintenance is active with recent commits and production-stable status.
License in practice
Licensed under 3-Clause BSD (permissive), so you can use, modify, and distribute the package freely in both open-source and commercial projects with minimal restrictions.
Quickstart
pip install mgwr
import mgwr.gwr as gwr
from mgwr.sel_bw import Sel_BW
# Prepare data: y (dependent), X (independent), coords (lat/lon)
bw = Sel_BW(coords, y, X).search()
model = gwr.GWR(coords, y, X, bw=bw).fit()
Verify before relying
- Whether parallel computing support requires additional setup or dependencies beyond the listed runtime packages.
- Performance characteristics and scalability limits for large spatial datasets.
- Availability and completeness of documentation for model diagnostics and covariate-specific inference workflows.
Package facts
| License | 3-Clause BSD (permissive) |
| Python support | supports the current Python release (>3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — scipy, numpy, libpysal, spglm, spreg |
| Maintenance | actively maintained — 951 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 101,811/month — #12,914 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mgwr-2.2.1-py3-none-any.whl
Keywords: spatial, statistics
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
spglmFits Gaussian, Poisson, QuasiPoisson, and…
permissive · top 15,000 on PyPI
spintSpInt calibrates spatial interaction models…
permissive · top 15,000 on PyPI
spregspreg estimates simultaneous autoregressive…
permissive · top 15,000 on PyPI
gmrGaussian Mixture Models for clustering and…
permissive · top 15,000 on PyPI
pysalPySAL is a meta-package that bundles 29 spatial…
permissive · top 15,000 on PyPI
glumglum is a high-performance Python library for…
permissive · top 15,000 on PyPI
dask-glmDistributed generalized linear model fitting…
permissive · top 15,000 on PyPI
statsmodelsstatsmodels provides statistical models,…
permissive · top 1,000 on PyPI
betacalFits beta calibration models to classifier…
permissive · top 15,000 on PyPI
gstoolsGSTools provides geostatistical tools for…
copyleft · top 15,000 on PyPI