API reference¶
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 (Fixed Effects)¶
|
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. |
|
|
|
Bayesian structural-form SAR-NB with Pólya–Gamma Gibbs sampler. |
|
Bayesian zero-inflated SAR Negative Binomial with PG-Gibbs sampler. |
|
Bayesian (non-spatial) logistic regression. |
|
Bayesian (non-spatial) Negative Binomial regression. |
|
Bayesian reduced-form SAR-logit with Pólya–Gamma Gibbs sampler. |
|
Bayesian structural-form SEM-logit with Pólya–Gamma Gibbs sampler. |
Panel Spatial Models (Tobit)¶
|
|
|
Flow Models¶
|
Non-spatial Bayesian OD-flow gravity model (independence baseline). |
|
Bayesian SAR flow model with three free spatial autoregressive parameters. |
|
Bayesian separable SAR flow model with ρ_w = −ρ_d · ρ_o. |
|
Aspatial OD-flow Negative Binomial gravity baseline. |
|
Bayesian SAR flow model with NB2 observation noise. |
|
Separable SAR flow model with NB2 observation noise. |
|
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¶
|
Non-spatial Bayesian OD-flow 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\). |
|
Aspatial panel OD-flow NB2 gravity baseline. |
|
Panel NB2 SAR flow model with unrestricted dependence parameters. |
|
Panel separable NB2 SAR 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\). |
Default Gibbs Priors¶
|
Base priors for all Gibbs samplers. |
|
Prior hyperparameters for Gaussian spatial Gibbs. |
|
Prior hyperparameters for the SAR-NB Gibbs sampler. |
|
Prior hyperparameters for the reduced-form SAR-NB sampler. |
|
Prior hyperparameters for the reduced-form flow NB sampler. |
|
Prior hyperparameters for the ZINB Gibbs sampler. |
|
Prior hyperparameters for the SAR-logit Gibbs sampler. |
|
Prior hyperparameters for the SEM-logit Gibbs sampler. |
|
Prior hyperparameters for RE panel Gibbs sampler. |
|
Prior hyperparameters for the Gaussian panel flow Gibbs sampler. |
Default NUTS Priors¶
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors shared by every panel model. |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors shared by every dynamic panel model. |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
|
Priors for |
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). |
GLM Bayesian LM Tests¶
Pólya-Gamma augmented LM tests for non-Gaussian models (Logit, NegBin).
|
Bayesian LM test for an omitted spatial lag of the linear predictor. |
|
Bayesian LM test for omitted spatial error in a GLM (logit / NB). |
|
Bayesian LM test for omitted WX coefficients in a GLM (H₀: γ = 0). |
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. |
|
Return the |
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. |
|
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¶
|
Compare a collection of fitted Bayesian models. |
|
Compute all pairwise Bayes factors for a set of Bayesian models. |
MCMC Efficiency¶
|
Summary of MCMC sampling-efficiency checks for a spatial model. |
|
Run MCMC adequacy checks on a fitted Bayesian spatial model. |
Spatial Cross-Validation¶
|
Result of |
|
Spatial block cross-validation for a fitted Bayesian spatial model. |
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 a non-spatial OLS DGP |
|
Simulate data from SAR DGP |
|
Simulate data from SEM DGP |
|
Simulate data from SLX DGP |
|
Simulate data from SDM DGP |
|
Simulate data from SDEM DGP |
|
Simulate data from a SAR-NB2 DGP. |
|
Simulate data from a zero-inflated SAR-NB DGP. |
|
Simulate SARProbit-style binary outcome data. |
|
Simulate left-censored SAR Tobit data. |
|
Simulate left-censored SEM Tobit data. |
|
Simulate left-censored SDM Tobit 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
neighbayes.models.flow operate on the latent scale, so fit on
np.log(y) to recover the SAR parameters. The Negative
Binomial DGPs are unchanged.
|
Simulate flow data from a SAR flow model. |
|
Simulate flow data from a separable SAR flow model. |
|
Generate synthetic O-D flow counts from an NB2 SAR flow DGP. |
|
NB2 flow DGP with separability constraint |
|
Simulate flow data from a spatial-error (SEM) flow model. |
|
Simulate SEM flow data with the separability constraint \(\lambda_w = -\lambda_d \lambda_o\). |
|
Simulate panel flow data from a SAR flow model with unit effects. |
|
Simulate panel flow data from a separable SAR flow model. |
|
Generate panel NB2 flow counts from a spatial autoregressive DGP. |
Panel NB2 flow DGP with separability constraint |
|
|
Simulate panel SEM flow data with O-D-pair random effects. |
|
Panel SEM flow DGP with separability constraint \(\lambda_w = -\lambda_d \lambda_o\). |
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 different numbers of dest/origin variables. |
|
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\). |