$$y = X \beta + u, u = \lambda W u + \varepsilon$$
where $\lambda$ is found by optimize()
first, and $\beta$ and other parameters by generalized least squares subsequently (one-dimensional search using optim performs badly on some platforms).
errorsarlm(formula, data=list(), listw, na.action=na.fail,
method="eigen", quiet=TRUE, zero.policy=FALSE,
interval = c(-1, 0.999), tol.solve=1.0e-10,
tol.opt=.Machine$double.eps^0.5)
lm()
listw
object created for example by nb2listw
na.fail
), can also be na.omit
or na.exclude
with consequences for residuals and fitted values - in these cases the weights list will be subsetted to remove NAs in the data. It may be necessary to eigenw
, and "spam" or "Matrix" for strictly symmetric weights lists of styles "B" and "C", or made symmetric by similarity (Ord, 1975, Appendix C) if perrorsarlm()
to terminate with an errorsolve()
(default=1.0e-10). This may be used if necessary to extract coefficient standard errors (for instance lowering to 1e-12), but errorsoptim()
(default=square root of double precision machine tolerance, a larger root may be used if the warning: ERROR: ABNORMAL_TERMINATION_IN_LNSRCH is seen, see help(boston) for an example)sarlm
lm
object returned when estimating for $\lambda=0$lm
object returned for the GLS fittol.solve
argument needs to be set to a smaller value than
the default, or the RHS variables can be centred or reduced in range.Note that the fitted() function for the output object assumes that the response variable may be reconstructed as the sum of the trend, the signal, and the noise (residuals). Since the values of the response variable are known, their spatial lags are used to calculate signal components (Cressie 1993, p. 564). This differs from other software, including GeoDa, which does not use knowledge of the response variable in making predictions for the fitting data.
lm
, lagsarlm
, similar.listw
, predict.sarlm
,
residuals.sarlm
data(oldcol)
COL.errW.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD,
nb2listw(COL.nb, style="W"), method="eigen", quiet=FALSE)
summary(COL.errW.eig, correlation=TRUE)
COL.errB.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD,
nb2listw(COL.nb, style="B"), method="eigen", quiet=FALSE)
summary(COL.errB.eig, correlation=TRUE)
COL.errW.M <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD,
nb2listw(COL.nb, style="W"), method="Matrix", quiet=FALSE)
summary(COL.errW.M)
NA.COL.OLD <- COL.OLD
NA.COL.OLD$CRIME[20:25] <- NA
COL.err.NA <- errorsarlm(CRIME ~ INC + HOVAL, data=NA.COL.OLD,
nb2listw(COL.nb), na.action=na.exclude)
COL.err.NA$na.action
COL.err.NA
resid(COL.err.NA)
Run the code above in your browser using DataLab