Cross-Sectional Models

Cross-sectional SAR and SDM by concentrated maximum likelihood, and the effects decomposition that makes their coefficients interpretable.

SpatialEconometrics.SpatialEconometricsPrototype.SpatialEffectsResult — Type
SpatialEffectsResult

Direct, indirect and total marginal effects with standard errors, as returned by spatial_effects. All six vectors are aligned with varnames.

Fields

  • varnames: covariate names, excluding the intercept.
  • direct, direct_se: the own-unit effect — the average diagonal of ∂y/∂x.
  • indirect, indirect_se: the spillover onto other units, i.e. the average off-diagonal row sum.
  • total, total_se: direct + indirect.
source
SpatialEconometrics.SpatialEconometricsPrototype.SpatialRegressionModel — Type
SpatialRegressionModel

A fitted cross-sectional spatial model, as returned by fit_spatial. Implements the StatsAPI.RegressionModel interface, so coef, vcov, nobs, loglikelihood, residuals and coefnames all work on it.

Fields

  • variant: the SpatialVariant that was fitted.
  • coef: estimated coefficients, ordered as coefnames.
  • vcov: covariance matrix of coef.
  • rho, rho_se: the spatial autoregressive parameter and its standard error.
  • sigma2: estimated error variance.
  • loglik: maximized log-likelihood.
  • W: the weight matrix used.
  • X_aug: the design actually estimated, including the intercept and, for SDM, the WX block.
  • y, residuals: response and residuals.
  • trace_powers: traces of powers of W, reused by spatial_effects.
  • coefnames: "(Intercept)", the covariate names, then W_-prefixed names for an SDM.
Note

coef holds the structural β, not marginal effects. In a spatial-lag model a change in x feeds back through (I - ρW)^{-1}, so use spatial_effects for interpretable quantities.

source
SpatialEconometrics.SpatialEconometricsPrototype.fit_spatial — Function
fit_spatial(variant, W, X, y; method, varnames, rho_bounds)

Fit a cross-sectional spatial regression by concentrated maximum likelihood.

The likelihood is concentrated so that β and σ² are solved in closed form at each trial ρ, leaving a one-dimensional maximization over ρ alone, which is done by Brent search within rho_bounds.

Arguments

  • variant: SAR or SDM.
  • W: N × N sparse weight matrix, conventionally row-standardized.
  • X: N × K covariates, without an intercept — one is added.
  • y: response of length N.

Keywords

  • method: how log|I - ρW| is evaluated — ExactLU or ChebyshevApprox (default, order 6).
  • varnames: covariate names; defaults to x1, x2, ….
  • rho_bounds: search interval for ρ, default (-0.995, 0.995). The bounds stay inside ±1 because I - ρW is singular at the edge of the stationary region.

Returns

A SpatialRegressionModel.

Examples

W = make_rook_weights(10)
m = fit_spatial(SAR(), W, X, y; varnames = ["income", "density"])
m.rho
coef(m)
spatial_effects(m)          # interpretable effects, not coef

A formula interface is also available: fit_spatial(@formula(y ~ x1 + slag(x2)), table, W).

Note

Read coef as structural parameters. spatial_effects gives the marginal effects, which differ whenever ρ ≠ 0.

See also fit_spatial_panel, fit_spatial_error, lm_tests for choosing between lag and error specifications.

References

LeSage, J. & Pace, R. K. (2009). Introduction to Spatial Econometrics. CRC Press.

source