USCounties {Matrix} | R Documentation |
Contiguity Matrix of U.S. Counties
Description
This matrix gives the contiguities of 3111 U.S. counties, using the queen criterion of at least one shared vertex or edge.
Usage
data(USCounties)
Format
A 3111 \times 3111
sparse, symmetric
matrix of class dsCMatrix
, with 9101
nonzero entries.
Source
GAL lattice file ‘usc_q.GAL’
(retrieved in 2008 from
‘http://sal.uiuc.edu/weights/zips/usc.zip’
with permission from Luc Anselin for use and distribution)
was read into R using function read.gal
from package spdep.
Neighbour lists were augmented with row-standardized
(and then symmetrized) spatial weights, using functions
nb2listw
and similar.listw
from packages
spdep and spatialreg.
The resulting listw
object was coerced to class
dsTMatrix
using as_dsTMatrix_listw
from spatialreg,
and subsequently to class dsCMatrix
.
References
Ord, J. K. (1975). Estimation methods for models of spatial interaction. Journal of the American Statistical Association, 70(349), 120-126. doi:10.2307/2285387
Examples
data(USCounties, package = "Matrix")
(n <- ncol(USCounties))
I <- .symDiagonal(n)
set.seed(1)
r <- 50L
rho <- 1 / runif(r, 0, 0.5)
system.time(MJ0 <- sapply(rho, function(mult)
determinant(USCounties + mult * I, logarithm = TRUE)$modulus))
## Can be done faster by updating the Cholesky factor:
C1 <- Cholesky(USCounties, Imult = 2)
system.time(MJ1 <- sapply(rho, function(mult)
determinant(update(C1, USCounties, mult), sqrt = FALSE)$modulus))
stopifnot(all.equal(MJ0, MJ1))
C2 <- Cholesky(USCounties, super = TRUE, Imult = 2)
system.time(MJ2 <- sapply(rho, function(mult)
determinant(update(C2, USCounties, mult), sqrt = FALSE)$modulus))
stopifnot(all.equal(MJ0, MJ2))