Home  /  Products  /  Features  /  Spatial autoregressive models

Spatial autoregressive models

Spatial autoregressive (SAR) models are fit using datasets that contain observations on geographical areas or on any units with a spatial representation. Fit linear models with autoregressive errors and spatial lags of the dependent and independent variables. Specify spatial lags using spatial weighting matrices. Create standard weighting matrices, such as inverse distance or nearest neighbor, or create custom matrices. Fit random- and fixed-effects models for spatial panel data. Explore direct and indirect effects of covariates after fitting models.

Learn about Spatial autoregressive models.

SAR models for cross-sectional data

  • Linear models with autoregressive errors and spatial lags of the dependent and independent variables
  • Generalized method of moments estimator GS2SLS (generalized spatial two-stage least squares)
    • Spatial lags and autoregressive error terms given by one or more spatial weighting matrices
    • Heteroskedastic errors
  • Maximum-likelihood estimator
    • Robust standard errors
    • Constraints
  • Instrumental-variables spatial linear models
  • Moran test of residual correlation

SAR models for panel data

  • Fixed-effects maximum-likelihood linear models
  • Random-effects maximum-likelihood linear models
    • Model panel-level effects as normal i.i.d. or with the same autoregressive form as the time-level errors

Data management for spatial data

  • Capabilities for
    • Data with shapefiles
    • Data without shapefiles but including location information
    • Data without shapefiles or location information
  • Automatic translation of standard-format shapefiles
  • Set coordinates as
    • Planar
    • Latitude and longitude
  • Calculate distances
  • Automatic balancing of spatial panel data
  • Draw choropleth maps

Spatial weighting matrices for SAR models

  • Create and manage spatial weighting matrices that specify spatial lags
  • Nearest-neighbor weighting matrices
  • Inverse-distance weighting matrices
  • Custom weighting matrices from
    • Stata data
    • Mata programs
    • File import
  • Normalization of weighting matrices
    • Spectral (largest eigenvalue)
    • Min–max normalization
    • Row
  • Manage matrices
    • List
    • Summarize
    • Drop
    • Copy
    • Save and use
    • Add note
  • Import and export weighting matrices from text files
  • Use and save weighting matrices in Stata format


  • Reduced-form mean
  • Direct mean
  • Indirect mean
  • Limited-information mean
  • Full-information mean
  • Linear prediction
  • Residuals
  • Uncorrelated residuals

Postestimation analysis

  • Direct and indirect (spillover) effects with standard errors

Postestimation Selector

  • View and run all postestimation features for your command
  • Automatically updated as estimation commands are run

Additional resources

See tests, predictions, and effects.

See New in Stata 18 to learn about what was added in Stata 18.