API reference

Models

A model class names a process and a family: SAR, SARLogit, SARNegBinFlow. Panel structure, effects, dynamics, and the flow restriction are arguments to the same class:

  • time_col (formula mode) or T (matrix mode) makes the model a panel;

  • unit_effects (pair_effects for flows) is None, "fixed", or "random", and time_effects=True adds fixed time effects;

  • dynamic=True adds the time lag \(y_{t-1}\), and dynamic="restricted" gives the restricted dynamic SDM;

  • separable=True pins \(\rho_w = -\rho_o \rho_d\) in a flow model.

A combination the package does not implement raises when the model is constructed.

Gaussian

OLS([formula, data, y, X, W, unit_effects, ...])

Bayesian ordinary least squares cross-sectional regression.

SLX([formula, data, y, X, W, unit_effects, ...])

Bayesian SLX (Spatial Lag X) model.

SAR([formula, data, y, X, W, unit_effects, ...])

Bayesian Spatial Autoregressive (Spatial Lag) model.

SEM([formula, data, y, X, W, unit_effects, ...])

Bayesian Spatial Error Model.

SDM([formula, data, y, X, W, unit_effects, ...])

Bayesian Spatial Durbin Model.

SDEM([formula, data, y, X, W, unit_effects, ...])

Bayesian Spatial Durbin Error Model.

Censored and binary

SARTobit([formula, data, y, X, W, ...])

Bayesian spatial autoregressive Tobit model.

SEMTobit([formula, data, y, X, W, ...])

Bayesian spatial error Tobit model.

SDMTobit([formula, data, y, X, W, ...])

Bayesian spatial Durbin Tobit model.

Logit([formula, data, y, X, W, ...])

Bayesian (non-spatial) logistic regression.

SARLogit([formula, data, y, X, W, ...])

Bayesian SAR logit: the latent SAR, or the reduced form with latent=False.

SEMLogit([formula, data, y, X, W, ...])

Bayesian latent SEM logit, sampled by an exact Gibbs sweep.

SDEMLogit([formula, data, y, X, W, ...])

Bayesian latent SDEM logit, sampled by the latent logit's exact Gibbs sweep.

Probit([formula, data, y, X, W, ...])

Bayesian (non-spatial) probit regression.

SARProbit([formula, data, y, X, W, ...])

Bayesian SAR probit: the latent SAR, or the reduced form with latent=False.

SEMProbit([formula, data, y, X, W, ...])

Bayesian latent SEM probit, or the SEM probit with random unit effects.

SDEMProbit([formula, data, y, X, W, ...])

Bayesian latent SDEM probit, sampled by the latent probit's exact Gibbs sweep.

Counts

NegBin([formula, data, y, X, W, ...])

Bayesian (non-spatial) Negative Binomial regression.

SARNegBin([formula, data, y, X, W, ...])

Bayesian SAR negative binomial: the latent SAR, or the reduced form with latent=False.

SEMNegBin([formula, data, y, X, W, ...])

Bayesian latent SEM negative binomial, sampled by an exact Gibbs sweep.

SDEMNegBin([formula, data, y, X, W, ...])

Bayesian latent SDEM negative binomial, sampled as SEMNegBin is.

ZINB([formula, data, y, X, W, unit_effects, ...])

Zero-inflated negative binomial panel without spatial dependence.

SARZINB([formula, data, y, X, W, ...])

Bayesian zero-inflated SAR negative binomial: latent, or reduced with latent=False.

HurdleNegBin([formula, data, y, X, W, ...])

Hurdle negative binomial panel without spatial dependence.

SARHurdleNegBin([formula, data, y, X, W, ...])

Bayesian SAR hurdle NB2: the latent model, or the reduced form with latent=False.

Flows

OLSFlow(y, X, W, *[, pair_effects, ...])

Non-spatial Bayesian origin-destination gravity model.

SARFlow(y, X, W, *[, pair_effects, ...])

Bayesian SAR origin-destination flow model.

SEMFlow(y, X, W, *[, pair_effects, ...])

Bayesian spatial-error origin-destination flow model.

NegBinFlow(y, X, W, *[, pair_effects, ...])

Aspatial negative binomial (NB2) origin-destination gravity model.

SARNegBinFlow(y, X, W, *[, pair_effects, ...])

Reduced-form SAR negative binomial (NB2) origin-destination flow model.

SARPoissonFlow(y, X, W, *[, pair_effects, ...])

Reduced-form SAR Poisson origin-destination flow model (cross-section).

SARZINBFlow(y, X, W, *[, pair_effects, ...])

Zero-inflated negative binomial SAR flow model (separable).

SARHurdleNegBinFlow(y, X, W, *[, ...])

Reduced-form SAR hurdle negative binomial flow model (separable).

Multilevel

Multilevel(*levels[, priors, logdet_method, ...])

Bayesian spatial multilevel model with a graph and a process at each level.

Level([formula, data, y, X, W, process, ...])

One level's equation for Multilevel.

Default Gibbs Priors

GibbsBasePriors([beta_mu, beta_sigma, ...])

Base priors for all Gibbs samplers.

GaussianGibbsPriors([beta_mu, beta_sigma, ...])

Prior hyperparameters for Gaussian spatial Gibbs.

ReducedGibbsPriors([beta_mu, beta_sigma, ...])

Prior hyperparameters for the reduced-form SAR-NB sampler.

FlowReducedGibbsPriors([beta_mu, ...])

Prior hyperparameters for the reduced-form flow NB sampler.

ZINBGibbsPriors([gamma_mu, gamma_sigma, ...])

Prior hyperparameters for the ZINB Gibbs sampler.

BinaryGibbsPriors([beta_mu, beta_sigma, ...])

Prior hyperparameters for the SAR-logit Gibbs sampler.

REGibbsPriors([beta_mu, beta_sigma, ...])

Prior hyperparameters for RE panel Gibbs sampler.

Default NUTS Priors

OLSPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.OLS.

SLXPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SLX.

SARPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SAR.

SEMPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SEM.

SDMPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SDM (lag + WX).

SDEMPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SDEM (SLX + spatial error).

NegBinPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.NegBin.

SARNegBinPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SARNegBin.

SEMNegBinPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SEMNegBin and SDEMNegBin.

SARTobitPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SARTobit.

SEMTobitPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SEMTobit.

SDMTobitPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SDMTobit.

SARProbitPriors([rho_lower, rho_upper, ...])

Priors for neighbayes.models.SARProbit.

SEMProbitPriors([lam_lower, lam_upper, ...])

Priors for neighbayes.models.SEMProbit, the latent SEM probit.

SEMProbitREPriors([lam_lower, lam_upper, ...])

Priors for SEMProbit(unit_effects="random").

SARLogitPriors([rho_lower, rho_upper, ...])

Priors for neighbayes.models.SARLogit.

SEMLogitPriors([lam_lower, lam_upper, ...])

Priors for neighbayes.models.SEMLogit, the latent SEM logit.

PanelBasePriors([beta_mu, beta_sigma, ...])

Priors shared by every panel model.

PanelOLSPriors([beta_mu, beta_sigma, ...])

The base of PanelOLSREPriors: the panel keys with no spatial bounds.

PanelSARPriors([beta_mu, beta_sigma, ...])

Panel priors with rho bounds: the base of the SAR random-effects and count panel priors.

PanelSEMPriors([beta_mu, beta_sigma, ...])

Panel priors with lam bounds: the base of the SEM and SDEM random-effects priors.

PanelSDEMPriors([beta_mu, beta_sigma, ...])

The base of PanelSDEMREPriors.

PanelOLSREPriors([unit_effect_sd_nu, ...])

Priors for neighbayes.models.OLS with random unit effects.

PanelSARREPriors([unit_effect_sd_nu, ...])

Priors for neighbayes.models.SAR with random unit effects.

PanelSEMREPriors([unit_effect_sd_nu, ...])

Priors for neighbayes.models.SEM with random unit effects.

PanelSDEMREPriors([unit_effect_sd_nu, ...])

Priors for neighbayes.models.SDEM with random unit effects.

PanelCountPriors([beta_mu, beta_sigma, ...])

Priors for the count panels (neighbayes.models.SARNegBin & co).

PanelZINBPriors([beta_mu, beta_sigma, ...])

Priors for the ZINB panels (neighbayes.models.SARZINB & co).

SARZINBPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SARZINB and the ZINB panels.

PanelHurdlePriors([beta_mu, beta_sigma, ...])

Priors for the hurdle panels (neighbayes.models.SARHurdleNegBin & co).

FlowPanelHurdlePriors([beta_mu, beta_sigma, ...])

Priors for the hurdle flow panels (neighbayes.models.SARHurdleNegBinFlow).

SARHurdlePriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.SARHurdleNegBin.

MultilevelPriors([beta_mu, beta_sigma, ...])

Priors for neighbayes.models.Multilevel.

PanelDynamicBasePriors([beta_mu, ...])

Priors shared by every dynamic panel model.

PanelOLSDynamicPriors([beta_mu, beta_sigma, ...])

Priors for the dynamic panel of neighbayes.models.OLS.

PanelSLXDynamicPriors([beta_mu, beta_sigma, ...])

Priors for the dynamic panel of neighbayes.models.SLX.

PanelSARDynamicPriors([beta_mu, beta_sigma, ...])

Priors for the dynamic panel of neighbayes.models.SAR.

PanelSEMDynamicPriors([beta_mu, beta_sigma, ...])

Priors for the dynamic panel of neighbayes.models.SEM.

PanelSDMRDynamicPriors([beta_mu, ...])

Priors for the restricted dynamic panel of neighbayes.models.SDM.

PanelSDMUDynamicPriors([beta_mu, ...])

Priors for the dynamic panel of neighbayes.models.SDM.

PanelSDEMDynamicPriors([beta_mu, ...])

Priors for the dynamic panel of neighbayes.models.SDEM.

Bayesian Diagnostics

BayesianLMTestResult(lm_samples, mean, ...)

Container for Bayesian LM test results.

bayesian_lm_lag_test(model)

LM test for an omitted spatial lag (H₀: ρ = 0).

bayesian_lm_error_test(model)

LM test for an omitted spatial error process (H₀: λ = 0).

bayesian_lm_wx_test(model)

LM test for omitted \(WX\) at an OLS or SAR fit (H₀: θ = 0).

bayesian_lm_sdm_joint_test(model)

Joint LM test for the SDM at an OLS fit (H₀: ρ = 0 and θ = 0).

bayesian_lm_slx_error_joint_test(model)

Joint LM test for the SDEM at an OLS fit (H₀: λ = 0 and θ = 0).

bayesian_lm_error_from_sar_test(model)

LM test for a spatial error process at a SAR fit (H₀: λ = 0 | SAR).

bayesian_lm_error_sdm_test(model)

LM test for a spatial error process at an SDM fit (H₀: λ = 0 | SDM).

bayesian_lm_lag_sdem_test(model)

LM test for a spatial lag at an SDEM fit (H₀: ρ = 0 | SDEM).

bayesian_lm_wx_sem_test(model)

LM test for omitted \(WX\) at a SEM fit (H₀: θ = 0 | SEM).

bayesian_robust_lm_lag_test(model)

Robust LM-lag at an OLS fit (H₀: ρ = 0, robust to a local λ).

bayesian_robust_lm_error_test(model)

Robust LM-error at an OLS fit (H₀: λ = 0, robust to a local ρ).

bayesian_robust_lm_lag_sdm_test(model)

Robust LM-lag at an SLX fit (H₀: ρ = 0, robust to a local λ).

bayesian_robust_lm_wx_test(model)

Robust LM-WX at a SAR fit (H₀: θ = 0, robust to a local λ).

bayesian_robust_lm_error_sdem_test(model)

Robust LM-error at an SLX fit (H₀: λ = 0, robust to a local ρ).

bayesian_robust_lm_error_sar_test(model)

Robust LM-error at a SAR fit (H₀: λ = 0, robust to a local θ).

bayesian_robust_lm_lag_sem_test(model)

Robust LM-lag at an OLS or SEM fit (H₀: ρ = 0, robust to a local θ).

bayesian_robust_lm_wx_sem_test(model)

Robust LM-WX at an OLS or SEM fit (H₀: θ = 0, robust to a local ρ).

GLM Bayesian LM Tests

LM tests for the logit, probit and NB families: the latent SAR and SEM score tests at the GLM null (Logit, Probit, NegBin), the error and WX tests at a reduced-form SAR null (SARLogit(latent=False), SARProbit(latent=False), SARNegBin(latent=False)), and a Moran diagnostic on working residuals.

bayesian_glm_lm_lag_test(model)

LM test for the latent SAR at the GLM null.

bayesian_glm_lm_error_test(model)

LM test for a latent error process.

bayesian_glm_robust_lm_lag_test(model)

Robust LM test for the spillover at the GLM null.

bayesian_glm_robust_lm_error_test(model)

Robust LM test for the error term at the GLM null.

bayesian_glm_lm_sarma_test(model)

Joint LM test for spillover and error at the GLM null.

bayesian_glm_lm_wx_test(model)

LM test for omitted \(WX\) (H₀: θ = 0).

bayesian_glm_moran_working_test(model)

Moran diagnostic on the working residuals at the GLM null.

Panel Bayesian LM Tests

bayesian_panel_lm_lag_test(model)

LM test for an omitted spatial lag in a panel (H₀: ρ = 0).

bayesian_panel_lm_error_test(model)

LM test for an omitted spatial error process in a panel (H₀: λ = 0).

bayesian_panel_robust_lm_lag_test(model)

Robust panel LM-lag (H₀: ρ = 0, robust to a local λ).

bayesian_panel_robust_lm_error_test(model)

Robust panel LM-error (H₀: λ = 0, robust to a local ρ).

bayesian_panel_lm_wx_test(model)

Panel LM test for omitted \(WX\) at an OLS or SAR panel (H₀: θ = 0).

bayesian_panel_lm_sdm_joint_test(model)

Joint panel LM test for the SDM at an OLS panel (H₀: ρ = 0 and θ = 0).

bayesian_panel_lm_slx_error_joint_test(model)

Joint panel LM test for the SDEM at an OLS panel (H₀: λ = 0 and θ = 0).

bayesian_panel_lm_error_sdm_test(model)

Panel LM test for a spatial error process at an SDM panel (H₀: λ = 0 | SDM).

bayesian_panel_lm_lag_sdem_test(model)

Panel LM test for a spatial lag at an SEM or SDEM panel (H₀: ρ = 0).

bayesian_panel_lm_wx_sem_test(model)

Panel LM test for omitted \(WX\) at a SEM panel (H₀: θ = 0 | SEM).

bayesian_panel_robust_lm_lag_sdm_test(model)

Robust panel LM-lag at an SLX panel (H₀: ρ = 0, robust to a local λ).

bayesian_panel_robust_lm_wx_test(model)

Robust panel LM-WX at a SAR panel (H₀: θ = 0, robust to a local λ).

bayesian_panel_robust_lm_error_sdem_test(model)

Robust panel LM-error at an SLX panel (H₀: λ = 0, robust to a local ρ).

bayesian_panel_robust_lm_error_sar_test(model)

Robust panel LM-error at a SAR panel (H₀: λ = 0, robust to a local θ).

bayesian_panel_robust_lm_lag_sem_test(model)

Robust panel LM-lag at an OLS or SEM panel (H₀: ρ = 0, robust to a local θ).

bayesian_panel_robust_lm_wx_sem_test(model)

Robust panel LM-WX at an OLS or SEM panel (H₀: θ = 0, robust to a local ρ).

Flow Bayesian LM Tests

bayesian_lm_flow_destination_test(model)

LM test for an omitted destination lag at an OLSFlow fit (H₀: ρ_d = 0).

bayesian_lm_flow_origin_test(model)

LM test for an omitted origin lag at an OLSFlow fit (H₀: ρ_o = 0).

bayesian_lm_flow_od_test(model)

LM test for an omitted network lag at an OLSFlow fit (H₀: ρ_w = 0).

bayesian_lm_flow_joint_test(model)

Joint LM test at an OLSFlow fit (H₀: ρ_d = ρ_o = ρ_w = 0).

bayesian_robust_lm_flow_destination_test(model)

Robust LM test for the destination lag at an OLSFlow fit.

bayesian_robust_lm_flow_origin_test(model)

Robust LM test for the origin lag at an OLSFlow fit.

bayesian_robust_lm_flow_od_test(model)

Robust LM test for the network lag at an OLSFlow fit.

bayesian_panel_lm_flow_destination_test(model)

LM test for an omitted destination lag at an OLSFlow panel fit.

bayesian_panel_lm_flow_origin_test(model)

LM test for an omitted origin lag at an OLSFlow panel fit (H₀: ρ_o = 0).

bayesian_panel_lm_flow_od_test(model)

LM test for an omitted network lag at an OLSFlow panel fit (H₀: ρ_w = 0).

bayesian_panel_lm_flow_joint_test(model)

Joint LM test at an OLSFlow panel fit (H₀: ρ_d = ρ_o = ρ_w = 0), df 3.

bayesian_panel_robust_lm_flow_destination_test(model)

Robust LM test for the destination lag at an OLSFlow panel fit.

bayesian_panel_robust_lm_flow_origin_test(model)

Robust LM test for the origin lag at an OLSFlow panel fit.

bayesian_panel_robust_lm_flow_od_test(model)

Robust LM test for the network lag at an OLSFlow panel fit.

Diagnostic Test Suites

Pre-bundled collections of LM tests used by model.spatial_diagnostics() and the decision-tree renderers.

DiagnosticSuite(name, tests)

Named, immutable registry of Bayesian LM specification tests.

get_diagnostic_suite(model)

Return the DiagnosticSuite for model, or None.

OLS_SUITE

Named, immutable registry of Bayesian LM specification tests.

OLS_PANEL_SUITE

Named, immutable registry of Bayesian LM specification tests.

SAR_SUITE

Named, immutable registry of Bayesian LM specification tests.

SAR_PANEL_SUITE

Named, immutable registry of Bayesian LM specification tests.

SEM_SUITE

Named, immutable registry of Bayesian LM specification tests.

SEM_PANEL_SUITE

Named, immutable registry of Bayesian LM specification tests.

SLX_SUITE

Named, immutable registry of Bayesian LM specification tests.

SLX_PANEL_SUITE

Named, immutable registry of Bayesian LM specification tests.

SDM_SUITE

Named, immutable registry of Bayesian LM specification tests.

SDM_PANEL_SUITE

Named, immutable registry of Bayesian LM specification tests.

SDEM_SUITE

Named, immutable registry of Bayesian LM specification tests.

SDEM_PANEL_SUITE

Named, immutable registry of Bayesian LM specification tests.

FLOW_SUITE

Named, immutable registry of Bayesian LM specification tests.

FLOW_PANEL_SUITE

Named, immutable registry of Bayesian LM specification tests.

LOGIT_SUITE

Named, immutable registry of Bayesian LM specification tests.

NEGBIN_SUITE

Named, immutable registry of Bayesian LM specification tests.

SAR_LOGIT_SUITE

Named, immutable registry of Bayesian LM specification tests.

SAR_NEGBIN_SUITE

Named, immutable registry of Bayesian LM specification tests.

Bayesian Model Comparison

ModelComparison(models[, labels, method])

Compare a collection of fitted Bayesian models.

bayes_factor_compare_models(models[, ...])

Compute all pairwise Bayes factors for a set of Bayesian models.

MCMC Efficiency

SpatialMCMCReport(parameters, ess_bulk, ...)

Summary of MCMC sampling-efficiency checks for a spatial model.

spatial_mcmc_diagnostic(model, *[, min_ess, ...])

Run MCMC adequacy checks on a fitted Bayesian spatial model.

Spatial Cross-Validation

SpatialCVResult(elpd, se, elpd_per_fold, ...)

Result of spatial_kfold().

spatial_kfold(model, splitter, *[, ...])

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.

Each simulator draws from the model class it is named for and takes the same design arguments: T (with N) for a panel, unit_effects and time_effects (scaled by unit_effect_sd and time_effect_sd, default 0.5), and dynamic. Fixed and random unit effects draw the same data; the distinction belongs to the model.

simulate_ols([n_side, W, gdf, beta, sigma, ...])

Simulate data from a non-spatial OLS DGP y = X beta + eps.

simulate_slx([n_side, W, gdf, beta1, beta2, ...])

Simulate data from SLX DGP y = X beta1 + W X_no_intercept beta2 + eps.

simulate_sar([n_side, W, gdf, rho, beta, ...])

Simulate data from SAR DGP y = (I-rho W)^(-1)(X beta + eps).

simulate_sem([n_side, W, gdf, lam, beta, ...])

Simulate data from SEM DGP y = X beta + (I-lam W)^(-1) eps.

simulate_sdm([n_side, W, gdf, rho, beta1, ...])

Simulate data from SDM DGP y = (I-rho W)^(-1)(Xb1 + WXb2 + eps).

simulate_sdem([n_side, W, gdf, lam, beta1, ...])

Simulate data from SDEM DGP y = Xb1 + WXb2 + (I-lam W)^(-1)eps.

simulate_sar_tobit(*[, censoring, ...])

Simulate left-censored SAR Tobit data.

simulate_sem_tobit(*[, censoring, ...])

Simulate left-censored SEM Tobit data.

simulate_sdm_tobit(*[, censoring, ...])

Simulate left-censored SDM Tobit data.

simulate_logit([W, gdf, n_side, beta, ...])

Simulate an aspatial logit: simulate_sar_logit() with rho = 0.

simulate_sar_logit([W, gdf, n_side, rho, ...])

Simulate SAR-logit binary outcome data.

simulate_sem_logit([W, gdf, n_side, lam, ...])

Simulate the latent SEM logit that SEMLogit fits.

simulate_sdem_logit([W, gdf, n_side, lam, ...])

Simulate the latent SDEM logit that SDEMLogit fits.

simulate_probit([W, gdf, n_side, beta, ...])

Simulate an aspatial probit: simulate_sar_probit() with rho = 0.

simulate_sar_probit([W, gdf, n_side, rho, ...])

Simulate the SAR probit that SARProbit fits.

simulate_sem_probit([W, gdf, n_side, lam, ...])

Simulate the SEM probit that SEMProbit fits.

simulate_sdem_probit([W, gdf, n_side, lam, ...])

Simulate the latent SDEM probit that SDEMProbit fits.

simulate_negbin([n_side, W, gdf, beta, ...])

Simulate an aspatial NB2 regression: simulate_sar_negbin() with rho = 0.

simulate_sar_negbin([n_side, W, gdf, rho, ...])

Simulate data from the reduced-form SAR-NB2 that SARNegBin fits.

simulate_sem_negbin([n_side, W, gdf, lam, ...])

Simulate the latent SEM negative binomial that SEMNegBin fits.

simulate_sdem_negbin([n_side, W, gdf, lam, ...])

Simulate the latent SDEM negative binomial that SDEMNegBin fits.

simulate_zinb([n_side, W, gdf, beta, ...])

Simulate an aspatial ZINB panel: simulate_sar_zinb() with rho = rho_zero = 0.

simulate_sar_zinb([n_side, W, gdf, rho, ...])

Simulate data from a zero-inflated SAR-NB DGP.

simulate_hurdle_negbin([n_side, W, gdf, ...])

Simulate an aspatial hurdle NB panel: simulate_sar_hurdle_negbin() at zero dependence.

simulate_sar_hurdle_negbin([n_side, W, gdf, ...])

Simulate a reduced-form SAR hurdle NB cross-section.

simulate_multilevel([n_side, blocks, ...])

Simulate nested levels with a graph and a process at each.

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.

Each flow simulator takes separable, T, pair_effects, and time_effects as its model class does. The Gaussian flow DGPs (simulate_sar_flow and simulate_sem_flow) 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_ols_flow([n, G, beta_d, beta_o, ...])

Simulate an aspatial Gaussian flow model: simulate_sar_flow() with every ρ at 0.

simulate_sar_flow([n, G, rho_d, rho_o, ...])

Simulate flow data from a SAR flow model.

simulate_sem_flow([n, G, lam_d, lam_o, ...])

Simulate flow data from a spatial-error (SEM) flow model.

simulate_negbin_flow([n, k, k_d, k_o, ...])

Simulate an aspatial NB flow model: simulate_sar_negbin_flow() with every ρ at 0.

simulate_sar_negbin_flow([n, k, k_d, k_o, ...])

Generate synthetic O-D flow counts from an NB2 SAR flow DGP.

simulate_sar_poisson_flow([n, rho_d, rho_o, ...])

Generate synthetic O-D flow counts from a Poisson SAR flow DGP.

simulate_sar_zinb_flow([n, rho_d, rho_o, ...])

Simulate the ZINB flow model with SAR dependence.

simulate_sar_hurdle_negbin_flow([n, rho_d, ...])

Simulate the hurdle NB flow model with SAR dependence.

Graph Utilities

FlowDesignMatrix(X_dest, X_orig, X_intra, ...)

Combined design matrix for an O-D flow regression.

flow_design_matrix(X[, col_names, dist, ...])

Build a flow regression design matrix from regional attribute data.

flow_design_matrix_asymmetric(Xd, Xo[, ...])

Build a flow design matrix with different numbers of dest/origin variables.

flow_design_matrix_with_orig(Xd, Xo[, ...])

Build a flow design matrix with separate destination and origin data.

flow_weight_matrices(G)

Build all three N×N flow weight matrices from a single Graph.

destination_weights(G)

Build the N×N destination weight matrix \(W_d = I_n \otimes W\).

origin_weights(G)

Build the N×N origin weight matrix \(W_o = W \otimes I_n\).

od_weights(G)

Build the N×N origin–destination weight matrix \(W_w = W \otimes W\).

Runtime Configuration

Opt-in helpers that change how fits run, not what they estimate: a persistent compile cache, and on-disk checkpoints that let a long JAX Gibbs fit resume after a crash with the draws it would have returned uninterrupted.

checkpoints(path, *[, every])

Save long JAX Gibbs fits to disk as they run, and resume them after a crash.

enable_compile_cache([path])

Enable persistent on-disk compile caches for JAX and PyTensor.