Skip to main content

neighbayes

Continuous Integration codecov

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

neighbayes-0.0.0.tar.gz (5.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neighbayes-0.0.0-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

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

Hashes for neighbayes-0.0.0.tar.gz
Algorithm Hash digest
SHA256 bc78ccb7de851d6fb17f544cfc47f0053cca4c13f1a5a8545bf98cf40af7504d
MD5 aaac8a431cbbe879064605503ce8bb2a
BLAKE2b-256 23b70b57b5f95a565918d7203c533f7cd5bbdcc49e560ef7d0913e33d7928258

See more details on using hashes here.

Provenance

The following attestation bundles were made for neighbayes-0.0.0.tar.gz:

Publisher: upload_package.yml on knaaptime/neighbayes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for neighbayes-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20c226cdacbe6196d8fc9cf0decadd1f326d3e2c493fd6d9923ec472b79fdbff
MD5 3351e1d51d5b62e81856b925bc47b81c
BLAKE2b-256 9c3644050e234fda8da1d83ebf1844b4fcd02dc750daf9e07c6b26ca9d2ce5f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for neighbayes-0.0.0-py3-none-any.whl:

Publisher: upload_package.yml on knaaptime/neighbayes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page