API reference¶
Base Classes¶
|
Base class for Bayesian spatial regression models. |
|
Base class for static spatial panel models with FE transforms. |
Cross Sectional Spatial Models¶
|
Bayesian ordinary least squares cross-sectional regression. |
|
Bayesian Spatial Autoregressive (Spatial Lag) model. |
|
Bayesian Spatial Error Model. |
|
Bayesian SLX (Spatial Lag X) model. |
|
Bayesian Spatial Durbin Model. |
|
Bayesian Spatial Durbin Error Model. |
Panel Spatial Models¶
|
Bayesian pooled and fixed-effects linear panel regression. |
|
Bayesian spatial-lag panel regression. |
|
Bayesian spatial-error panel regression. |
|
Bayesian spatial Durbin panel regression. |
|
Bayesian spatial Durbin error panel regression. |
|
Bayesian SLX panel regression. |
Panel Spatial Models (Random Effects)¶
|
Bayesian random effects panel regression (non-spatial). |
|
Bayesian spatial lag panel model with unit random effects. |
|
Bayesian spatial error panel model with unit random effects. |
|
Bayesian spatial Durbin error panel model with unit random effects. |
Dynamic Panel Spatial Models¶
|
|
|
|
|
|
|
|
|
|
|
|
|
Non-Linear Spatial Models¶
|
Bayesian spatial probit with regional random effects. |
|
Bayesian spatial autoregressive Tobit model. |
|
Bayesian spatial error Tobit model. |
|
Bayesian spatial Durbin Tobit model. |
Panel Spatial Models (Tobit)¶
|
|
|
Flow Models¶
|
Abstract base class for Bayesian spatial flow regression models. |
|
Non-spatial Bayesian OD-flow gravity model (independence baseline). |
|
Non-spatial Bayesian OD-flow Poisson gravity model (count baseline). |
|
Bayesian SAR flow model with three free spatial autoregressive parameters. |
|
Bayesian separable SAR flow model with ρ_w = −ρ_d · ρ_o. |
|
Bayesian SAR flow model with a Poisson observation distribution. |
|
Bayesian separable SAR flow model with a Poisson observation distribution. |
|
Bayesian spatial-error flow model with three free spatial parameters. |
|
Bayesian separable spatial-error flow model with \(\lambda_w = -\lambda_d \lambda_o\). |
Panel Flow Models¶
|
Abstract base class for balanced panel spatial flow models. |
|
Non-spatial Bayesian OD-flow gravity model for balanced panel data. |
|
Non-spatial Bayesian OD-flow Poisson gravity model for balanced panel data. |
|
Panel spatial-lag origin-destination flow model with unrestricted dependence. |
|
Panel separable spatial-lag flow model with \(\rho_w = -\rho_d \rho_o\). |
|
Panel Poisson spatial-lag flow model with unrestricted dependence. |
|
Panel separable Poisson spatial-lag flow model. |
|
Panel spatial-error flow model with three free spatial parameters. |
|
Panel separable spatial-error flow model with \(\lambda_w = -\lambda_d \lambda_o\). |
Bayesian Diagnostics¶
|
Container for Bayesian LM test results. |
|
Bayesian LM test for omitted spatial lag (SAR) model. |
|
Bayesian LM test for omitted spatial error (SEM) model. |
|
Bayesian LM test for WX coefficients (H₀: γ = 0 | SAR). |
|
Bayesian joint LM test for SDM (H₀: ρ = 0 AND γ = 0 | OLS). |
Bayesian joint LM test for SDEM (H₀: λ = 0 AND γ = 0 | OLS). |
|
Bayesian LM-Error test from a SAR posterior (H₀: λ = 0 | SAR). |
|
|
Bayesian LM-Error test from an SDM posterior (H₀: λ = 0 | SDM). |
|
Bayesian LM-Lag test from an SDEM posterior (H₀: ρ = 0 | SDEM). |
|
Bayesian LM test for WX coefficients in SEM (H₀: γ = 0 | SEM). |
|
Bayesian robust LM-Lag test (H₀: ρ = 0, robust to local λ). |
Bayesian robust LM-Error test (H₀: λ = 0, robust to local ρ). |
|
Bayesian robust LM-Lag test in SDM context (H₀: ρ = 0, robust to γ). |
|
|
Bayesian robust LM-WX test (H₀: γ = 0, robust to ρ). |
Bayesian robust LM-Error test in SDEM context (H₀: λ = 0, robust to γ). |
|
Bayesian robust LM-Error test in SAR context (H₀: λ = 0 | SAR). |
|
Bayesian robust LM-Error test in SDM context (H₀: λ = 0 | SDM). |
|
Bayesian robust LM-Lag test in SDEM context (H₀: ρ = 0 | SDEM). |
|
Bayesian robust LM-Lag test in SEM context (H₀: ρ = 0 | SEM). |
|
Bayesian robust LM-WX test in SEM context (H₀: γ = 0 | SEM). |
Panel Bayesian LM Tests¶
|
Bayesian panel LM test for omitted spatial lag (H₀: ρ = 0). |
|
Bayesian panel LM test for omitted spatial error (H₀: λ = 0). |
Bayesian panel robust LM-Lag test (H₀: ρ = 0, robust to λ). |
|
Bayesian panel robust LM-Error test (H₀: λ = 0, robust to ρ). |
|
|
Bayesian panel LM test for WX coefficients (H₀: γ = 0). |
Bayesian panel joint LM test for SDM (H₀: ρ = 0 AND γ = 0). |
|
Bayesian panel joint LM test for SDEM (H₀: λ = 0 AND γ = 0). |
|
Panel LM-Error test from an SDM panel posterior (H₀: λ = 0 | SDM). |
|
Panel LM-Lag test from an SDEM panel posterior (H₀: ρ = 0 | SDEM). |
|
Bayesian panel LM test for WX coefficients in SEM (H₀: γ = 0 | SEM). |
|
Bayesian panel robust LM-Lag in SDM context (H₀: ρ = 0 | SLX panel). |
|
Bayesian panel robust LM-WX (H₀: γ = 0 | SAR panel, robust to ρ). |
|
Bayesian panel robust LM-Error in SDEM context (H₀: λ = 0 | SLX panel). |
Flow Bayesian LM Tests¶
|
Bayesian LM test for an omitted destination-side spatial lag. |
|
Bayesian LM test for an omitted origin-side spatial lag (\(H_0\colon \rho_o = 0\)). |
Bayesian LM test for an omitted network spatial lag (\(H_0\colon \rho_w = 0\)). |
|
|
Bayesian LM (WX-style) test for the intra block in an OLSFlow null. |
|
Joint Bayesian LM test for the SARFlow filter (\(H_0\colon \rho_d = \rho_o = \rho_w = 0\)). |
|
Robust Bayesian LM test for \(\rho_d\) adjusting for \((\rho_o, \rho_w)\) nuisance via the Neyman-orthogonal score (Bera and Yoon [1993], Anselin et al. [1996], Doğan et al. [2021]). |
|
Robust Bayesian LM test for \(\rho_o\) adjusting for \((\rho_d, \rho_w)\) nuisance. |
Robust Bayesian LM test for \(\rho_w\) adjusting for \((\rho_d, \rho_o)\) nuisance. |
|
Panel analogue of |
|
Panel analogue of |
|
Panel analogue of |
|
Panel analogue of |
|
Panel analogue of |
Diagnostic Test Suites¶
Pre-bundled collections of LM tests used by model.spatial_diagnostics()
and the decision-tree renderers.
|
Named, immutable registry of Bayesian LM specification tests. |
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
|
Named, immutable registry of Bayesian LM specification tests. |
Bayesian Model Comparison¶
|
Compute all pairwise Bayes factors for a set of Bayesian models. |
|
Convert BIC values to Bayes factors via the BIC-approximation method. |
|
Compile a PyMC model's log-posterior into a callable for bridge sampling. |
|
Compute posterior model probabilities from marginal likelihoods. |
Log-Determinant Methods¶
Method resolution and bound handling¶
Positive-only methods (sparse_spline, grid_mc) auto-restrict the
rho/lambda support to [1e-5, 1.0] when the prior or method default
would otherwise admit negative values. Explicit rho_min/rho_max
overrides still raise.
|
Canonical names for the log-determinant approximation methods. |
|
Resolved logdet method and rho interval used for approximation. |
|
Validate |
|
Resolve method-specific rho bounds from defaults, priors, or overrides. |
Builders¶
|
Return a function (rho) -> pytensor log|I - rho*W| expression. |
|
Return a pure-numpy |
|
Return a vectorized numpy |
Kernel evaluators and approximations¶
|
Eigenvalue-based log|I - rho*W|. |
|
Exact log|I - rho*W| as a pytensor expression. |
|
Evaluate Chebyshev approximation of log|I - rho*W| symbolically. |
|
Cubic spline interpolation of log|I - rho*W|. |
|
Evaluate Barry-Pace trace polynomial approximation of log|I - rho*W| symbolically. |
|
Compute Monte Carlo log-determinant approximation (Barry and Kelley Pace [1999]). |
|
Compute Chebyshev approximation of log|I - rho*W| ([Pace and LeSage, 2004]). |
|
Compute an ILU-based approximate log-determinant grid. |
|
Compute an exact sparse-LU log-determinant grid. |
|
Compute a spline-interpolated log-determinant grid. |
Flow log-determinants¶
|
Differentiable PyTensor log-determinant for the flow SAR model. |
|
Vectorised numpy port of |
|
Estimate tr(W^k) for k=1..miter via Barry-Pace stochastic traces. |
Data Generating Processes¶
Note
The cross-sectional and (scalar) panel DGP simulators accept W
(Graph/sparse/dense) and gdf inputs. You may provide both together;
in that case W is used for simulation and is checked against gdf
for dimensional compatibility (a ValueError is raised when they do
not describe the same number of spatial units).
The flow DGPs below take G (libpysal Graph), gdf, n, and
knn_k instead. All four are optional: when none is supplied the
DGP synthesises a point grid via
synth_point_geodataframe() and builds a
row-standardised KNN graph automatically.
|
Simulate data from SAR DGP |
|
Simulate data from a non-spatial OLS DGP |
|
Simulate data from SEM DGP |
|
Simulate data from SLX DGP |
|
Simulate data from SDM DGP |
|
Simulate data from SDEM DGP |
|
Simulate left-censored SAR Tobit data. |
|
Simulate left-censored SEM Tobit data. |
|
Simulate left-censored SDM Tobit data. |
|
Simulate SpatialProbit-style binary outcome data. |
|
Simulate pooled data compatible with OLSPanelFE model assumptions. |
|
Simulate SAR panel data in time-first stacking order. |
|
Simulate SEM panel data in time-first stacking order. |
|
Simulate SDM panel FE data. |
|
Simulate SDEM panel FE data. |
|
Simulate SLX panel FE data. |
|
Simulate OLS random-effects panel style data. |
|
Simulate SAR random-effects panel style data. |
|
Simulate SEM random-effects panel style data. |
|
Simulate dynamic non-spatial panel FE data. |
|
Simulate dynamic restricted SDM panel FE data. |
|
Simulate dynamic unrestricted SDM panel FE data. |
|
Simulate dynamic SAR panel FE data. |
|
Simulate dynamic SEM panel FE data. |
|
Simulate dynamic SDEM panel FE data. |
|
Simulate dynamic SLX panel FE data. |
|
Simulate left-censored panel SAR FE data. |
|
Simulate left-censored panel SEM FE data. |
Flow Data Generating Processes¶
Each flow DGP accepts n, G, gdf, and knn_k as optional
arguments and (unless gamma_dist=0.0) appends a log_distance
column log(1 + d_{ij}) with default coefficient gamma_dist=-0.5.
The Gaussian flow DGPs (generate_flow_data,
generate_panel_flow_data and their separable variants) default to
distribution="lognormal", returning strictly-positive flows
y = exp(eta) where eta is the latent SAR-filtered linear
predictor (also exposed in the result dict as "eta_vec" /
"eta"). Pass distribution="normal" to recover the legacy
Gaussian-on-y behaviour. The Gaussian-likelihood flow models in
bayespecon.models.flow operate on the latent scale, so fit on
np.log(y) to recover the SAR parameters. The Poisson DGPs are
unchanged.
|
Simulate flow data from a SAR flow model. |
|
Simulate flow data from a separable SAR flow model. |
|
Generate synthetic origin-destination flow count data for a Poisson spatial autoregressive flow model. |
|
Simulate Poisson flow count data from a separable SAR flow model. |
|
Simulate panel flow data from a SAR flow model with unit effects. |
|
Simulate panel flow data from a separable SAR flow model. |
|
Simulate panel Poisson flow data from a spatial autoregressive model. |
Simulate panel Poisson flow data from a separable SAR flow model. |
Graph Utilities¶
|
Combined design matrix for an O-D flow regression. |
|
Build a flow regression design matrix from regional attribute data. |
|
Build a flow design matrix with separate destination and origin data. |
Build all three N×N flow weight matrices from a single Graph. |
|
Build the N×N destination weight matrix \(W_d = I_n \otimes W\). |
|
Build the N×N origin weight matrix \(W_o = W \otimes I_n\). |
|
Build the N×N network weight matrix \(W_w = W \otimes W\). |