Skip to contents

lag: \(y = \rho W y + X\beta + e\); error: \(y = X\beta + u\), \(u = \lambda W u + e\); sac: both. Profiling \(\beta\) and \(\sigma^2\) leaves \(-2\log L = n\log(2\pi\sigma^2) + n - 2\log|I - \rho W| - 2\log|I - \lambda W|\), maximised by stats::optimize (lag, error) or by alternating one-dimensional searches (SAC); log-determinants by LU decomposition. Standard errors: the analytic information matrix for lag and error (Ord 1975; Anselin 1988), a central-difference Hessian of the full log-likelihood for SAC. These match spatialreg::lagsarlm, errorsarlm and sacsarlm with method = "LU".

Usage

SpatialRegressionML(
  y,
  X,
  W,
  model = c("lag", "error", "sac"),
  interval = c(-0.999, 0.999)
)

Arguments

y

Response.

X

Design matrix including any intercept column.

W

Spatial weights matrix.

model

"lag", "error" or "sac".

interval

Search interval for the autoregressive parameters.

Value

List with beta, rho and/or lambda, sigma2, loglik, aic, bic, se.

References

Ord, K. (1975). Estimation methods for models of spatial interaction. Journal of the American Statistical Association 70, 120-126.

Anselin, L. (1988). Spatial Econometrics: Methods and Models. Kluwer.

Examples

W <- matrix(c(0, .5, 0, .5, .5, 0, .5, 0, 0, .5, 0, .5, .5, 0, .5, 0), 4)
SpatialRegressionML(c(1, 2, 1.5, 3), cbind(1, c(.1, .5, .2, .9)), W, model = "error")$loglik
#> [1] 3.615121