bayespecon.models.flow_panel.SARFlowPanel¶
-
class bayespecon.models.flow_panel.SARFlowPanel(y, G, X, T, col_names=
None, k=None, model=0, priors=None, logdet_method='traces', restrict_positive=True, robust=False, miter=30, titer=800, trace_riter=50, trace_seed=None, symmetric_xo_xd=None)[source]¶ Panel spatial-lag origin-destination flow model with unrestricted dependence.
For each period \(t\), the vectorized flow matrix \(y_t \in \mathbb{R}^{N}\) with \(N = n^2\) satisfies
\[y_t = \rho_d W_d y_t + \rho_o W_o y_t + \rho_w W_w y_t + X_t \beta + \varepsilon_t, \qquad \varepsilon_t \sim \mathcal{N}(0, \sigma^2 I_N).\]The panel stack is time-first across \(T\) periods. The
modelargument controls pooled, pair fixed-effects, time fixed-effects, or two-way demeaning before the likelihood is evaluated. The Jacobian contribution scales as \(T \log |A(\rho_d, \rho_o, \rho_w)|\).-
__init__(y, G, X, T, col_names=
None, k=None, model=0, priors=None, logdet_method='traces', restrict_positive=True, robust=False, miter=30, titer=800, trace_riter=50, trace_seed=None, symmetric_xo_xd=None)[source]¶
Methods
__init__(y, G, X, T[, col_names, k, model, ...])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 samples
y_repfor the full panel stack.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, **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 samples
y_repfor the full panel stack.
- property pymc_model : pymc.model.core.Model | None[source]¶
Return the most recently built PyMC model.
-
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).
-
__init__(y, G, X, T, col_names=