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
SpatialEffectsResultDirect, 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.
SpatialEconometrics.SpatialEconometricsPrototype.SpatialRegressionModel — Type
SpatialRegressionModelA 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: theSpatialVariantthat was fitted.coef: estimated coefficients, ordered ascoefnames.vcov: covariance matrix ofcoef.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, forSDM, theWXblock.y,residuals: response and residuals.trace_powers: traces of powers ofW, reused byspatial_effects.coefnames:"(Intercept)", the covariate names, thenW_-prefixed names for anSDM.
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:SARorSDM.W:N × Nsparse weight matrix, conventionally row-standardized.X:N × Kcovariates, without an intercept — one is added.y: response of lengthN.
Keywords
method: howlog|I - ρW|is evaluated —ExactLUorChebyshevApprox(default, order 6).varnames: covariate names; defaults tox1, x2, ….rho_bounds: search interval forρ, default(-0.995, 0.995). The bounds stay inside±1becauseI - ρWis singular at the edge of the stationary region.
Returns
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 coefA formula interface is also available: fit_spatial(@formula(y ~ x1 + slag(x2)), table, W).
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.