CSPATIALREG Procedure

Spatial Error Models

The spatial error model (SEM) accounts for spatial dependence in the error terms rather than in the dependent variable. Let y Subscript i denote the observation that is associated with the spatial unit bold s Subscript i for i equals 1 comma 2 comma ellipsis comma n. For these spatial units, let bold upper W be an n times n spatial weights matrix. Further, let bold x Subscript i be a p times 1 vector that denotes values of p regressors that are recorded at unit bold s Subscript i.

The SEM can be described in vector form by using the following two-stage formulation (LeSage and Pace 2009),

bold y equals bold upper X bold-italic beta plus bold u
bold u equals lamda bold upper W bold u 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-italic epsilon equals left-parenthesis epsilon 1 comma epsilon 2 comma ellipsis comma epsilon Subscript n Baseline right-parenthesis prime with epsilon Subscript i Baseline tilde Overscript normal i normal i normal d Endscripts upper N left-parenthesis 0 comma sigma squared right-parenthesis, bold upper X is an n times p matrix where each row consists of bold x prime Subscript i, and bold-italic beta is a p times 1 parameter vector.

The log-likelihood function for the SEM is

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

where bold upper B equals bold upper I Subscript n Baseline minus lamda bold upper W.

For the SEM, the gradients are

StartFraction partial-differential script upper L Over partial-differential bold-italic beta EndFraction equals StartFraction left-parenthesis bold upper B bold upper X right-parenthesis prime left-bracket bold upper B left-parenthesis bold y minus bold upper X bold-italic beta right-parenthesis right-bracket Over sigma squared EndFraction
StartFraction partial-differential script upper L Over partial-differential lamda EndFraction equals StartFraction 1 Over sigma squared EndFraction left-bracket bold upper W left-parenthesis bold y minus bold upper X bold-italic beta right-parenthesis right-bracket prime left-bracket bold upper B left-parenthesis bold y minus bold upper X bold-italic beta right-parenthesis right-bracket minus normal t normal r left-parenthesis bold upper B 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-bracket bold upper B left-parenthesis bold y minus bold upper X bold-italic beta right-parenthesis right-bracket prime left-bracket bold upper B left-parenthesis bold y minus bold upper X bold-italic beta right-parenthesis right-bracket Over 2 sigma Superscript 4 Baseline EndFraction

In addition to the interaction effects among error terms, you might also want to include exogenous interaction effects in the model. In such cases, you need to consider a spatial Durbin error model.

Last updated: July 09, 2026