CSPATIALREG Procedure

Spatial Autoregressive Models

The spatial autoregressive (SAR) model is useful for incorporating spatial dependence in the dependent variable—that is, the endogenous interaction effect. Let y Subscript i denote the observation that is associated with a spatial unit bold s Subscript i for i equals 1 comma 2 comma ellipsis comma n. For these spatial units, let an n times n matrix bold upper W with nonnegative elements be a spatial weights matrix and let bold x Subscript i be a p times 1 vector that denotes values of p regressors that are recorded for the spatial unit bold s Subscript i. You can formulate the SAR model as

y Subscript i Baseline equals rho sigma-summation Underscript j equals 1 Overscript n Endscripts upper W Subscript i j Baseline y Subscript j Baseline plus bold x prime Subscript i Baseline bold-italic beta plus epsilon Subscript i

where i equals 1 comma 2 comma ellipsis comma n, rho is the spatial autoregressive coefficient, bold-italic beta is a p times 1 parameter vector, upper W Subscript i j is the left-parenthesis i comma j right-parenthesisth element of the matrix bold upper W subject to upper W Subscript i i Baseline equals 0, and the error term epsilon Subscript i that is related to the spatial unit bold s Subscript i is assumed to follow epsilon Subscript i Baseline tilde Overscript normal i normal i normal d Endscripts upper N left-parenthesis 0 comma sigma squared right-parenthesis for i equals 1 comma 2 comma ellipsis comma n.

The SAR model is often described in vector form as

bold y equals rho bold upper W bold y plus bold upper X bold-italic beta plus bold-italic epsilon

where bold y equals left-parenthesis y 1 comma y 2 comma ellipsis comma y Subscript n Baseline right-parenthesis prime, bold upper X is an n times p matrix where each row consists of bold x prime Subscript i, and bold-italic epsilon equals left-parenthesis epsilon 1 comma epsilon 2 comma ellipsis comma epsilon Subscript n Baseline right-parenthesis prime.

The standard estimator for the SAR model is the maximum likelihood estimator (MLE). For the SAR model, the log-likelihood function is (Anselin 2001)

script upper L equals minus StartFraction n Over 2 EndFraction ln left-parenthesis 2 pi sigma squared right-parenthesis minus StartFraction left-parenthesis bold upper A bold y minus bold upper X bold-italic beta right-parenthesis prime left-parenthesis bold upper A bold y minus bold upper X bold-italic beta right-parenthesis Over 2 sigma squared EndFraction plus ln StartAbsoluteValue bold upper A EndAbsoluteValue

where bold upper A equals bold upper I Subscript n Baseline minus rho bold upper W, bold upper I Subscript n is an n times n identity matrix, and StartAbsoluteValue bold upper A EndAbsoluteValue denotes the determinant of bold upper A.

You can derive the gradients as follows:

StartFraction partial-differential script upper L Over partial-differential bold-italic beta EndFraction equals StartFraction bold upper X prime left-parenthesis bold upper A bold y minus bold upper X bold-italic beta right-parenthesis Over sigma squared EndFraction
StartFraction partial-differential script upper L Over partial-differential rho EndFraction equals StartFraction 1 Over sigma squared EndFraction bold y prime bold upper W prime left-parenthesis bold upper A bold y minus bold upper X bold-italic beta right-parenthesis minus normal t normal r left-parenthesis bold upper A Superscript negative 1 Baseline bold upper W right-parenthesis
StartFraction partial-differential script upper L Over partial-differential sigma squared EndFraction equals minus StartFraction n Over 2 sigma squared EndFraction plus StartFraction left-parenthesis bold upper A bold y minus bold upper X bold-italic beta right-parenthesis prime left-parenthesis bold upper A bold y minus bold upper X bold-italic beta right-parenthesis Over 2 sigma Superscript 4 Baseline EndFraction

For the n times n matrix bold upper A, normal t normal r left-parenthesis bold upper A right-parenthesis equals sigma-summation Underscript i equals 1 Overscript n Endscripts a Subscript i i, where a Subscript i i is the ith diagonal element of bold upper A.

A SAR model does not account for exogenous interaction effects. In practice, the value of the dependent variable y for a spatial unit might also be affected by some independent exploratory variables of other spatial units. In such a case, you can use the spatial Durbin model instead.

Last updated: July 09, 2026