$$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.
errorsarlm(formula, data=list(), listw, na.action=na.fail, method="eigen",
quiet=TRUE, zero.policy=FALSE, tol.solve=1.0e-7,
tol.opt=.Machine$double.eps^0.5, sparsedebug=FALSE)
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 "sparse" - computes the
determinant of the sparse matrix (I - rho*W) directly using logSpwdet
.errorsarlm()
to terminate with an errorsolve()
(default=1.0e-7). This may be used if necessary to extract coefficient standard errors (for instance lowering to 1e-10), but errors optimize()
(default=square root of double precision machine tolerance)sarlm
lm
object returned when estimating for $\lambda=0$lm
object returned for the GLS fitWhen using the sparse method, the user takes (unfortunately) full
responsibility for possible failures, including R terminating with
a core dump! Safeguards have been put in place to try to trap errant
behaviour in the sparse functions' memory allocation, but they may
not always help. When sparsedebug is TRUE, a log file (sparsestats)
is written in the working directory - the figure of interest is the
number of allocated blocks. At present, spwdet
will fail when
this increases over the number initially allocated, but will not release
memory allocated by the sparse functions. In the event of problems,
save your workspace and quit R. Problems seem to be related to larger
n, and to an unknown trigger precipitating uncontrolled fillin, in the
course of which the sparse routines lose track of their memory pointers,
and then provoke a segmentation fault trying to free unallocated memory.
lm
, lagsarlm
,
eigenw
, logSpwdet
, 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)
COL.errB.eig <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD,
nb2listw(COL.nb, style="B"), method="eigen", quiet=FALSE)
COL.errW.sp <- errorsarlm(CRIME ~ INC + HOVAL, data=COL.OLD,
nb2listw(COL.nb, style="W"), method="sparse", quiet=FALSE)
summary(COL.errW.eig)
summary(COL.errB.eig)
summary(COL.errW.sp)
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