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 DataTree (an xarray.DataTree), so the standard posterior tooling (az.plot_trace_dist, az.compare, az.loo) works without translation. The stored pointwise log-likelihood is each observation's density given all the others, so az.loo is a leave-one-out estimate for spatial models too (Bürkner, Gabry & Vehtari 2021); robust models with fixed effects or a lagged outcome, and robust Tobits, have no such term and warn.

import libpysal
from neighbayes.dgp import simulate_sar
from neighbayes.models import OLS, SAR

gdf = simulate_sar(n_side=20, 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.impacts()

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 numpy 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).

Metadata

Release files for neighbayes 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for neighbayes 0.1.0
File Size Uploaded Provenance Actions
neighbayes-0.1.0.tar.gz 4.3 MB With provenance Details for neighbayes-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for neighbayes 0.1.0
File Interpreter ABI Platform Actions
neighbayes-0.1.0-py3-none-any.whl Python 3 none any Details for neighbayes-0.1.0-py3-none-any.whl

Total release size: 5.8 MB

Release files / neighbayes-0.1.0.tar.gz

Download URL neighbayes-0.1.0.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
574a626fdb816607cc3d0385da5a247e669e91f7f519dceb7b903c1efd45bbdd
BLAKE2b-256 checksum
How to use checksums
5ce6320b431a4f4d665f2d057bc1313eb6be5e8dac2e5b1ea8e154fe44a50bbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / neighbayes-0.1.0-py3-none-any.whl

Download URL neighbayes-0.1.0-py3-none-any.whl
Size 1.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
61584e5211d125ce133c6f0d6a2f4c8b9868de5b5866521c5bbb042013164913
BLAKE2b-256 checksum
How to use checksums
760a8b15120dface900e22f3b454884f46b601fdfc2f27645ef89179b66d6bce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for neighbayes 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for neighbayes-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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