--- id: spglm version: "1.1.0" license: BSD 3-Clause license_treatment: permissive maintenance: active --- # spglm — Sparse Generalized Linear Models License: permissive · Maintenance: active · Downloads: 103.0K/mo ## What it is and what it does spglm is a lightweight, sparse-compatible implementation of generalized linear modeling adapted from Statsmodels. It provides estimation of Gaussian, Poisson, QuasiPoisson, and Logistic regression models using iteratively weighted least squares (IWLS), designed specifically for the sparse design matrices that arise in spatial interaction and geographic weighted regression problems. The package trades some diagnostic breadth for computational efficiency and sparse-matrix support, making it a specialized tool for spatial statistics rather than a general-purpose GLM framework. The package depends on numpy, scipy, libpysal, and spreg, and is maintained as part of the PySAL ecosystem. It supports Python 3.9 and later and installs with low friction. The implementation solves least-squares normal equations directly rather than using pseudo-inverse methods, which the authors note is less robust for ill-conditioned data; for more comprehensive GLM functionality they recommend the original Statsmodels package. Use it for: - Fit Poisson or Logistic models to sparse spatial interaction matrices in transportation or migration studies. - Estimate geographic weighted regression (GWR) components with sparse design matrices. - Perform QuasiPoisson regression when overdispersion is present in count data. - Compute GLM diagnostics (residuals, fitted values, deviance) for sparse regression problems. - Build spatial statistical models as part of a PySAL-based analysis pipeline. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Fits Gaussian, Poisson, QuasiPoisson, and Logistic generalized linear models using iteratively weighted least squares, with full support for sparse design matrices. Yes, if you are working with sparse generalized linear models in a spatial statistics context (especially within PySAL). Install with caution if you need robust estimation of ill-conditioned data—the package's direct normal-equation solver is not the most numerically stable approach; Statsmodels is better for that. No known vulnerabilities and active maintenance make it a safe dependency. ## Install pip install spglm uv add spglm poetry add spglm ## Installing spglm Before you install: Low friction: pure Python wheel with four standard dependencies (numpy, scipy, libpysal, spreg). Actively maintained as of July 2026 with no known vulnerabilities. License in practice: BSD 3-Clause permissive license allows commercial and private use with attribution; no restrictions on derivative works. Quickstart: pip install spglm import spglm from spglm.glm import GLM model = GLM(y, X, family=spglm.family.Gaussian()) results = model.fit() Requires Python 3.9 or later. Verify before relying: - Whether the package is actively used in production spatial analysis workflows beyond PySAL ecosystem. - Performance characteristics and scalability limits for very large sparse matrices. - Availability and completeness of documentation beyond the homepage. ## Package facts - License: BSD 3-Clause (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 103.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags sparse generalized linear models, GLM with sparse matrices, poisson regression sparse, logistic regression sparse, spatial statistics regression, IWLS estimation, quasipoisson regression, spatial-statistics, sparse-matrices, glm [View on SkillFed](https://skillfed.io/packages/spglm) · [View on PyPI](https://pypi.org/project/spglm/)