Learn R Programming

spdep (version 0.1-10)

listw2sn: Spatial neighbour sparse representation

Description

The function makes a spatial neighbour object representation (similar to the S-PLUS spatial statististics module representation of a listw spatial weights object. The object is used in calculating the Jacobian of the likelihood functions of spatial autoregressive models when the "sparse" method is chosen in errorsarlm and lagsarlm.

Usage

listw2sn(listw)
spwdet(sparseweights, rho, debug=FALSE)
log.spwdet(sparseweights, rho, debug=FALSE)

Arguments

listw
a listw object from for example nb2listw
sparseweights
a spatial.neighbour object
rho
spatial autoregressive parameter value
debug
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 data frame with three columns, and with class spatial.neighbour:
  • fromregion number id for the start of the link (S-PLUS row.id)
  • toregion number id for the end of the link (S-PLUS col.id)
  • weightsweight for this link
  • log.spwdet returns log det(I - rho * W).

Details

The methods used for finding the determinant directly by sparse matrix techniques are given by R. Kelley Pace and R. P. Barry (1998), and are implemented here using the sparse library by Kenneth Kundert and Alberto Sangiovanni-Vincentelli; the same reference is used by the S-PLUS spatial statistics module.

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' memmory 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 incontrolled 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

R. Kelley Pace and R. P. Barry (1998) Quick computations of spatially autoregressive estimators, Geographical Analysis 29 (3) 232-247; http://www.spatial-statistics.com/pace_manuscripts/ga_ms_dir/pdf/fin_geo_analysis.pdf.

Files: src/spAllocate.c, src/spBuild.c, src/spConfig.h, src/spDefs.h, src/spFactor.c, src/spMatrix.h, src/spUtils.c are by Kenneth Kundert and Alberto Sangiovanni-Vincentelli, University of California, Berkeley, and are from:

http://www.netlib.org/sparse/index.html

(Kenneth Kundert, Sparse Matrix Techniques, in Circuit Analysis, Simulation and Design, Albert Ruehli (Ed.), North-Holland, 1986)

They are copyright (c) 1985,86,87,88 by Kenneth S. Kundert and the University of California, with the following licence:

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the copyright notices appear in all copies and supporting documentation and that the authors and the University of California are properly credited. The authors and the University of California make no representations as to the suitability of this software for any purpose. It is provided "as is", without express or implied warranty.

See Also

nb2listw, errorsarlm, lagsarlm

Examples

Run this code
data(columbus)
col.listw <- nb2listw(col.gal.nb)
col.listw$neighbours[[1]]
col.listw$weights[[1]]
col.sn <- listw2sn(col.listw)
col.sn[col.sn[,1] == 1,]
rho <- seq(-0.8, 0.9, 0.1)
for (i in rho) print(paste("rho:", i, "log(det(I - rho*W))",
  log.spwdet(col.sn, i)), quote=TRUE)

Run the code above in your browser using DataLab