diff --git a/docs/404.html b/docs/404.html index 1d5dc7c..62e0300 100644 --- a/docs/404.html +++ b/docs/404.html @@ -32,7 +32,7 @@
diff --git a/docs/articles/SpatialFiltering.html b/docs/articles/SpatialFiltering.html index 1f4e6bd..07818e2 100644 --- a/docs/articles/SpatialFiltering.html +++ b/docs/articles/SpatialFiltering.html @@ -33,7 +33,7 @@ @@ -130,14 +130,20 @@
library(spdep)
require("sf", quietly=TRUE)
-NY8 <- st_read(system.file("shapes/NY8_utm18.shp", package="spData"))
-## Reading layer `NY8_utm18' from data source
-## `/home/rsb/lib/r_libs/spData/shapes/NY8_utm18.shp' using driver `ESRI Shapefile'
-## Simple feature collection with 281 features and 17 fields
-## Geometry type: POLYGON
+if (packageVersion("spData") >= "2.3.2") {
+ NY8 <- sf::st_read(system.file("shapes/NY8_utm18.gpkg", package="spData"))
+} else {
+ NY8 <- sf::st_read(system.file("shapes/NY8_bna_utm18.gpkg", package="spData"))
+ sf::st_crs(NY8) <- "EPSG:32618"
+ NY8$Cases <- NY8$TRACTCAS
+}
+## Reading layer `sf_bna2_utm18' from data source
+## `/home/rsb/lib/r_libs/spData/shapes/NY8_bna_utm18.gpkg' using driver `GPKG'
+## Simple feature collection with 281 features and 12 fields
+## Geometry type: MULTIPOLYGON
## Dimension: XY
-## Bounding box: xmin: 358241.9 ymin: 4649755 xmax: 480393.1 ymax: 4808545
-## Projected CRS: WGS 84 / UTM zone 18N
+## Bounding box: xmin: 357628 ymin: 4649538 xmax: 480360.3 ymax: 4808317
+## Projected CRS: UTM Zone 18, Northern Hemisphere
NY_nb <- read.gal(system.file("weights/NY_nb.gal", package="spData"), override.id=TRUE)
@@ -209,19 +215,23 @@Introduction NYlistwW <- nb2listw(NY_nb, style = "W") set.seed(111)
-nyME <- ME(Cases~PEXPOSURE+PCTAGE65P+PCTOWNHOME, data=NY8, offset=log(POP8), family="poisson", listw=NYlistwW, alpha=0.44)
nyME <- ME(Cases~PEXPOSURE+PCTAGE65P+PCTOWNHOME, data=NY8, offset=log(POP8), family="poisson", listw=NYlistwW, alpha=0.46)
nyME
## Eigenvector ZI pr(ZI)
## 0 NA NA 0.31
-## 1 24 NA 0.44
-## 2 223 NA 0.42
-## 3 206 NA 0.43
-## 4 169 NA 0.48
+## 1 24 NA 0.46
+## 2 164 NA 0.41
+## 3 113 NA 0.44
+## 4 60 NA 0.50
+NY8$eigen_1 <- fitted(nyME)[,1]
+NY8$eigen_2 <- fitted(nyME)[,2]
+
+
nyglmME <- glm(Cases~PEXPOSURE+PCTAGE65P+PCTOWNHOME+offset(log(POP8))+fitted(nyME), data=NY8, family="poisson")
summary(nyglmME)
##
@@ -229,27 +239,27 @@ Introduction ## glm(formula = Cases ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME + offset(log(POP8)) +
## fitted(nyME), family = "poisson", data = NY8)
##
-## Coefficients:
-## Estimate Std. Error z value Pr(>|z|)
-## (Intercept) -8.13431 0.18388 -44.237 < 2e-16 ***
-## PEXPOSURE 0.14136 0.03134 4.511 6.45e-06 ***
-## PCTAGE65P 4.16875 0.60149 6.931 4.19e-12 ***
-## PCTOWNHOME -0.39290 0.19222 -2.044 0.04096 *
-## fitted(nyME)vec24 1.62658 0.72243 2.252 0.02435 *
-## fitted(nyME)vec223 0.92941 0.70391 1.320 0.18671
-## fitted(nyME)vec206 -0.11559 0.68987 -0.168 0.86693
-## fitted(nyME)vec169 -1.82674 0.68142 -2.681 0.00735 **
+## Coefficients: (1 not defined because of singularities)
+## Estimate Std. Error z value Pr(>|z|)
+## (Intercept) -8.123408 0.184525 -44.023 < 2e-16 ***
+## PEXPOSURE 0.144595 0.031469 4.595 4.33e-06 ***
+## PCTAGE65P 4.072265 0.607725 6.701 2.07e-11 ***
+## PCTOWNHOME -0.392118 0.193313 -2.028 0.0425 *
+## fitted(nyME)vec24 1.548573 0.725355 2.135 0.0328 *
+## fitted(nyME)vec164 -0.166982 0.767258 -0.218 0.8277
+## fitted(nyME)vec113 NA NA NA NA
+## fitted(nyME)vec60 -0.001836 0.769811 -0.002 0.9981
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for poisson family taken to be 1)
##
-## Null deviance: 428.25 on 280 degrees of freedom
-## Residual deviance: 340.08 on 273 degrees of freedom
+## Null deviance: 428.84 on 280 degrees of freedom
+## Residual deviance: 349.30 on 274 degrees of freedom
## AIC: Inf
##
## Number of Fisher Scoring iterations: 5
-+nyGLMp <- glm(Cases~PEXPOSURE+PCTAGE65P+PCTOWNHOME+offset(log(POP8)), data=NY8,family="poisson") anova(nyGLMp, nyglmME, test="Chisq")
+## Resid. Df Resid. Dev Df Deviance Pr(>Chi) +## 1 277 354.0 +## 2 274 349.3 3 4.6969 0.1954## Analysis of Deviance Table @@ -257,11 +267,9 @@
Introduction ## Model 1: Cases ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME + offset(log(POP8)) ## Model 2: Cases ~ PEXPOSURE + PCTAGE65P + PCTOWNHOME + offset(log(POP8)) + ## fitted(nyME) -## Resid. Df Resid. Dev Df Deviance Pr(>Chi) -## 1 277 353.35 -## 2 273 340.08 4 13.269 0.01003 * -## --- -## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Figure \[fig:geigen2\] shows the spatial patterns chosen to match the very small amount of spatial autocorrelation remaining in the model. As with the other Poisson diff --git a/docs/articles/SpatialFiltering_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/SpatialFiltering_files/figure-html/unnamed-chunk-6-1.png new file mode 100644 index 0000000..a4a1129 Binary files /dev/null and b/docs/articles/SpatialFiltering_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index c9de137..c47f993 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -17,7 +17,7 @@
## Loading required package: spData
## Loading required package: Matrix
## Loading required package: sf
-## Linking to GEOS 3.12.1, GDAL 3.9.0, PROJ 9.4.0; sf_use_s2() is TRUE
+## Linking to GEOS 3.12.2, GDAL 3.9.0, PROJ 9.4.1; sf_use_s2() is TRUE
## GEOS GDAL proj.4 GDAL_with_GEOS USE_PROJ_H
-## "3.12.1" "3.9.0" "9.4.0" "true" "true"
+## "3.12.2" "3.9.0" "9.4.1" "true" "true"
## PROJ
-## "9.4.0"
+## "9.4.1"
library(sf)
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1])
## Reading layer `columbus' from data source
-## `/home/rsb/lib/r_libs/spData/shapes/columbus.shp' using driver `ESRI Shapefile'
+## `/home/rsb/lib/r_libs/spData/shapes/columbus.gpkg' using driver `GPKG'
## Simple feature collection with 49 features and 20 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: 5.874907 ymin: 10.78863 xmax: 11.28742 ymax: 14.74245
-## CRS: NA
+## Projected CRS: Undefined Cartesian SRS with unknown unit
row.names(columbus)[1:10]
## [1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"
diff --git a/docs/articles/sids_models.html b/docs/articles/sids_models.html
index a7c7117..6365375 100644
--- a/docs/articles/sids_models.html
+++ b/docs/articles/sids_models.html
@@ -33,7 +33,7 @@
@@ -121,7 +121,7 @@ We will be using the spdep and
spatialreg packages, here version: spdep, version
-1.3-4, 2024-05-31, the sf package and the
+1.3-5, 2024-06-02, the sf package and the
tmap package. The data from the sources referred to
above is documented in the help
page for the nc.sids
data set in
@@ -132,8 +132,8 @@
library(spdep)
-nc <- st_read(system.file("shapes/sids.shp", package="spData")[1], quiet=TRUE)
-st_crs(nc) <- "+proj=longlat +datum=NAD27"
+nc <- st_read(system.file("shapes/sids.gpkg", package="spData")[1], quiet=TRUE)
+#st_crs(nc) <- "+proj=longlat +datum=NAD27"
row.names(nc) <- as.character(nc$FIPSNO)
nc$ft.SID74 <- sqrt(1000)*(sqrt(nc$SID74/nc$BIR74) + sqrt((nc$SID74+1)/nc$BIR74))
diff --git a/docs/authors.html b/docs/authors.html
index c2ce1d3..9c22ae4 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -17,7 +17,7 @@
protect errorsarlm
against missing Durbin=
if only intercept
fix longstanding bugs in getVmate
in a non-default side logic branch
add return_impacts=
to lmSLX
to work around issues with aliased variables; impacts should be improved to handle this case when time permits
require("sf", quietly=TRUE)
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
#require("spdep", quietly=TRUE)
col.gal.nb <- spdep::read.gal(system.file("weights/columbus.gal", package="spData")[1])
lmbase <- lm(CRIME ~ INC + HOVAL, data=columbus)
diff --git a/docs/reference/aple.html b/docs/reference/aple.html
index 4a0b37e..85cf2e6 100644
--- a/docs/reference/aple.html
+++ b/docs/reference/aple.html
@@ -17,7 +17,7 @@
wheat <- st_read(system.file("shapes/wheat.shp", package="spData")[1], quiet=TRUE)
+ wheat <- st_read(system.file("shapes/wheat.gpkg", package="spData")[1], quiet=TRUE)
library(spdep)
#>
#> Attaching package: ‘spdep’
diff --git a/docs/reference/aple.mc.html b/docs/reference/aple.mc.html
index 532dbb3..da43ccc 100644
--- a/docs/reference/aple.mc.html
+++ b/docs/reference/aple.mc.html
@@ -17,7 +17,7 @@
@@ -112,7 +112,7 @@ See also
Examples
# \dontrun{
-wheat <- st_read(system.file("shapes/wheat.shp", package="spData")[1], quiet=TRUE)
+wheat <- st_read(system.file("shapes/wheat.gpkg", package="spData")[1], quiet=TRUE)
nbr1 <- spdep::poly2nb(wheat, queen=FALSE)
nbrl <- spdep::nblag(nbr1, 2)
nbr12 <- spdep::nblag_cumul(nbrl)
diff --git a/docs/reference/aple.plot.html b/docs/reference/aple.plot.html
index 77012c9..875f3a2 100644
--- a/docs/reference/aple.plot.html
+++ b/docs/reference/aple.plot.html
@@ -17,7 +17,7 @@
@@ -128,7 +128,7 @@ See also
Examples
# \dontrun{
-wheat <- st_read(system.file("shapes/wheat.shp", package="spData")[1], quiet=TRUE)
+wheat <- st_read(system.file("shapes/wheat.gpkg", package="spData")[1], quiet=TRUE)
nbr1 <- spdep::poly2nb(wheat, queen=FALSE)
nbrl <- spdep::nblag(nbr1, 2)
nbr12 <- spdep::nblag_cumul(nbrl)
diff --git a/docs/reference/do_ldet.html b/docs/reference/do_ldet.html
index b10a757..88a6497 100644
--- a/docs/reference/do_ldet.html
+++ b/docs/reference/do_ldet.html
@@ -17,7 +17,7 @@
diff --git a/docs/reference/eigenw.html b/docs/reference/eigenw.html
index 6e91b66..5aa859f 100644
--- a/docs/reference/eigenw.html
+++ b/docs/reference/eigenw.html
@@ -23,7 +23,7 @@
diff --git a/docs/reference/gstsls.html b/docs/reference/gstsls.html
index 370bfd2..f5c6f65 100644
--- a/docs/reference/gstsls.html
+++ b/docs/reference/gstsls.html
@@ -18,7 +18,7 @@
diff --git a/docs/reference/impacts.html b/docs/reference/impacts.html
index 3fdc36f..71cda4b 100644
--- a/docs/reference/impacts.html
+++ b/docs/reference/impacts.html
@@ -17,7 +17,7 @@
require("sf", quietly=TRUE)
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
#require("spdep", quietly=TRUE)
col.gal.nb <- spdep::read.gal(system.file("weights/columbus.gal", package="spData")[1])
listw <- spdep::nb2listw(col.gal.nb)
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 2ff40b5..0ce5590 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -17,7 +17,7 @@
require("sf", quietly=TRUE)
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
#require("spdep", quietly=TRUE)
col.gal.nb <- spdep::read.gal(system.file("weights/columbus.gal", package="spData")[1])
lm.mod <- lm(CRIME ~ HOVAL + INC, data=columbus)
diff --git a/docs/reference/set.mcOption.html b/docs/reference/set.mcOption.html
index 6470e5a..6a2542b 100644
--- a/docs/reference/set.mcOption.html
+++ b/docs/reference/set.mcOption.html
@@ -17,7 +17,7 @@
# \dontrun{
require(sf, quietly=TRUE)
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
#require(spdep, quietly=TRUE)
col.gal.nb <- spdep::read.gal(system.file("weights/columbus.gal", package="spData")[1])
col.listw <- spdep::nb2listw(col.gal.nb)
@@ -180,11 +180,11 @@ Examples
W <- as(lw, "CsparseMatrix")
system.time(e <- invIrM(nb7rt, rho=0.98, method="solve", feasible=NULL) %*% x)
#> user system elapsed
-#> 0.003 0.000 0.003
+#> 0.003 0.000 0.002
system.time(ee <- powerWeights(W, rho=0.98, X=x))
#> Warning: not converged within order iterations
#> user system elapsed
-#> 0.241 0.001 0.246
+#> 0.170 0.007 0.178
str(attr(ee, "internal"))
#> List of 5
#> $ series: num [1:250] 0.287 0.234 0.201 0.178 0.16 ...
@@ -197,10 +197,10 @@ Examples
# \dontrun{
system.time(ee <- powerWeights(W, rho=0.9, X=x))
#> user system elapsed
-#> 0.195 0.000 0.200
+#> 0.129 0.006 0.135
system.time(ee <- powerWeights(W, rho=0.98, order=1000, X=x))
#> user system elapsed
-#> 0.860 0.000 0.868
+#> 0.795 0.009 0.807
all.equal(e, as(ee, "matrix"), check.attributes=FALSE)
#> [1] TRUE
nb60rt <- spdep::cell2nb(60, 60, torus=TRUE)
@@ -209,7 +209,7 @@ Examples
x <- matrix(rnorm(dim(W)[1]), ncol=1)
system.time(ee <- powerWeights(W, rho=0.3, X=x))
#> user system elapsed
-#> 0.011 0.000 0.011
+#> 0.009 0.000 0.009
str(as(ee, "matrix"))
#> num [1:3600, 1] -0.383 0.207 -0.731 1.552 0.32 ...
#> - attr(*, "dimnames")=List of 2
diff --git a/docs/reference/spautolm.html b/docs/reference/spautolm.html
index 6695535..9b01ce1 100644
--- a/docs/reference/spautolm.html
+++ b/docs/reference/spautolm.html
@@ -17,7 +17,7 @@
require("sf", quietly=TRUE)
-columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+columbus <- st_read(system.file("shapes/columbus.gpkg", package="spData")[1], quiet=TRUE)
#require(spdep, quietly=TRUE)
col.gal.nb <- spdep::read.gal(system.file("weights/columbus.gal", package="spData")[1])
listw <- spdep::nb2listw(col.gal.nb)
@@ -150,11 +150,11 @@ Examples
set.seed(1100)
system.time(trMC <- trW(W, type="MC"))
#> user system elapsed
-#> 0.006 0.000 0.006
+#> 0.005 0.000 0.006
str(trMC)
#> num [1:30] 0 10.91 3.69 5.36 3.64 ...
#> - attr(*, "sd")= num [1:30] NA NA 0.598 0.495 0.489 ...
-#> - attr(*, "timings")= Named num [1:2] 0.006 0.006
+#> - attr(*, "timings")= Named num [1:2] 0.005 0.006
#> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed"
#> - attr(*, "type")= chr "MC"
#> - attr(*, "n")= int 49
@@ -180,10 +180,10 @@ Examples
#> [1] TRUE
system.time(trMat <- trW(W, m=24, type="mult"))
#> user system elapsed
-#> 0.005 0.000 0.005
+#> 0.002 0.000 0.003
str(trMat)
#> num [1:24] 0 10.91 3.65 5.62 3.66 ...
-#> - attr(*, "timings")= Named num [1:2] 0.005 0.005
+#> - attr(*, "timings")= Named num [1:2] 0.002 0.003
#> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed"
#> - attr(*, "type")= chr "mult"
#> - attr(*, "n")= int 49
@@ -192,11 +192,11 @@ Examples
set.seed(1)
system.time(trMC <- trW(W, m=24, type="MC"))
#> user system elapsed
-#> 0.009 0.000 0.009
+#> 0.006 0.000 0.006
str(trMC)
#> num [1:24] 0 10.91 2.44 4.97 2.82 ...
#> - attr(*, "sd")= num [1:24] NA NA 0.618 0.501 0.451 ...
-#> - attr(*, "timings")= Named num [1:2] 0.008 0.009
+#> - attr(*, "timings")= Named num [1:2] 0.006 0.006
#> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed"
#> - attr(*, "type")= chr "MC"
#> - attr(*, "n")= int 49
@@ -206,10 +206,10 @@ Examples
listwS <- similar.listw(listw)
system.time(trmom <- trW(listw=listwS, m=24, type="moments"))
#> user system elapsed
-#> 0.128 0.000 0.128
+#> 0.109 0.000 0.110
str(trmom)
#> num [1:24] 0 124.2 32.7 63.7 33.2 ...
-#> - attr(*, "timings")= Named num [1:2] 0.128 0.128
+#> - attr(*, "timings")= Named num [1:2] 0.109 0.109
#> ..- attr(*, "names")= chr [1:2] "user.self" "elapsed"
#> - attr(*, "type")= chr "moments"
#> - attr(*, "n")= int 506
@@ -225,7 +225,7 @@ Examples
}
system.time(trmomp <- trW(listw=listwS, m=24, type="moments"))
#> user system elapsed
-#> 0.125 0.000 0.127
+#> 0.107 0.000 0.108
if(!get.mcOption()) {
set.ClusterOption(NULL)
stopCluster(cl)