Learn R Programming

spdep (version 0.2-9)

errorsarlm: Spatial simultaneous autoregressive error model estimation

Description

Maximum likelihood estimation of spatial simultaneous autoregressive error models of the form:

$$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.

Usage

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)

Arguments

formula
a symbolic description of the model to be fit. The details of model specification are given for lm()
data
an optional data frame containing the variables in the model. By default the variables are taken from the environment which the function is called.
listw
a listw object created for example by nb2listw
na.action
a function (default 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
method
"eigen" (default) - the Jacobian is computed as the product of (1 - rho*eigenvalue) using eigenw , and "sparse" - computes the determinant of the sparse matrix (I - rho*W) directly using logSpwdet.
quiet
default=TRUE; if FALSE, reports function values during optimization.
zero.policy
if TRUE assign zero to the lagged value of zones without neighbours, if FALSE (default) assign NA - causing errorsarlm() to terminate with an error
tol.solve
the tolerance for detecting linear dependencies in the columns of matrices to be inverted - passed to solve() (default=1.0e-7). This may be used if necessary to extract coefficient standard errors (for instance lowering to 1e-10), but errors
tol.opt
the desired accuracy of the optimization - passed to optimize() (default=square root of double precision machine tolerance)
sparsedebug
if TRUE, writes a log file on sparse matrix operations (name sparsestats) in the current directory. To be used if sparse estimation fails!

Value

  • A list object of class sarlm
  • type"error"
  • lambdasimultaneous autoregressive error coefficient
  • coefficientsGLS coefficient estimates
  • rest.seGLS coefficient standard errors (are equal to asymptotic standard errors)
  • LLlog likelihood value at computed optimum
  • s2GLS residual variance
  • SSEsum of squared GLS errors
  • parametersnumber of parameters estimated
  • lm.modelthe lm object returned when estimating for $\lambda=0$
  • methodthe method used to calculate the Jacobian
  • callthe call used to create this object
  • residualsGLS residuals
  • lm.targetthe lm object returned for the GLS fit
  • fitted.valuesDifference between residuals and response variable
  • aseTRUE if method=eigen
  • formulamodel formula
  • se.fitNot used yet
  • lambda.seif ase=TRUE, the asymptotic standard error of $\lambda$
  • LMtestNULL for this model
  • zero.policyzero.policy for this model
  • na.action(possibly) named vector of excluded or omitted observations if non-default na.action argument used
  • The internal sar.error.* functions return the value of the log likelihood function at $\lambda$.

Details

The asymptotic standard error of $\lambda$ is only computed when method=eigen, because the full matrix operations involved would be costly for large n typically associated with the choice of method=sparse.

When 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.

References

Cliff, A. D., Ord, J. K. 1981 Spatial processes, Pion; Ord, J. 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. (Dordrecht: Kluwer); Anselin, L. 1995 SpaceStat, a software program for the analysis of spatial data, version 1.80. Regional Research Institute, West Virginia University, Morgantown, WV (www.spacestat.com); Anselin L, Bera AK (1998) Spatial dependence in linear regression models with an introduction to spatial econometrics. In: Ullah A, Giles DEA (eds) Handbook of applied economic statistics. Marcel Dekker, New York, pp. 237-289.

See Also

lm, lagsarlm, eigenw, logSpwdet, predict.sarlm, residuals.sarlm

Examples

Run this code
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