Skip to contents

\(Wy\) is endogenous in \(y = \rho W y + X\beta + e\); it is instrumented by X and the spatial lags \(WX\) (and \(W^2X\) when w2x) of the non-constant columns, plus \(W1\), \(W^21\) when W is not row-standardised (Kelejian and Prucha 1998); a constant lag duplicates the intercept and is dropped. \(\delta = (Z_p'Z_p)^{-1} Z_p'y\) with \(Z_p\) the columns \(\hat{Wy}\) and X, residuals from Z (columns Wy and X), \(Var = s^2 (Z_p'Z_p)^{-1}\), \(s^2 = e'e/(n-k)\), or the HC0 / HC1 sandwich. This is spatialreg::stsls.

Usage

SpatialTwoStageLS(y, X, W, w2x = TRUE, robust = NULL, sig2n_k = TRUE)

Arguments

y

Response.

X

Design matrix.

W

Spatial weights.

w2x

Also use \(W^2 X\).

robust

NULL, "HC0" or "HC1".

sig2n_k

Divide by \(n - k\).

Value

List with coefficients (rho first), se, cov, sigma2, residuals, instruments.

References

Kelejian, H. H. and Prucha, I. R. (1998). A generalized spatial two-stage least squares procedure for estimating a spatial autoregressive model with autoregressive disturbances. Journal of Real Estate Finance and Economics 17, 99-121.

Examples

W <- 1 * (abs(outer(1:6, 1:6, "-")) == 1)
W <- W / rowSums(W)
SpatialTwoStageLS(c(1, 2.2, 1.4, 3.1, .9, 2), cbind(1, c(.1, .6, .2, .9, .3, .5)), W)$coefficients
#> [1] -0.1014857  0.8709669  2.4827006