File: USCounties.Rd

package info (click to toggle)
rmatrix 1.7-5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,156 kB
  • sloc: ansic: 97,207; makefile: 280; sh: 165
file content (71 lines) | stat: -rw-r--r-- 2,186 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
\name{USCounties}
\title{Contiguity Matrix of U.S. Counties}
%
\docType{data}
\keyword{datasets}
%
\alias{USCounties}
%
\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 \eqn{3111 \times 3111}{3111-by-3111} sparse, symmetric
  matrix of class \code{\linkS4class{dsCMatrix}}, with 9101
  nonzero entries.
}
\source{
  GAL lattice file \file{usc_q.GAL}
  (retrieved in 2008 from
  \file{http://sal.uiuc.edu/weights/zips/usc.zip}
  with permission from Luc Anselin for use and distribution)
  was read into \R{} using function \code{read.gal}
  from package \CRANpkg{spdep}.

  Neighbour lists were augmented with row-standardized
  (and then symmetrized) spatial weights, using functions
  \code{nb2listw} and \code{similar.listw} from packages
  \CRANpkg{spdep} and \CRANpkg{spatialreg}.
  The resulting \code{listw} object was coerced to class
  \code{\linkS4class{dsTMatrix}}
  using \code{as_dsTMatrix_listw} from \CRANpkg{spatialreg},
  and subsequently to class \code{\linkS4class{dsCMatrix}}.
}
\references{
  Ord, J. K. (1975).
  Estimation methods for models of spatial interaction.
  \emph{Journal of the American Statistical Association},
  \emph{70}(349), 120-126.
  \doi{10.2307/2285387}
}
\examples{
\dontshow{ % for R_DEFAULT_PACKAGES=NULL
library(stats, pos = "package:base", verbose = FALSE)
library(utils, pos = "package:base", verbose = FALSE)
}
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))
}