Spatial Discrete Choice
Spatial probit and ordered probit, by linearized GMM and by Gibbs sampling.
SpatialEconometrics.SpatialDiscreteChoice.BayesianSpatialProbitModel — Type
BayesianSpatialProbitModelA spatial probit estimated by Albert-Chib Gibbs sampling, returned by fit_bayesian_spatial_probit.
Data augmentation draws the latent utilities, which makes the conditional posteriors tractable and avoids the intractable likelihood. Slower than fit_spatial_probit but markedly more precise on rho in small samples, and it carries an intercept.
This is built in, not part of the Turing extension.
SpatialEconometrics.SpatialDiscreteChoice.SpatialOrderedProbitModel — Type
SpatialOrderedProbitModelA spatial ordered probit, returned by fit_spatial_ordered_probit, for an outcome with J ordered categories.
Alongside the coefficients it carries the cut points separating the categories, drawn from their uniform conditionals between adjacent order statistics of the latent vector.
With J = 2 this reduces to binary probit, which fit_bayesian_spatial_probit handles better since it carries an intercept.
SpatialEconometrics.SpatialDiscreteChoice.SpatialProbitEffects — Type
SpatialProbitEffectsDirect, indirect and total marginal effects on the probability scale for a spatial discrete-choice model, returned by marginal_effects.
Two things compound here: the probit link makes the effect depend on where each unit sits on the curve, and the spatial lag propagates a change through (I - rho*W)^{-1}. The reported effects average over both.
SpatialEconometrics.SpatialDiscreteChoice.SpatialProbitModel — Type
SpatialProbitModelA spatial probit fitted by linearized GMM, returned by fit_spatial_probit.
Fast, because it avoids the N-dimensional integral the exact likelihood needs, but less precise in small samples than the Gibbs sampler — see fit_bayesian_spatial_probit when precision on rho matters.
Use marginal_effects to interpret the fit: as in any probit the coefficients are not marginal effects, and the spatial lag adds feedback on top of that.
SpatialEconometrics.SpatialDiscreteChoice.fit_bayesian_spatial_probit — Function
fit_bayesian_spatial_probit(W, X, y; n_samples=2000, burnin=500, rng=...)Fit the spatial autoregressive probit by Gibbs sampling with Albert & Chib (1993) data augmentation, following LeSage & Pace (2009, Ch. 10).
Each sweep: draw the latent y* one site at a time from its truncated conditional, draw β from its conjugate normal conditional, then update ρ by random-walk Metropolis on log|I-ρW| - ½(Ay*-Xβ)'(Ay*-Xβ) with a Uniform(-1,1) prior. The error variance is fixed at 1 for identification.
beta_prior_var sets an isotropic N(0, v·I) prior on β. Reported coef and vcov are the posterior mean and covariance; accept_rate is the ρ acceptance rate, which should land roughly in 0.2–0.5. The default rho_proposal_sd of 0.2 targets that band; 0.05 overshoots to about 0.77 acceptance and mixes slowly.
Because the observed signs pin the latent vector only up to scale, ‖β‖ and ρ trade off along a weakly identified ridge. The posterior is still centred correctly — over 8 replications at ρ = 0.4 the posterior mean averaged 0.374 at N = 196 — but its spread is wide (SD ≈ 0.10), so a single chain at small N can sit well away from the truth. Check accept_rate and lengthen the chain before reading much into one ρ estimate.
SpatialEconometrics.SpatialDiscreteChoice.fit_spatial_ordered_probit — Function
fit_spatial_ordered_probit(W, X, y; n_categories=maximum(y), n_samples=2000, ...)Fit the spatial ordered probit
y* = ρWy* + Xβ + ε, y = j iff τ_{j-1} < y* ≤ τ_jby Gibbs sampling with data augmentation (Wang, Kockelman & Wang, 2013). y holds integer categories 1:J.
For identification there is no intercept and τ_1 = 0; the free cutpoints τ_2 … τ_{J-1} are drawn from their uniform conditionals between the adjacent order statistics of the latent vector. τ_0 = -∞ and τ_J = +∞.
A binary y (J = 2) reduces to the probit above and is better served by fit_bayesian_spatial_probit, which carries an intercept.
SpatialEconometrics.SpatialDiscreteChoice.fit_spatial_probit — Function
fit_spatial_probit(W, X, y; varnames=nothing, instrument_lags=2)Fit the spatial autoregressive probit model
y* = ρWy* + Xβ + ε, y = 1(y* > 0)by the linearized GMM estimator of Klier & McMillen (2008). A standard probit supplies the ρ = 0 starting value; the moment conditions are then linearized around it and estimated by 2SLS with instruments [X, WX, W²X].
y must be coded 0/1. Returns a SpatialProbitModel.
Fitted probabilities use the heteroskedastic latent form Φ(((I-ρW)⁻¹Xβ)ᵢ / √[(I-ρW)⁻¹(I-ρW)⁻ᵀ]ᵢᵢ), which needs a dense inverse of I - ρW; cost is O(N³), so this is intended for moderate N.
loglikelihood reports the probit log-likelihood evaluated at the fitted index. It is a pseudo-likelihood — the estimator is GMM, not ML — so it is comparable across specifications fit the same way, but is not an ML criterion.
Linearizing around ρ = 0 buys speed at a real cost in efficiency. Over 8 replications at ρ = 0.4 this estimator had a standard deviation of about 0.25 at N = 196 and 0.18 at N = 400 — roughly 2.5× that of fit_bayesian_spatial_probit on the same data. It is approximately unbiased, so treat a single small-sample ρ̂ as a coarse reading and prefer the Gibbs sampler when precision on ρ matters.
SpatialEconometrics.SpatialDiscreteChoice.marginal_effects — Function
marginal_effects(m::SpatialProbitModel)Decompose the marginal effect of each covariate into direct, indirect, and total components. For covariate k the effect matrix is diag(φ(index)) (I-ρW)⁻¹ βₖ; the direct effect averages its diagonal, the total averages its row sums, and the indirect effect is the difference (LeSage & Pace, 2009).
Requires a dense inverse of I - ρW — O(N³), so intended for moderate N.