neighbayes
neighbayes is a Python package for Bayesian estimation of spatial econometric models. Every model is a class, and specified with a Wilkinson formula via
formulaic and a PySAL
Graph
(or any scipy.sparse matrix) for the spatial weights $W$; fit() returns an
arviz.InferenceData, so the standard posterior tooling (az.plot_trace,
az.compare, az.loo) works without translation (though exercise caution as WAIC/LOO diagnostics aren't valid for spatial models).
import libpysal
from neighbayes.dgp import simulate_sar
from neighbayes.models import OLS, SAR
gdf = simulate_sar(n=400, beta=[1, 0.4, 2.5], rho=0.6, create_gdf=True)
G = libpysal.graph.Graph.build_contiguity(gdf).transform("r")
form = "y ~ -1 + X_0 + X_1 + X_2"
# start with a baseline OLS and test the residuals for spatial dependence
ols = OLS(formula=form, W=G, data=gdf)
ols.fit()
print(ols.spatial_diagnostics_decision(format="ascii"))
# the diagnostics point to SAR here, so fit it and decompose the spillovers
sar = SAR(formula=form, W=G, data=gdf)
sar.fit(draws=2000, chains=4, random_seed=42)
sar.summary()
sar.spatial_effects()
neighbayes provides roughly fifty model classes behind one formula interface, each
with a matching simulator in neighbayes.dgp. Every fit comes with Bayesian LM
diagnostics (with a decision tree for specification search) and posterior decompositions
of direct, indirect, and total effects. Every model (almost) has a custom Gibbs sampler
for better mixing (with both numby and jax implementations), but can fall back to PyMC if requested.
Installation
conda install -c conda-forge neighbayes # or: pip install neighbayes
Requires Python 3.12+. The installation guide covers development installs and the optional JAX backend.
Documentation
Model-by-model user guides, the diagnostics battery, effects interpretation, and the API reference are at pysal.org/neighbayes.
Validation
Every model includes thorough parameter recovery tests, and samplers have been validated against maximum likelihood estimators as well as published results (see docs).
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file neighbayes-0.0.0.tar.gz.
File metadata
- Download URL: neighbayes-0.0.0.tar.gz
- Upload date:
- Size: 5.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc78ccb7de851d6fb17f544cfc47f0053cca4c13f1a5a8545bf98cf40af7504d
|
|
| MD5 |
aaac8a431cbbe879064605503ce8bb2a
|
|
| BLAKE2b-256 |
23b70b57b5f95a565918d7203c533f7cd5bbdcc49e560ef7d0913e33d7928258
|
Provenance
The following attestation bundles were made for neighbayes-0.0.0.tar.gz:
Publisher:
upload_package.yml on knaaptime/neighbayes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neighbayes-0.0.0.tar.gz -
Subject digest:
bc78ccb7de851d6fb17f544cfc47f0053cca4c13f1a5a8545bf98cf40af7504d - Sigstore transparency entry: 2713318224
- Sigstore integration time:
-
Permalink:
knaaptime/neighbayes@e22ada19ffce938aee3dc63d922596f656a43db8 -
Branch / Tag:
refs/tags/v0.0.0 - Owner: https://github.com/knaaptime
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
upload_package.yml@e22ada19ffce938aee3dc63d922596f656a43db8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file neighbayes-0.0.0-py3-none-any.whl.
File metadata
- Download URL: neighbayes-0.0.0-py3-none-any.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20c226cdacbe6196d8fc9cf0decadd1f326d3e2c493fd6d9923ec472b79fdbff
|
|
| MD5 |
3351e1d51d5b62e81856b925bc47b81c
|
|
| BLAKE2b-256 |
9c3644050e234fda8da1d83ebf1844b4fcd02dc750daf9e07c6b26ca9d2ce5f6
|
Provenance
The following attestation bundles were made for neighbayes-0.0.0-py3-none-any.whl:
Publisher:
upload_package.yml on knaaptime/neighbayes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neighbayes-0.0.0-py3-none-any.whl -
Subject digest:
20c226cdacbe6196d8fc9cf0decadd1f326d3e2c493fd6d9923ec472b79fdbff - Sigstore transparency entry: 2713318430
- Sigstore integration time:
-
Permalink:
knaaptime/neighbayes@e22ada19ffce938aee3dc63d922596f656a43db8 -
Branch / Tag:
refs/tags/v0.0.0 - Owner: https://github.com/knaaptime
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
upload_package.yml@e22ada19ffce938aee3dc63d922596f656a43db8 -
Trigger Event:
push
-
Statement type: