bayespecon.models.flow_panel.NegativeBinomialFlowPanel¶
- class bayespecon.models.flow_panel.NegativeBinomialFlowPanel(y, G, X, T, **kwargs)[source]¶
Aspatial panel OD-flow NB2 gravity baseline.
Methods
__init__(y, G, X, T, **kwargs)fit([draws, tune, chains, target_accept, ...])Draw samples from the posterior.
fit_approx([draws, n, method, random_seed, ...])Fit a variational approximation and return posterior draws.
posterior_predictive([n_draws, random_seed])Draw posterior-predictive flow counts for the panel Poisson gravity model.
Run Bayesian LM specification tests for flow panel models.
spatial_diagnostics_decision([alpha, format])Return a model-selection decision from Bayesian LM test results.
spatial_effects([draws, ...])Summarise posterior origin/destination/intra/network/total effects.
summary([var_names])Return posterior summary table via ArviZ.
Attributes
Return the most recent PyMC variational approximation, if any.
Return posterior draws from the most recent fit.
Return the most recently built PyMC model.
-
fit(draws=
2000, tune=1000, chains=4, target_accept=0.9, random_seed=None, store_lambda=False, idata_kwargs=None, progressbar=True, **sample_kwargs)[source]¶ Draw samples from the posterior.
-
fit_approx(draws=
2000, n=10000, method='advi', random_seed=None, store_lambda=False, compute_log_likelihood=True, **fit_kwargs)[source]¶ Fit a variational approximation and return posterior draws.
- property inference_data : arviz.data.inference_data.InferenceData | None[source]¶
Return posterior draws from the most recent fit.
-
posterior_predictive(n_draws=
None, random_seed=None)[source]¶ Draw posterior-predictive flow counts for the panel Poisson gravity model.
- property pymc_model : pymc.model.core.Model | None[source]¶
Return the most recently built PyMC model.
- spatial_diagnostics()[source]¶
Run Bayesian LM specification tests for flow panel models.
Looks up the diagnostic suite registered for this model class and returns a tidy DataFrame with one row per test. See
bayespecon.models.base.SpatialModel.spatial_diagnostics()for the column schema.- Raises:¶
RuntimeError – If the model has not been fit yet.
-
spatial_diagnostics_decision(alpha=
0.05, format='graphviz')[source]¶ Return a model-selection decision from Bayesian LM test results.
Walks the panel-flow decision tree using Bayesian p-values from
spatial_diagnostics()and recommends eitherOLSFlowPanel(no spatial dependence detected) orSARFlowPanel(at least one direction is significant).- Parameters:¶
- alpha : float, default 0.05¶
Significance level for the Bayesian p-values.
- format : {"graphviz", "ascii", "model"}, default "graphviz"¶
Output format.
"model"returns the recommended model name string."ascii"returns an indented box-drawing tree."graphviz"returns agraphviz.Digraph(with ASCII fallback if graphviz is not installed).
- Return type:¶
str or graphviz.Digraph
-
spatial_effects(draws=
None, return_posterior_samples=False, ci=0.95, mode='auto')[source]¶ Summarise posterior origin/destination/intra/network/total effects.
See
bayespecon.models.flow.FlowModel.spatial_effects()for themodesemantics (auto / combined / separate destination-origin sides per Thomas-Agnan & LeSage 2014, §83.5.2).
-
fit(draws=