diff --git a/docs/404.html b/docs/404.html index b0a7a428..bc3dcbe6 100644 --- a/docs/404.html +++ b/docs/404.html @@ -32,7 +32,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/articles/CO69.html b/docs/articles/CO69.html index a8127e2f..537198ea 100644 --- a/docs/articles/CO69.html +++ b/docs/articles/CO69.html @@ -33,7 +33,7 @@ spdep - 1.2-8 + 1.3-1 @@ -410,9 +410,9 @@

Spatial weights## 1 2 3 4 5 6 7 8 ## 1 2 5 5 8 1 2 1 ## 1 least connected region: -## E with 1 link +## with 1 link ## 1 most connected region: -## V with 8 links +## with 8 links ## ## Weights style: B ## Weights constants summary: @@ -446,9 +446,9 @@

Spatial weights## 1 2 3 4 5 6 7 8 ## 1 2 5 5 8 1 2 1 ## 1 least connected region: -## E with 1 link +## with 1 link ## 1 most connected region: -## V with 8 links +## with 8 links ## ## Weights style: B ## Weights constants summary: @@ -565,7 +565,7 @@

Measures of spatial autocorrelation Prop_stdR <- lapply(vars, function(x) moran.test(eire_ge1[[x]], listw=lw_std, randomisation=TRUE)) })
##    user  system elapsed 
-##    0.12    0.00    0.12
+## 0.121 0.000 0.121
 res <- sapply(c("MoranN", "MoranR", "GearyN", "GearyR", "Prop_unstdN", "Prop_unstdR", "Prop_stdN", "Prop_stdR"), function(x) sapply(get(x), "[[", "statistic"))
 rownames(res) <- vars
@@ -786,7 +786,7 @@ 

Simulating measures of s Prop_stdSad <- lapply(lm_objs, function(x) lm.morantest.sad(x, listw=lw_std)) })

##    user  system elapsed 
-##   0.065   0.000   0.065
+## 0.067 0.000 0.067
 res <- sapply(c("MoranSad", "Prop_unstdSad", "Prop_stdSad"), function(x) sapply(get(x), "[[", "statistic"))
 rownames(res) <- vars
@@ -839,7 +839,7 @@

Simulating measures of s Prop_stdEx <- lapply(lm_objs, function(x) lm.morantest.exact(x, listw=lw_std)) })
##    user  system elapsed 
-##   0.084   0.001   0.085
+## 0.083 0.000 0.083
 res <- sapply(c("MoranEx", "Prop_unstdEx", "Prop_stdEx"), function(x) sapply(get(x), "[[", "statistic"))
 rownames(res) <- vars
diff --git a/docs/articles/index.html b/docs/articles/index.html index 2ff543d2..3269ee18 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/articles/nb.html b/docs/articles/nb.html index 27fbff1b..ad9ea526 100644 --- a/docs/articles/nb.html +++ b/docs/articles/nb.html @@ -33,7 +33,7 @@ spdep - 1.2-8 + 1.3-1 @@ -132,33 +132,29 @@

Introduction
 library(spdep)
## Loading required package: spData
-
## The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
-## which was just loaded, will retire in October 2023.
-## Please refer to R-spatial evolution reports for details, especially
-## https://r-spatial.org/r/2023/05/15/evolution4.html.
-## It may be desirable to make the sf package available;
-## package maintainers should consider adding sf to Suggests:.
-## The sp package is now running under evolution status 2
-##      (status 2 uses the sf package in place of rgdal)
## Loading required package: sf
-
## Linking to GEOS 3.12.0, GDAL 3.7.1, PROJ 9.2.1; sf_use_s2() is TRUE
-
+
## Linking to GEOS 3.12.0, GDAL 3.7.3, PROJ 9.3.0; sf_use_s2() is TRUE
+
 NY8 <- as(sf::st_read(system.file("shapes/NY8_utm18.shp", package="spData")), "Spatial")
## 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
+##   `/home/rsb/lib/r_libs/spData/shapes/NY8_utm18.shp' using driver `ESRI Shapefile'
+
## Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL
+## Message 1: /home/rsb/lib/r_libs/spData/shapes/NY8_utm18.shp contains polygon(s)
+## with rings with invalid winding order. Autocorrecting them, but that shapefile
+## should be corrected using ogr2ogr for example.
+
## Simple feature collection with 281 features and 17 fields
 ## Geometry type: POLYGON
 ## Dimension:     XY
 ## Bounding box:  xmin: 358241.9 ymin: 4649755 xmax: 480393.1 ymax: 4808545
 ## Projected CRS: WGS 84 / UTM zone 18N
-
+
 NY_nb <- read.gal(system.file("weights/NY_nb.gal", package="spData"), region.id=as.character(as.integer(row.names(NY8))-1L))

For the sake of simplicity in showing how to create neighbour objects, we work on a subset of the map consisting of the census tracts within Syracuse, although the same principles apply to the full data set. We retrieve the part of the neighbour list in Syracuse using the subset method.

-
+
 Syracuse <- NY8[NY8$AREANAME == "Syracuse city",]
 Sy0_nb <- subset(NY_nb, NY8$AREANAME == "Syracuse city")
 summary(Sy0_nb)
@@ -172,9 +168,9 @@

Introduction## 1 2 3 4 5 6 7 8 9 ## 1 1 5 9 14 17 9 6 1 ## 1 least connected region: -## 164 with 1 link +## with 1 link ## 1 most connected region: -## 136 with 9 links

+## with 9 links

Creating Contiguity Neighbours @@ -186,12 +182,12 @@

Creating Contiguity Neighbours
class(Syracuse)
## [1] "SpatialPolygonsDataFrame"
 ## attr(,"package")
 ## [1] "sp"
-
+
 Sy1_nb <- poly2nb(Syracuse)
 isTRUE(all.equal(Sy0_nb, Sy1_nb, check.attributes=FALSE))
## [1] TRUE
@@ -210,11 +206,11 @@

Creating Contiguity Neighbours
+
 Sy2_nb <- poly2nb(Syracuse, queen=FALSE)
 isTRUE(all.equal(Sy0_nb, Sy2_nb, check.attributes=FALSE))
## [1] FALSE
-
+
 oopar <- par(mfrow=c(1,2), mar=c(3,3,1,1)+0.1)
 plot(Syracuse, border="grey60")
 plot(Sy0_nb, coordinates(Syracuse), add=TRUE, pch=19, cex=0.6)
@@ -225,10 +221,10 @@ 

Creating Contiguity Neighbours=TRUE, pch=".", cex=0.6, lwd=2)

## Warning in diffnb(Sy0_nb, Sy2_nb, verbose = FALSE): region.id differ; using ids
 ## of first list
-
+
 text(bbox(Syracuse)[1,1], bbox(Syracuse)[2,2], labels="b)", cex=0.8)

-
+
 par(oopar)

a: Queen-style census tract contiguities, Syracuse; b: Rook-style contiguity differences shown as thicker lines

@@ -250,7 +246,7 @@

Creating Contiguity Neighbours
+
 library(spgrass6)
 writeVECT6(Syracuse, "SY0")
 contig <- vect2neigh("SY0")
@@ -292,12 +288,15 @@ 

Creating Graph-Based Neighbours(Avis and Horton 1985). Functions for graph-based neighbours were kindly contributed by Nicholas Lewin-Koh.

-
+
 coords <- coordinates(Syracuse)
 IDs <- row.names(as(Syracuse, "data.frame"))
 #FIXME library(tripack)
-Sy4_nb <- tri2nb(coords, row.names=IDs)
-if (require(dbscan, quietly=TRUE)) {
+Sy4_nb <- tri2nb(coords, row.names=IDs)
+
## Warning in sn2listw(df1): style is M (missing); style should be set to a valid
+## value
+
+if (require(dbscan, quietly=TRUE)) {
   Sy5_nb <- graph2nb(soi.graph(Sy4_nb, coords), row.names=IDs)
 } else Sy5_nb <- NULL
## 
@@ -305,10 +304,10 @@ 

Creating Graph-Based Neighbours## The following object is masked from 'package:stats': ## ## as.dendrogram

-
+
 Sy6_nb <- graph2nb(gabrielneigh(coords), row.names=IDs)
 Sy7_nb <- graph2nb(relativeneigh(coords), row.names=IDs)
-
+
 oopar <- par(mfrow=c(2,2), mar=c(1,1,1,1)+0.1)
 plot(Syracuse, border="grey60")
 plot(Sy4_nb, coords, add=TRUE, pch=".")
@@ -325,7 +324,7 @@ 

Creating Graph-Based Neighboursplot(Sy7_nb, coords, add=TRUE, pch=".") text(bbox(Syracuse)[1,1], bbox(Syracuse)[2,2], labels="d)", cex=0.8)

-
+
 par(oopar)

a: Delauney triangulation neighbours; b: Sphere of influence neighbours (if available); c: Gabriel graph neighbours; d: Relative @@ -350,14 +349,14 @@

Creating Graph-Based Neighbours -
+
 nb_l <- list(Triangulation=Sy4_nb, Gabriel=Sy6_nb,
   Relative=Sy7_nb)
 if (!is.null(Sy5_nb)) nb_l <- c(nb_l, list(SOI=Sy5_nb))
 sapply(nb_l, function(x) is.symmetric.nb(x, verbose=FALSE, force=TRUE))
## Triangulation       Gabriel      Relative           SOI 
 ##          TRUE         FALSE         FALSE          TRUE
-
+
 sapply(nb_l, function(x) n.comp.nb(x)$nc)
## Triangulation       Gabriel      Relative           SOI 
 ##             1             1             1             1
@@ -374,7 +373,7 @@

Distance-Based Neighboursnb object by knn2nb(); knearneigh() can also take a longlat= argument to handle geographical coordinates.

-
+
 Sy8_nb <- knn2nb(knearneigh(coords, k=1), row.names=IDs)
 Sy9_nb <- knn2nb(knearneigh(coords, k=2), row.names=IDs)
 Sy10_nb <- knn2nb(knearneigh(coords, k=4), row.names=IDs)
@@ -382,11 +381,11 @@ 

Distance-Based Neighbourssapply(nb_l, function(x) is.symmetric.nb(x, verbose=FALSE, force=TRUE))

##    k1    k2    k4 
 ## FALSE FALSE FALSE
-
+
 sapply(nb_l, function(x) n.comp.nb(x)$nc)
## k1 k2 k4 
 ## 15  1  1
-
+
 oopar <- par(mfrow=c(1,3), mar=c(1,1,1,1)+0.1)
 plot(Syracuse, border="grey60")
 plot(Sy8_nb, coords, add=TRUE, pch=".")
@@ -398,7 +397,7 @@ 

Distance-Based Neighboursplot(Sy10_nb, coords, add=TRUE, pch=".") text(bbox(Syracuse)[1,1], bbox(Syracuse)[2,2], labels="c)", cex=0.8)

-
+
 par(oopar)

a: \(k=1\) neighbours; b: \(k=2\) neighbours; c: \(k=4\) neighbours

The figure shows the neighbour relationships for \(k= 1, 2, 4\), with many components for @@ -414,16 +413,16 @@

Distance-Based Neighboursd2 setting the lower and upper distance bounds; it can also take a longlat argument to handle geographical coordinates.

-
+
 dsts <- unlist(nbdists(Sy8_nb, coords))
 summary(dsts)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 ##   395.7   587.3   700.1   760.4   906.1  1544.6
-
+
 max_1nn <- max(dsts)
 max_1nn
## [1] 1544.615
-
+
 Sy11_nb <- dnearneigh(coords, d1=0, d2=0.75*max_1nn, row.names=IDs)
 Sy12_nb <- dnearneigh(coords, d1=0, d2=1*max_1nn, row.names=IDs)
 Sy13_nb <- dnearneigh(coords, d1=0, d2=1.5*max_1nn, row.names=IDs)
@@ -431,11 +430,11 @@ 

Distance-Based Neighbourssapply(nb_l, function(x) is.symmetric.nb(x, verbose=FALSE, force=TRUE))

##   d1   d2   d3 
 ## TRUE TRUE TRUE
-
+
 sapply(nb_l, function(x) n.comp.nb(x)$nc)
## d1 d2 d3 
 ##  4  1  1
-
+
 oopar <- par(mfrow=c(1,3), mar=c(1,1,1,1)+0.1)
 plot(Syracuse, border="grey60")
 plot(Sy11_nb, coords, add=TRUE, pch=".")
@@ -447,7 +446,7 @@ 

Distance-Based Neighboursplot(Sy13_nb, coords, add=TRUE, pch=".") text(bbox(Syracuse)[1,1], bbox(Syracuse)[2,2], labels="c)", cex=0.8)

-
+
 par(oopar)

a: Neighbours within 1,158m; b: neighbours within 1,545m; c: neighbours within 2,317m

@@ -459,7 +458,7 @@

Distance-Based Neighbours -
+
 dS <- c(0.75, 1, 1.5)*max_1nn
 res <- sapply(nb_l, function(x) table(card(x)))
 mx <- max(card(Sy13_nb))
@@ -482,7 +481,7 @@ 

Distance-Based Neighbours -
+
 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
@@ -512,7 +511,7 @@ 

Higher-Order Neighboursnblag() function takes an existing neighbour list and returns a list of lists, from first to maxlag= order neighbours.

-
+
 Sy0_nb_lags <- nblag(Sy0_nb, maxlag=9)
 names(Sy0_nb_lags) <- c("first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth")
 res <- sapply(Sy0_nb_lags, function(x) table(card(x)))
@@ -551,14 +550,14 @@ 

Grid Neighbours -
+
 cell2nb(7, 7, type="rook", torus=TRUE)
## Neighbour list object:
 ## Number of regions: 49 
 ## Number of nonzero links: 196 
 ## Percentage nonzero weights: 8.163265 
 ## Average number of links: 4
-
+
 cell2nb(7, 7, type="rook", torus=FALSE)
## Neighbour list object:
 ## Number of regions: 49 
@@ -575,7 +574,7 @@ 

Grid Neighbours\(63 \times 63\) matrix for Syracuse census tracts, but demanding for a 3,\(103 \times 3\),103 matrix.

-
+
 data(meuse.grid)
 coordinates(meuse.grid) <- c("x", "y")
 gridded(meuse.grid) <- TRUE
@@ -587,7 +586,7 @@ 

Grid Neighbours## Number of nonzero links: 12022 ## Percentage nonzero weights: 0.1248571 ## Average number of links: 3.874315

-
+
 table(card(mg_nb))
## 
 ##    1    2    3    4 
diff --git a/docs/articles/nb_sf.html b/docs/articles/nb_sf.html
index f6f5be87..3a020026 100644
--- a/docs/articles/nb_sf.html
+++ b/docs/articles/nb_sf.html
@@ -33,7 +33,7 @@
       
       
         spdep
-        1.2-8
+        1.3-1
       
     
@@ -229,9 +229,9 @@

Comparison of sp and sf approaches} if (dothis) sf_extSoftVersion()

##           GEOS           GDAL         proj.4 GDAL_with_GEOS     USE_PROJ_H 
-##       "3.12.0"        "3.7.1"        "9.2.1"         "true"         "true" 
+##       "3.12.0"        "3.7.3"        "9.3.0"         "true"         "true" 
 ##           PROJ 
-##        "9.2.1"
+## "9.3.0"

Let us read the GPKG file with valid geometries in to ‘sf’ and ‘sp’ objects:

@@ -258,7 +258,7 @@ 

Contiguity neighbours for pol eps <- sqrt(.Machine$double.eps) system.time(for(i in 1:reps) NY8_sf_1_nb <- poly2nb(NY8_sf, queen=TRUE, snap=eps))/reps

##    user  system elapsed 
-##  0.0946  0.0039  0.0988
+## 0.0925 0.0038 0.0965

Using spatial indices to check intersection of polygons is much faster than the legacy method in poly2nb. From spdep 1.1-7, use is made of GEOS through sf to find candidate @@ -296,15 +296,20 @@

Contiguity neighbours from boundaries used in ASDAR, but with some invalid geometries as mentioned earlier:

-NY8_sf_old <- st_read(system.file("shapes/NY8_utm18.shp", package="spData"), quiet=TRUE)
-table(st_is_valid(NY8_sf_old))
+NY8_sf_old <- st_read(system.file("shapes/NY8_utm18.shp", package="spData"), quiet=TRUE)

+
## Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL
+## Message 1: /home/rsb/lib/r_libs/spData/shapes/NY8_utm18.shp contains polygon(s)
+## with rings with invalid winding order. Autocorrecting them, but that shapefile
+## should be corrected using ogr2ogr for example.
+
+table(st_is_valid(NY8_sf_old))
## 
 ## FALSE  TRUE 
 ##     5   276

We can see that there are a number of differences between the neighbour sets derived from the fully valid geometries and the older partly invalid set:

-
+
 try(NY8_sf_old_1_nb <- poly2nb(NY8_sf_old), silent = TRUE)
 all.equal(NY8_sf_old_1_nb, NY8_sf_1_nb, check.attributes=FALSE)
## [1] "Component 57: Numeric: lengths (4, 5) differ" 
@@ -313,7 +318,7 @@ 

Contiguity neighbours from ## [4] "Component 73: Numeric: lengths (4, 5) differ" ## [5] "Component 260: Numeric: lengths (8, 9) differ"

Using st_make_valid() to make the geometries valid:

-
+
 NY8_sf_old_val <- st_make_valid(NY8_sf_old, dist=0)
 table(st_is_valid(NY8_sf_old_val))
## 
@@ -321,22 +326,22 @@ 

Contiguity neighbours from ## 281

we also see that the geometry type of the geometry column changes:

-
+
 class(st_geometry(NY8_sf_old))
## [1] "sfc_POLYGON" "sfc"
-
+
 class(st_geometry(NY8_sf_old_val))
## [1] "sfc_GEOMETRY" "sfc"

and checking the "sfg" objects, two now have objects of different topological dimensions.

-
+
 table(sapply(st_geometry(NY8_sf_old_val), function(x) class(x)[[2]]))
## 
 ## MULTIPOLYGON      POLYGON 
 ##            3          278

This can be remedied using st_collection_extract() to get the polygon objects:

-
+
 NY8_sf_old_val <- st_collection_extract(NY8_sf_old_val, "POLYGON")
 table(sapply(st_geometry(NY8_sf_old_val), function(x) class(x)[[2]]))
## 
@@ -345,7 +350,7 @@ 

Contiguity neighbours from

However, in making the geometries valid, we change the geometries, so the new sets of neighbours still differ from those made with the valid geometries in the same ways as before imposing validity:

-
+
 try(NY8_sf_old_1_nb_val <- poly2nb(NY8_sf_old_val), silent = TRUE)
 all.equal(NY8_sf_old_1_nb_val, NY8_sf_1_nb, check.attributes=FALSE)
## [1] "Component 57: Numeric: lengths (4, 5) differ" 
@@ -355,7 +360,7 @@ 

Contiguity neighbours from ## [5] "Component 260: Numeric: lengths (8, 9) differ"

The neighbour sets are the same for the old boundaries with or without imposing validity:

-
+
 all.equal(NY8_sf_old_1_nb_val, NY8_sf_old_1_nb, check.attributes=FALSE)
## [1] TRUE
@@ -372,20 +377,20 @@

Finding points for polygon objectsof_largest_polygon=TRUE argument to make sure that the centroid is that of the largest polygon id the observation is made up of more than one external ring:

-
+
 NY8_ct_sf <- st_centroid(st_geometry(NY8_sf), of_largest_polygon=TRUE)

or st_point_on_surface() which guarantees that the point will fall on the surface of a member polygon:

-
+
 NY8_pos_sf <- st_point_on_surface(st_geometry(NY8_sf))

or indeed taking the centre of the largest inscribed circle (the function returns a radius line segment, so we choose the central point, not the point on the circle):

-
+
 if (unname(sf_extSoftVersion()["GEOS"] >= "3.9.0")) 
     NY8_cic_sf <- st_cast(st_inscribed_circle(st_geometry(NY8_sf), nQuadSegs=0), "POINT")[(1:(2*nrow(NY8_sf)) %% 2) != 0]

We need to check whether coordinates are planar or not:

-
+
 st_is_longlat(NY8_ct_sf)
## [1] FALSE
@@ -394,10 +399,13 @@

Graph-based neighbours

From this, we can check the graph-based neighbours (planar coordinates only):

-
+
 suppressPackageStartupMessages(require(deldir))
-NY84_nb <- tri2nb(NY8_ct_sf)
-if (require(dbscan, quietly=TRUE)) {
+NY84_nb <- tri2nb(NY8_ct_sf)
+
## Warning in sn2listw(df1): style is M (missing); style should be set to a valid
+## value
+
+if (require(dbscan, quietly=TRUE)) {
   NY85_nb <- graph2nb(soi.graph(NY84_nb, NY8_ct_sf))
 } else NY85_nb <- NULL
## 
@@ -405,7 +413,7 @@ 

Graph-based neighbours## The following object is masked from 'package:stats': ## ## as.dendrogram

-
+
 NY86_nb <- graph2nb(gabrielneigh(NY8_ct_sf))
 NY87_nb <- graph2nb(relativeneigh(NY8_ct_sf))
@@ -416,44 +424,44 @@

K-nearest neighboursdbscan::kNN() in 2D or 3D building a kd-tree is used:

-
+
 system.time(for (i in 1:reps) NY88_nb_sf <- knn2nb(knearneigh(NY8_ct_sf, k=1)))/reps
##    user  system elapsed 
-##  0.0176  0.0009  0.0185
+## 0.0174 0.0009 0.0183

Legacy code may be used omitting the kd-tree:

-
+
 system.time(for (i in 1:reps) NY89_nb_sf <- knn2nb(knearneigh(NY8_ct_sf, k=1, use_kd_tree=FALSE)))/reps
##    user  system elapsed 
-##  0.0183  0.0009  0.0192
+## 0.0174 0.0013 0.0188

Distance neighbours

Distance neighbours need a threshold - nbdists shows the maximum distance to first nearest neighbour:

-
+
 dsts <- unlist(nbdists(NY88_nb_sf, NY8_ct_sf))
 summary(dsts)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
 ##    82.85   912.85  1801.11  3441.04  4461.26 17033.11
-
+
 max_1nn <- max(dsts)

dnearneigh can also handle Great Circle distances, but this is not demonstrated here, as the data set used is planar:

-
+
 system.time(for (i in 1:reps) NY810_nb <- dnearneigh(NY8_ct_sf, d1=0, d2=0.75*max_1nn))/reps
##    user  system elapsed 
-##  0.0324  0.0012  0.0337
+## 0.0315 0.0011 0.0327

By default, the function uses dbscan::frNN() to build a kd-tree in 2D or 3D which is then used to find distance neighbours. For small n, the argument use_kd_tree=FALSE may speed up computation a little by reverting to legacy code not building a kd-tree first, but in general the differences are so small that the user will not notice:

-
+
 system.time(for (i in 1:reps) NY811_nb <- dnearneigh(NY8_ct_sf, d1=0, d2=0.75*max_1nn, use_kd_tree=FALSE))/reps
##    user  system elapsed 
-##  0.0185  0.0016  0.0202
+## 0.0163 0.0015 0.0178
@@ -464,7 +472,7 @@

Spherical point-based neighbourssf 1.0-0 to use s2 by default has opened up new opportunities where spatial indexing on the sphere may help.

-
+
 pts_ll <- st_transform(NY8_ct_sf, "OGC:CRS84")
 st_is_longlat(pts_ll)
## [1] TRUE
@@ -475,45 +483,45 @@

K-nearest neighbourssf_use_s2() is TRUE, knearneigh() will use spatially indexed points and s2::s2_closest_edges() (see https://github.com/r-spatial/s2/issues/125#issuecomment-860107442)

-
+
 (old_use_s2 <- sf_use_s2())
## [1] TRUE

and performs well with also with larger data sets:

-
+
 sf_use_s2(TRUE)
 system.time(for (i in 1:reps) pts_ll1_nb <- knn2nb(knearneigh(pts_ll, k=6)))/reps
##    user  system elapsed 
-##  0.0254  0.0000  0.0255
+## 0.0252 0.0000 0.0252

For this smaller data set, the legacy approach without spatial indexing is adequate, but slows down as the number of observations increases:

-
+
 sf_use_s2(FALSE)
## Spherical geometry (s2) switched off
-
+
 system.time(for (i in 1:reps) pts_ll2_nb <- knn2nb(knearneigh(pts_ll, k=6)))/reps
##    user  system elapsed 
-##  0.0195  0.0000  0.0195
+## 0.0191 0.0000 0.0191

The WGS84 ellipsoid Great Circle distances differ a very little from the s2 spherical distances, yielding output that here diverges for two tract centroids:

-
+
 all.equal(pts_ll1_nb, pts_ll2_nb, check.attributes=FALSE)
## [1] "Component 52: Mean relative difference: 1.466667"  
 ## [2] "Component 124: Mean relative difference: 0.0251046"
-
+
 pts_ll1_nb[[52]]
## [1] 15 38 48 49 50 53
-
+
 pts_ll2_nb[[52]]
## [1] 37 38 48 49 50 53
-
+
 pts_ll1_nb[[124]]
## [1] 117 122 123 125 133 134
-
+
 pts_ll2_nb[[124]]
## [1] 116 117 123 125 133 134
-
+
 sf_use_s2(old_use_s2)
## Spherical geometry (s2) switched on
@@ -529,9 +537,9 @@

Distance neighbours.

-
+
-
+
 args(dnearneigh)
## function (x, d1, d2, row.names = NULL, longlat = NULL, bounds = c("GE", 
 ##     "LE"), use_kd_tree = TRUE, symtest = FALSE, use_s2 = packageVersion("s2") > 
@@ -540,57 +548,57 @@ 

Distance neighbourss2::s2_dwithin_matrix() is run:

-
+
 if (packageVersion("s2") > "1.0.7") {
   system.time(for (i in 1:(reps/5)) pts_ll3_nb <- dnearneigh(pts_ll, d1=0,
       d2=0.75*max_1nn_ll))/(reps/5)
 }
##    user  system elapsed 
-##  0.0445  0.0000  0.0450
+## 0.0440 0.0000 0.0445

Alternatively, spherical distances can be used with dwithin=FALSE and s2::s2_closest_edges(); although running in similar time, s2::s2_closest_edges() depends on the additional k= argument, which, if mis-set, may miss valid neighbours:

-
+
 system.time(for (i in 1:(reps/5)) pts_ll5_nb <- dnearneigh(pts_ll, d1=0, d2=0.75*max_1nn_ll, dwithin=FALSE))/(reps/5)
##    user  system elapsed 
-##  0.0290  0.0000  0.0295
-
+##   0.027   0.000   0.027
+
 if (packageVersion("s2") > "1.0.7") all.equal(pts_ll3_nb, pts_ll5_nb, check.attributes=FALSE)
## [1] TRUE

Using s2::s2_closest_edges() respects d1 > 0 without requiring a second pass in R, so is faster than s2::s2_dwithin_matrix():

-
+
 if (packageVersion("s2") > "1.0.7") {
   system.time(for (i in 1:(reps/5)) pts_ll3a_nb <- dnearneigh(pts_ll, d1=5,
       d2=0.75*max_1nn_ll, dwithin=FALSE))/(reps/5)
 }
##    user  system elapsed 
-##   0.027   0.000   0.027
+## 0.0270 0.0000 0.0275

Using s2::s2_dwithin_matrix() requires a second pass, one for the lower bound, another for the upper bound, and a set difference operation to find neighbours in the distance band:

-
+
 if (packageVersion("s2") > "1.0.7") {
     system.time(for (i in 1:(reps/5)) pts_ll5a_nb <- dnearneigh(pts_ll, d1=5,
         d2=0.75*max_1nn_ll))/(reps/5)
 }
##    user  system elapsed 
-##  0.0745  0.0000  0.0750
-
+##  0.0725  0.0000  0.0725
+
 if (packageVersion("s2") > "1.0.7") all.equal(pts_ll3a_nb, pts_ll5a_nb, check.attributes=FALSE)
## [1] TRUE

Setting use_s2=FALSE falls back to the legacy version, which uses symmetry to reduce time:

-
+
 system.time(for (i in 1:reps) pts_ll6_nb <- dnearneigh(pts_ll, d1=0, d2=0.75*max_1nn_ll, use_s2=FALSE))/reps
##    user  system elapsed 
-##  0.0099  0.0000  0.0100
+## 0.0097 0.0000 0.0097

Minor differences may occur between the legacy ellipsoid and s2 spherical approaches:

-
+
 all.equal(pts_ll5_nb, pts_ll6_nb, check.attributes=FALSE)
##  [1] "Component 20: Numeric: lengths (6, 5) differ"     
 ##  [2] "Component 28: Numeric: lengths (7, 6) differ"     
@@ -614,11 +622,11 @@ 

Distance neighbours## [20] "Component 235: Numeric: lengths (40, 39) differ" ## [21] "Component 237: Numeric: lengths (14, 15) differ" ## [22] "Component 245: Numeric: lengths (16, 15) differ"

-
+
 system.time(for (i in 1:reps) pts_ll6a_nb <- dnearneigh(pts_ll, d1=5, d2=0.75*max_1nn_ll, use_s2=FALSE))/reps
##    user  system elapsed 
-##  0.0108  0.0000  0.0108
-
+##  0.0097  0.0000  0.0097
+
 if (packageVersion("s2") > "1.0.7") all.equal(pts_ll5a_nb, pts_ll6a_nb, check.attributes=FALSE)
##  [1] "Component 20: Numeric: lengths (6, 5) differ"       
 ##  [2] "Component 28: Numeric: lengths (7, 6) differ"       
@@ -657,7 +665,7 @@ 

Contiguity neighbours for spherical polygon supports2 spatial indexing functionality is accessed in finding candidate neighbours in intersecting geometries.

-
+
 NY8_sf_ll <- st_transform(NY8_sf, "OGC:CRS84")
 st_is_longlat(NY8_sf_ll)
## [1] TRUE
@@ -665,11 +673,11 @@

Contiguity neighbours for spherical polygon supports2_intersects_matrix(), but the results are the same, and because spatial indexing is used, this scales well for larger data sets:

-
+
 system.time(for (i in 1:reps) NY8_sf_1_nb_ll <- poly2nb(NY8_sf_ll, queen=TRUE, snap=eps))/reps
##    user  system elapsed 
-##  0.1598  0.0018  0.1623
-
+##  0.1553  0.0013  0.1572
+
 all.equal(NY8_sf_1_nb, NY8_sf_1_nb_ll, check.attributes=FALSE)
## [1] TRUE
diff --git a/docs/articles/sids.html b/docs/articles/sids.html index 39996058..7cb1cd5e 100644 --- a/docs/articles/sids.html +++ b/docs/articles/sids.html @@ -33,7 +33,7 @@ spdep - 1.2-8 + 1.3-1
@@ -124,8 +124,8 @@

IntroductionGetting the data into R

We will be using the spdep and -spreg packages, here version: spdep, version 1.2-8, -2023-02-27, the sf package and the +spreg packages, here version: spdep, version 1.3-1, +2023-11-03, 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 spData. The actual data, included in a shapefile @@ -396,7 +396,8 @@

Getting the data into R## Percentage nonzero weights: 3.94 ## Average number of links: 3.94 ## 2 regions with no links: -## 37055 37095

+## 37055 37095 +## 3 disjoint connected subgraphs

 plot(st_geometry(nc), border="grey")
 plot(ncCC89, st_centroid(st_geometry(nc), of_largest_polygon), add=TRUE, col="blue")
@@ -469,13 +470,13 @@

Probability mappingnc$low = cut(nc$ch_pmap_low,prbs )

 is_tmap <- FALSE
-if (require(tmap, quietly=TRUE)) is_tmap <- TRUE
+if (require(tmap, quietly=TRUE)) is_tmap <- TRUE
 is_tmap
## [1] TRUE
-library(tmap)
-tm_shape(nc) + tm_fill(c("low", "high"), palette="Set1", title="p-values") +
-  tm_facets(free.scales=FALSE) + tm_layout(panel.labels=c("low", "high"))
+library(tmap) +tm_shape(nc) + tm_fill(c("low", "high"), palette="Set1", title="p-values") + + tm_facets(free.scales=FALSE) + tm_layout(panel.labels=c("low", "high"))

For more complicated thematic maps, it may be helpful to use ColorBrewer (https://colorbrewer2.org) colour palettes. Here we use @@ -497,7 +498,7 @@

Probability mappingnc$pmap <- pmap$pmap

 brks <- c(0,0.001,0.01,0.025,0.05,0.95,0.975,0.99,0.999,1)
-tm_shape(nc) + tm_fill("pmap", breaks=brks, midpoint=0.5, palette="RdBu") + tm_layout(legend.outside=TRUE)
+tm_shape(nc) + tm_fill("pmap", breaks=brks, midpoint=0.5, palette="RdBu") + tm_layout(legend.outside=TRUE)

Marilia Carvalho (personal communication) and Virgilio Gómez Rubio (Gómez-Rubio, Ferrándiz-Ferragud, and @@ -522,7 +523,7 @@

Probability mappingnc$stdres <- rstandard(res)

 brks <- c(-4, -3, -2, -1.5, -1, -0.5, 0.5, 1, 1.5, 2, 3, 4)
-tm_shape(nc) + tm_fill("stdres", breaks=brks, midpoint=0, palette="RdBu") + tm_layout(legend.outside=TRUE)
+tm_shape(nc) + tm_fill("stdres", breaks=brks, midpoint=0, palette="RdBu") + tm_layout(legend.outside=TRUE)

The dispersion is equal to 2.2786188, much greater than unity; we calculate the corrected probability map values by taking the @@ -561,7 +562,7 @@

Probability mapping
 brks <- c(0, 0.25, 0.5, 0.75, 1, 2, 3, 4, 5)
 nc_miss <- st_centroid(st_geometry(nc[card(ncCC89) == 0,]), of_largest_polygon)
-tm_shape(nc) + tm_fill("EB_loc", breaks=brks, midpoint=1, palette="RdBu") + tm_layout(legend.outside=TRUE) + tm_shape(nc_miss) + tm_symbols(shape=8, size=0.5)

+tm_shape(nc) + tm_fill("EB_loc", breaks=brks, midpoint=1, palette="RdBu") + tm_layout(legend.outside=TRUE) + tm_shape(nc_miss) + tm_symbols(shape=8, size=0.5)

The results are shown in Figure \(\ref{EBlocal}\). Like other relevant functions in spdep,EBlocal() takes a @@ -600,7 +601,7 @@

Exploration and modelling of the nc$both <- factor(paste(nc$L_id, nc$M_id, sep=":")) nboth <- length(table(unclass(nc$both)))

-tm_shape(nc) + tm_fill("both", palette="Set1", title="rough\nrectangles") + tm_layout(legend.outside=TRUE)
+tm_shape(nc) + tm_fill("both", palette="Set1", title="rough\nrectangles") + tm_layout(legend.outside=TRUE)

Cressie constructs a transformed SIDS rates variable, 1974–78, for his analyses (with co-workers). We can replicate his stem-and-leaf @@ -685,9 +686,9 @@

Median polish smoothingnc$pred <- c(med$overall + mL_id %*% med$row + mM_id %*% med$col) nc$mp_resid <- nc$ft.SID74 - nc$pred

-out1 <- tm_shape(nc) + tm_fill(c("ft.SID74", "pred")) + tm_facets(free.scales=FALSE) + tm_layout(panel.labels=c("Observed", "Median polish prediction"))
-out2 <- tm_shape(nc) + tm_fill("mp_resid", midpoint=0) + tm_layout(legend.outside=TRUE)
-tmap_arrange(out1, out2, ncol=1)
+out1 <- tm_shape(nc) + tm_fill(c("ft.SID74", "pred")) + tm_facets(free.scales=FALSE) + tm_layout(panel.labels=c("Observed", "Median polish prediction")) +out2 <- tm_shape(nc) + tm_fill("mp_resid", midpoint=0) + tm_layout(legend.outside=TRUE) +tmap_arrange(out1, out2, ncol=1)

The figure shows the median polish smoothing results as three maps, the observed Freeman-Tukey transformed SIDS rates, the fitted smoothed diff --git a/docs/authors.html b/docs/authors.html index 80d2841e..dc7664fa 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1

diff --git a/docs/index.html b/docs/index.html index d57f4206..8fa226c4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -59,7 +59,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/news/index.html b/docs/news/index.html index 38a0c053..78bd13b8 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1

@@ -67,7 +67,16 @@

Changelog

- + +
  • summary.nb, print.nb, summary.listw and print.listw now report the subgraph count from n.comp.nb if it is more than one

  • +
  • subset.nb now reports if the subgraph count of the neighbour object increases on subsetting

  • +
  • adding a zero.policy attribute to functions creating listw objects: nb2listw, sn2listw, mat2listw, nb2listwdist. Default zero.policy= argument updated to use attr(., "zero.policy") in summary.listw, print.listw, moran, moran.test, moran.mc, moran.plot, geary.mc, geary, geary.test, globalG.test, joincount.test, joincount.mc, joincount.multi, localC, localC_perm, localmoran, localmoran_perm, localG, localG_perm, lee, lee.test, lee.mc, lm.morantest, lm.LMtests, sp.mantel.mc, listw2star, lag.listw, lm.morantest, lm.LMtests, subset.listw, EBImoran.mc, LOSH, LOSH.mc, LOSH.cs, lm.morantest.exactand lm.morantest.sad

  • +
  • confusing error message in moran.plot() if no-neighbour cases, but zero.policy=FALSE

  • +
  • replace rgrass7 with rgrass in vignette

  • +
  • fix #133 (edit.nb affected by not attaching sp)

  • +
+
+
  • mat2listw() warning if no style= argument given, or if M" is given https://github.com/r-spatial/spatialreg/issues/24, https://github.com/r-spatial/spatialreg/issues/23.

  • remaining users of run_perm() - localC(), localmoran_bv() and local_joincount_uni() get no_repeat_in_row= arguments.

  • Address 2) in #124; localG_perm() and localmoran_perm() get no_repeat_in_row= arguments to use conditional permutation without replacement by sample vectors; the default implementation uses sampling with replacement, which is acceptable across simulation draws, but arguably less acceptable within draws. Feedback would be valued.

  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 695e3e8d..5f78f8ad 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -6,5 +6,5 @@ articles: nb: nb.html nb_sf: nb_sf.html sids: sids.html -last_built: 2023-08-07T11:50Z +last_built: 2023-11-04T17:52Z diff --git a/docs/reference/COL.OLD.html b/docs/reference/COL.OLD.html index 9645cfd9..ea35c61c 100644 --- a/docs/reference/COL.OLD.html +++ b/docs/reference/COL.OLD.html @@ -22,7 +22,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/EBImoran.mc.html b/docs/reference/EBImoran.mc.html index 82a8b153..db555f47 100644 --- a/docs/reference/EBImoran.mc.html +++ b/docs/reference/EBImoran.mc.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,7 +72,7 @@

Permutation test for empirical Bayes index

-
EBImoran.mc(n, x, listw, nsim, zero.policy = NULL, 
+    
EBImoran.mc(n, x, listw, nsim, zero.policy = attr(listw, "zero.policy"), 
  alternative = "greater", spChk=NULL, return_boot=FALSE,
  subtract_mean_in_numerator=TRUE)
@@ -92,7 +92,7 @@

Arguments

number of permutations

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of "greater" (default), "two.sided", or "less"

@@ -184,7 +184,7 @@

Examples

#> weights: nb2listw(ncCC89_nb, style = "B", zero.policy = TRUE) #> number of simulations + 1: 1000 #> -#> statistic = 0.25789, observed rank = 1000, p-value < 2.2e-16 +#> statistic = 0.25789, observed rank = 998, p-value = 0.004 #> alternative hypothesis: two.sided #> sids.p <- nc.sids$SID74 / nc.sids$BIR74 @@ -197,7 +197,7 @@

Examples

#> weights: nb2listw(ncCC89_nb, style = "B", zero.policy = TRUE) #> number of simulations + 1: 1000 #> -#> statistic = 0.20904, observed rank = 1000, p-value < 2.2e-16 +#> statistic = 0.20904, observed rank = 999, p-value = 0.002 #> alternative hypothesis: two.sided #>

diff --git a/docs/reference/EBest.html b/docs/reference/EBest.html index 616abbad..13278660 100644 --- a/docs/reference/EBest.html +++ b/docs/reference/EBest.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1

diff --git a/docs/reference/EBlocal.html b/docs/reference/EBlocal.html index 44886cbd..fd484536 100644 --- a/docs/reference/EBlocal.html +++ b/docs/reference/EBlocal.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/LOSH.cs.html b/docs/reference/LOSH.cs.html index 305bb966..964cbf83 100644 --- a/docs/reference/LOSH.cs.html +++ b/docs/reference/LOSH.cs.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,7 +72,7 @@

Chi-square based test for local spatial heteroscedasticity

-
LOSH.cs(x, listw, zero.policy = NULL, na.action = na.fail, 
+    
LOSH.cs(x, listw, zero.policy = attr(listw, "zero.policy"), na.action = na.fail, 
                  p.adjust.method = "none", spChk = NULL)
@@ -85,7 +85,7 @@

Arguments

a listw object created for example by nb2listw

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

na.action

a function (default na.fail), can also be na.omit or na.exclude - in these cases the weights list will be subsetted to remove NAs in the data. It may be necessary to set zero.policy to TRUE because this subsetting may create no-neighbour observations. Note that only weights lists created without using the glist argument to nb2listw may be subsetted. If na.pass is used, zero is substituted for NA values in calculating the spatial lag. (Note that na.exclude will only work properly starting from R 1.9.0, na.omit and na.exclude assign the wrong classes in 1.8.*)

diff --git a/docs/reference/LOSH.html b/docs/reference/LOSH.html index 119cdc48..ec9b7a11 100644 --- a/docs/reference/LOSH.html +++ b/docs/reference/LOSH.html @@ -19,7 +19,7 @@ spdep - 1.2-8 + 1.3-1
@@ -76,7 +76,8 @@

Local spatial heteroscedasticity

-
LOSH(x, listw, a=2, var_hi=TRUE, zero.policy=NULL, na.action=na.fail, spChk=NULL)
+
LOSH(x, listw, a=2, var_hi=TRUE, zero.policy=attr(listw, "zero.policy"),
+ na.action=na.fail, spChk=NULL)
@@ -94,7 +95,7 @@

Arguments

default TRUE, the moments and the test statistics are calculated for each location; if FALSE, only the plain LOSH measures, \(\bar{x}_i\) and \(e_i\) are calculated

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

na.action

a function (default na.fail), can also be na.omit or na.exclude - in these cases the weights list will be subsetted to remove NAs in the data. It may be necessary to set zero.policy to TRUE because this subsetting may create no-neighbour observations. Note that only weights lists created without using the glist argument to nb2listw may be subsetted. If na.pass is used, zero is substituted for NA values in calculating the spatial lag. (Note that na.exclude will only work properly starting from R 1.9.0, na.omit and na.exclude assign the wrong classes in 1.8.*)

diff --git a/docs/reference/LOSH.mc-1.png b/docs/reference/LOSH.mc-1.png index 0775e406..5a905795 100644 Binary files a/docs/reference/LOSH.mc-1.png and b/docs/reference/LOSH.mc-1.png differ diff --git a/docs/reference/LOSH.mc.html b/docs/reference/LOSH.mc.html index 576ec878..c0a6763a 100644 --- a/docs/reference/LOSH.mc.html +++ b/docs/reference/LOSH.mc.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,8 +72,8 @@

Bootstrapping-based test for local spatial heteroscedasticity

-
LOSH.mc(x, listw, a = 2, nsim = 99, zero.policy = NULL, na.action = na.fail, 
-                    spChk = NULL, adjust.n = TRUE, p.adjust.method = "none")
+
LOSH.mc(x, listw, a = 2, nsim = 99, zero.policy = attr(listw, "zero.policy"),
+ na.action = na.fail, spChk = NULL, adjust.n = TRUE, p.adjust.method = "none")
@@ -91,7 +91,7 @@

Arguments

the number of randomisations used in the bootstrap

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

na.action

a function (default na.fail), can also be na.omit or na.exclude - in these cases the weights list will be subsetted to remove NAs in the data. It may be necessary to set zero.policy to TRUE because this subsetting may create no-neighbour observations. Note that only weights lists created without using the glist argument to nb2listw may be subsetted. If na.pass is used, zero is substituted for NA values in calculating the spatial lag. (Note that na.exclude will only work properly starting from R 1.9.0, na.omit and na.exclude assign the wrong classes in 1.8.*)

@@ -154,10 +154,10 @@

Examples

summary(resLOSH_mc) #> Hi x_bar_i ei Pr() #> Min. :0.03438 Min. :13.85 Min. : 0.0298 Min. :0.009901 -#> 1st Qu.:0.23838 1st Qu.:24.71 1st Qu.: 7.0114 1st Qu.:0.138614 -#> Median :0.66689 Median :35.90 Median : 52.1094 Median :0.683168 -#> Mean :1.06592 Mean :34.88 Mean : 151.9232 Mean :0.546373 -#> 3rd Qu.:1.59680 3rd Qu.:45.39 3rd Qu.: 105.0551 3rd Qu.:0.881188 +#> 1st Qu.:0.23838 1st Qu.:24.71 1st Qu.: 7.0114 1st Qu.:0.118812 +#> Median :0.66689 Median :35.90 Median : 52.1094 Median :0.702970 +#> Mean :1.06592 Mean :34.88 Mean : 151.9232 Mean :0.542332 +#> 3rd Qu.:1.59680 3rd Qu.:45.39 3rd Qu.: 105.0551 3rd Qu.:0.891089 #> Max. :4.68765 Max. :54.91 Max. :2455.2201 Max. :0.990099 resLOSH_cs <- LOSH.cs(columbus$CRIME, nb2listw(col.gal.nb)) summary(resLOSH_cs) diff --git a/docs/reference/aggregate.nb.html b/docs/reference/aggregate.nb.html index 5a9c72ea..be8ed0bb 100644 --- a/docs/reference/aggregate.nb.html +++ b/docs/reference/aggregate.nb.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/airdist.html b/docs/reference/airdist.html index 8c28ca46..67c50e89 100644 --- a/docs/reference/airdist.html +++ b/docs/reference/airdist.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/autocov_dist.html b/docs/reference/autocov_dist.html index eacaf01e..630c96fb 100644 --- a/docs/reference/autocov_dist.html +++ b/docs/reference/autocov_dist.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/bhicv.html b/docs/reference/bhicv.html index 7c8eee35..2e1f9102 100644 --- a/docs/reference/bhicv.html +++ b/docs/reference/bhicv.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1
@@ -105,7 +105,7 @@

Examples

bh <- st_read(system.file("etc/shapes/bhicv.shp",
       package="spdep")[1])
 #> Reading layer `bhicv' from data source 
-#>   `/tmp/Rtmp9t5Oi5/temp_libpath69bae5a08dacc/spdep/etc/shapes/bhicv.shp' 
+#>   `/tmp/Rtmpu0jdcX/temp_libpath70612704761e5/spdep/etc/shapes/bhicv.shp' 
 #>   using driver `ESRI Shapefile'
 #> Simple feature collection with 98 features and 8 fields
 #> Geometry type: POLYGON
diff --git a/docs/reference/card.html b/docs/reference/card.html
index 9a5119c7..660297cc 100644
--- a/docs/reference/card.html
+++ b/docs/reference/card.html
@@ -18,7 +18,7 @@
       
       
         spdep
-        1.2-8
+        1.3-1
       
     
diff --git a/docs/reference/cell2nb.html b/docs/reference/cell2nb.html index 15575086..9b67215a 100644 --- a/docs/reference/cell2nb.html +++ b/docs/reference/cell2nb.html @@ -21,7 +21,7 @@ spdep - 1.2-8 + 1.3-1
@@ -137,9 +137,9 @@

Examples

#> 2 3 4 #> 4 20 25 #> 4 least connected regions: -#> 1:1 7:1 1:7 7:7 with 2 links +#> with 2 links #> 25 most connected regions: -#> 2:2 3:2 4:2 5:2 6:2 2:3 3:3 4:3 5:3 6:3 2:4 3:4 4:4 5:4 6:4 2:5 3:5 4:5 5:5 6:5 2:6 3:6 4:6 5:6 6:6 with 4 links +#> with 4 links xyc <- attr(nb7rt, "region.id") xy <- matrix(as.integer(unlist(strsplit(xyc, ":"))), ncol=2, byrow=TRUE) plot(nb7rt, xy) @@ -156,9 +156,9 @@

Examples

#> 4 #> 49 #> 49 least connected regions: -#> 1:1 2:1 3:1 4:1 5:1 6:1 7:1 1:2 2:2 3:2 4:2 5:2 6:2 7:2 1:3 2:3 3:3 4:3 5:3 6:3 7:3 1:4 2:4 3:4 4:4 5:4 6:4 7:4 1:5 2:5 3:5 4:5 5:5 6:5 7:5 1:6 2:6 3:6 4:6 5:6 6:6 7:6 1:7 2:7 3:7 4:7 5:7 6:7 7:7 with 4 links +#> with 4 links #> 49 most connected regions: -#> 1:1 2:1 3:1 4:1 5:1 6:1 7:1 1:2 2:2 3:2 4:2 5:2 6:2 7:2 1:3 2:3 3:3 4:3 5:3 6:3 7:3 1:4 2:4 3:4 4:4 5:4 6:4 7:4 1:5 2:5 3:5 4:5 5:5 6:5 7:5 1:6 2:6 3:6 4:6 5:6 6:6 7:6 1:7 2:7 3:7 4:7 5:7 6:7 7:7 with 4 links +#> with 4 links run <- FALSE if (require("sp", quietly=TRUE)) run <- TRUE if (run) { diff --git a/docs/reference/choynowski.html b/docs/reference/choynowski.html index a6f6b91a..6eb4b58b 100644 --- a/docs/reference/choynowski.html +++ b/docs/reference/choynowski.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1

diff --git a/docs/reference/columbus.html b/docs/reference/columbus.html index fca7ad88..01b9e3d7 100644 --- a/docs/reference/columbus.html +++ b/docs/reference/columbus.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/compon.html b/docs/reference/compon.html index a2048691..d047f12a 100644 --- a/docs/reference/compon.html +++ b/docs/reference/compon.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1

diff --git a/docs/reference/diffnb.html b/docs/reference/diffnb.html index 174b88dc..9f889c20 100644 --- a/docs/reference/diffnb.html +++ b/docs/reference/diffnb.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1

diff --git a/docs/reference/dnearneigh.html b/docs/reference/dnearneigh.html index 8c069772..afbf4662 100644 --- a/docs/reference/dnearneigh.html +++ b/docs/reference/dnearneigh.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -143,46 +143,15 @@

Examples

#> Number of nonzero links: 252 #> Percentage nonzero weights: 10.49563 #> Average number of links: 5.142857 +#> 2 disjoint connected subgraphs #> Link number distribution: #> #> 1 2 3 4 5 6 7 8 9 10 11 #> 4 8 6 2 5 8 6 2 6 1 1 #> 4 least connected regions: -#> 6 10 21 47 with 1 link +#> with 1 link #> 1 most connected region: -#> 28 with 11 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.1276 0.3608 0.4566 0.4331 0.5224 0.6189 -#> -#> The decimal point is 2 digit(s) to the left of the | -#> -#> 12 | 88 -#> 14 | 44 -#> 16 | -#> 18 | 7788 -#> 20 | 0033 -#> 22 | 772277 -#> 24 | 4488 -#> 26 | 8822 -#> 28 | 2244 -#> 30 | 00334466 -#> 32 | 11114444001188 -#> 34 | 0033446633 -#> 36 | 1133559900335588 -#> 38 | 1133668899003355 -#> 40 | 44557777222266 -#> 42 | 990022333399 -#> 44 | 3322777799 -#> 46 | 22223344666677001111225588 -#> 48 | 00000011222299 -#> 50 | 1122888800557799 -#> 52 | 22223333446600 -#> 54 | 00333377001133556677 -#> 56 | 111133446666 -#> 58 | 0022337799 -#> 60 | 2299111199 -#> +#> with 11 links opar <- par(no.readonly=TRUE) plot(st_geometry(columbus), border="grey", reset=FALSE, main=paste("Distance based neighbours 0-", format(all.linked), sep="")) @@ -223,31 +192,15 @@

Examples

#> Number of nonzero links: 190 #> Percentage nonzero weights: 8.246528 #> Average number of links: 3.958333 +#> 5 disjoint connected subgraphs #> Link number distribution: #> #> 1 2 3 4 5 7 8 9 10 #> 11 9 4 8 4 4 4 3 1 #> 11 least connected regions: -#> 2 4 8 10 24 26 29 32 35 41 45 with 1 link +#> with 1 link #> 1 most connected region: -#> 28 with 10 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 93.66 293.14 360.45 354.22 448.26 542.97 -#> -#> The decimal point is 2 digit(s) to the right of the | -#> -#> 0 | 99 -#> 1 | 00112233 -#> 1 | 666699 -#> 2 | 00222222334444444444 -#> 2 | 667788999999 -#> 3 | 000000001111111122222222222233333333334444 -#> 3 | 555566666677777788888899999999 -#> 4 | 0000001111223344 -#> 4 | 5555555555556666667777888888888899 -#> 5 | 00000011111122334444 -#> +#> with 10 links gck1 <- knn2nb(knearneigh(xy, k=1, longlat=TRUE)) (all.linked <- max(unlist(nbdists(gck1, xy, longlat=TRUE)))) #> [1] 523.5819 @@ -258,31 +211,15 @@

Examples

#> Number of nonzero links: 220 #> Percentage nonzero weights: 9.548611 #> Average number of links: 4.583333 +#> 2 disjoint connected subgraphs #> Link number distribution: #> #> 1 2 3 4 5 6 7 8 9 10 #> 5 9 6 8 5 2 3 3 5 2 #> 5 least connected regions: -#> 2 4 8 41 45 with 1 link +#> with 1 link #> 2 most connected regions: -#> 7 28 with 10 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 93.66 304.16 381.26 371.99 467.80 523.58 -#> -#> The decimal point is 2 digit(s) to the right of the | -#> -#> 0 | 99 -#> 1 | 00112233 -#> 1 | 666699 -#> 2 | 00222222334444444444 -#> 2 | 667788999999 -#> 3 | 000000001111111122222222222233333333334444 -#> 3 | 555566666677777788888899999999 -#> 4 | 00000011112233334444 -#> 4 | 555555555555666666666677778888888888889999 -#> 5 | 00000000000000111111111122222222222222 -#> +#> with 10 links plot(ll.nb, xy) plot(diffnb(ll.nb, gc.nb), xy, add=TRUE, col="red", lty=2) title(main="Differences Euclidean/Great Circle") @@ -302,7 +239,7 @@

Examples

gck1b <- knn2nb(knearneigh(xy1, k=1)) system.time(o <- nbdists(gck1b, xy1)) #> user system elapsed -#> 0.006 0.000 0.006 +#> 0.007 0.000 0.006 (all.linked <- max(unlist(o))) #> [1] 522.4464 # use s2 brute-force dwithin_matrix approach for s2 <= 1.0.7 @@ -315,42 +252,26 @@

Examples

#> Number of nonzero links: 220 #> Percentage nonzero weights: 9.548611 #> Average number of links: 4.583333 +#> 2 disjoint connected subgraphs #> Link number distribution: #> #> 1 2 3 4 5 6 7 8 9 10 #> 5 9 6 8 5 2 3 3 5 2 #> 5 least connected regions: -#> 2 4 8 41 45 with 1 link +#> with 1 link #> 2 most connected regions: -#> 7 28 with 10 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 93.71 303.44 380.87 371.83 468.73 522.45 -#> -#> The decimal point is 2 digit(s) to the right of the | -#> -#> 0 | 99 -#> 1 | 00112233 -#> 1 | 666699 -#> 2 | 00222222334444444444 -#> 2 | 667788999999 -#> 3 | 000000001111111122222222222233333333334444 -#> 3 | 555566666677777788888899999999 -#> 4 | 0000001111223333444444 -#> 4 | 55555555556666666666777788888888889999999999 -#> 5 | 0000000000111111111111222222222222 -#> +#> with 10 links # use s2 closest_edges approach s2 > 1.0.7 if (packageVersion("s2") > "1.0.7") { (system.time(gc.nb.closest <- dnearneigh(xy1, 0, all.linked, dwithin=FALSE))) } #> user system elapsed -#> 0.007 0.000 0.007 +#> 0.008 0.000 0.008 if (packageVersion("s2") > "1.0.7") { system.time(gc.nb.dwithin <- dnearneigh(xy1, 0, all.linked, use_s2=TRUE, dwithin=TRUE)) } #> user system elapsed -#> 0.009 0.000 0.010 +#> 0.010 0.000 0.009 if (packageVersion("s2") > "1.0.7") { summary(gc.nb.dwithin, xy1, scale=0.5) } @@ -361,29 +282,15 @@

Examples

#> Average number of links: 4.541667 #> 1 region with no links: #> 2 +#> 3 disjoint connected subgraphs #> Link number distribution: #> #> 0 1 2 3 4 5 6 7 8 9 10 #> 1 5 8 6 8 5 2 3 3 5 2 #> 5 least connected regions: -#> 4 8 29 41 45 with 1 link +#> with 1 link #> 2 most connected regions: -#> 7 28 with 10 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0 649 1289 1567 2347 3939 -#> -#> The decimal point is 3 digit(s) to the right of the | -#> -#> 0 | 0000111122222233333333334444444 -#> 0 | 5555555555556666666666666777777777888888888899999999999 -#> 1 | 00000001111111222223333333333334444444 -#> 1 | 555555677777888888999999999 -#> 2 | 01112223333344 -#> 2 | 5566667778889999 -#> 3 | 00001111123333444 -#> 3 | 55566666667778888899 -#> +#> with 10 links if (packageVersion("s2") > "1.0.7") { summary(gc.nb.closest, xy1, scale=0.5) } @@ -394,64 +301,34 @@

Examples

#> Average number of links: 4.541667 #> 1 region with no links: #> 2 +#> 3 disjoint connected subgraphs #> Link number distribution: #> #> 0 1 2 3 4 5 6 7 8 9 10 #> 1 5 8 6 8 5 2 3 3 5 2 #> 5 least connected regions: -#> 4 8 29 41 45 with 1 link +#> with 1 link #> 2 most connected regions: -#> 7 28 with 10 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0 649 1289 1567 2347 3939 -#> -#> The decimal point is 3 digit(s) to the right of the | -#> -#> 0 | 0000111122222233333333334444444 -#> 0 | 5555555555556666666666666777777777888888888899999999999 -#> 1 | 00000001111111222223333333333334444444 -#> 1 | 555555677777888888999999999 -#> 2 | 01112223333344 -#> 2 | 5566667778889999 -#> 3 | 00001111123333444 -#> 3 | 55566666667778888899 -#> +#> with 10 links # use legacy symmetric brute-force approach system.time(gc.nb.legacy <- dnearneigh(xy1, 0, all.linked, use_s2=FALSE)) #> user system elapsed -#> 0.003 0.000 0.004 +#> 0.003 0.000 0.003 summary(gc.nb, xy1, scale=0.5) #> Neighbour list object: #> Number of regions: 48 #> Number of nonzero links: 220 #> Percentage nonzero weights: 9.548611 #> Average number of links: 4.583333 +#> 2 disjoint connected subgraphs #> Link number distribution: #> #> 1 2 3 4 5 6 7 8 9 10 #> 5 9 6 8 5 2 3 3 5 2 #> 5 least connected regions: -#> 2 4 8 41 45 with 1 link +#> with 1 link #> 2 most connected regions: -#> 7 28 with 10 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 93.71 303.44 380.87 371.83 468.73 522.45 -#> -#> The decimal point is 2 digit(s) to the right of the | -#> -#> 0 | 99 -#> 1 | 00112233 -#> 1 | 666699 -#> 2 | 00222222334444444444 -#> 2 | 667788999999 -#> 3 | 000000001111111122222222222233333333334444 -#> 3 | 555566666677777788888899999999 -#> 4 | 0000001111223333444444 -#> 4 | 55555555556666666666777788888888889999999999 -#> 5 | 0000000000111111111111222222222222 -#> +#> with 10 links if (packageVersion("s2") > "1.0.7") all.equal(gc.nb.closest, gc.nb.dwithin, check.attributes=FALSE) #> [1] TRUE # legacy is ellipsoidal, s2 spherical, so minor differences expected diff --git a/docs/reference/droplinks.html b/docs/reference/droplinks.html index 426b43a3..fff21381 100644 --- a/docs/reference/droplinks.html +++ b/docs/reference/droplinks.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1

diff --git a/docs/reference/edit.nb.html b/docs/reference/edit.nb.html index 82cf289f..44773c64 100644 --- a/docs/reference/edit.nb.html +++ b/docs/reference/edit.nb.html @@ -22,7 +22,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/eire.html b/docs/reference/eire.html index 65132f18..431eb6a7 100644 --- a/docs/reference/eire.html +++ b/docs/reference/eire.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/geary.html b/docs/reference/geary.html index e9686fd1..6d156a86 100644 --- a/docs/reference/geary.html +++ b/docs/reference/geary.html @@ -22,7 +22,7 @@ spdep - 1.2-8 + 1.3-1
@@ -82,7 +82,7 @@

Compute Geary's C

-
geary(x, listw, n, n1, S0, zero.policy=NULL)
+    
geary(x, listw, n, n1, S0, zero.policy=attr(listw, "zero.policy"))
 <!-- %geary.intern(x, listw, n, zero.policy, type="geary") -->
@@ -104,7 +104,7 @@

Arguments

global sum of weights

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

diff --git a/docs/reference/geary.mc.html b/docs/reference/geary.mc.html index cf7a9567..236e80b0 100644 --- a/docs/reference/geary.mc.html +++ b/docs/reference/geary.mc.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,7 +72,7 @@

Permutation test for Geary's C statistic

-
geary.mc(x, listw, nsim, zero.policy=NULL, alternative="greater",
+    
geary.mc(x, listw, nsim, zero.policy=attr(listw, "zero.policy"), alternative="greater",
  spChk=NULL, adjust.n=TRUE, return_boot=FALSE)
@@ -88,7 +88,7 @@

Arguments

number of permutations

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of "greater" (default), or "less"; this reversal corresponds to that on geary.test described in the section on the output statistic value, based on Cliff and Ord 1973, p. 21 (changed 2011-04-11, thanks to Daniel Garavito).

@@ -160,12 +160,12 @@

Examples

#> alternative hypothesis: less #> mean(sim1$res) -#> [1] 0.9949109 +#> [1] 1.012612 var(sim1$res) -#> [1] 0.01038392 +#> [1] 0.0119779 summary(sim1$res) #> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.5299 0.9488 0.9967 0.9949 1.0598 1.2113 +#> 0.5299 0.9401 1.0218 1.0126 1.0906 1.2388 colold.lags <- nblag(COL.nb, 3) sim2 <- geary.mc(COL.OLD$CRIME, nb2listw(colold.lags[[2]], style="W"), nsim=99) @@ -177,12 +177,12 @@

Examples

#> weights: nb2listw(colold.lags[[2]], style = "W") #> number of simulations + 1: 100 #> -#> statistic = 0.81129, observed rank = 4, p-value = 0.04 +#> statistic = 0.81129, observed rank = 1, p-value = 0.01 #> alternative hypothesis: greater #> summary(sim2$res) #> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.7273 0.9338 0.9860 0.9879 1.0482 1.1900 +#> 0.8113 0.9541 1.0113 1.0014 1.0569 1.1619 sim3 <- geary.mc(COL.OLD$CRIME, nb2listw(colold.lags[[3]], style="W"), nsim=99) sim3 @@ -193,12 +193,12 @@

Examples

#> weights: nb2listw(colold.lags[[3]], style = "W") #> number of simulations + 1: 100 #> -#> statistic = 1.1303, observed rank = 94, p-value = 0.94 +#> statistic = 1.1303, observed rank = 92, p-value = 0.92 #> alternative hypothesis: greater #> summary(sim3$res) #> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.8289 0.9117 0.9835 0.9821 1.0344 1.2064 +#> 0.8264 0.9586 1.0079 1.0099 1.0562 1.2047

diff --git a/docs/reference/geary.test.html b/docs/reference/geary.test.html index fec92096..5de2c5e6 100644 --- a/docs/reference/geary.test.html +++ b/docs/reference/geary.test.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,7 +72,7 @@

Geary's C test for spatial autocorrelation

-
geary.test(x, listw, randomisation=TRUE, zero.policy=NULL,
+    
geary.test(x, listw, randomisation=TRUE, zero.policy=attr(listw, "zero.policy"),
     alternative="greater", spChk=NULL, adjust.n=TRUE)
@@ -88,7 +88,7 @@

Arguments

variance of I calculated under the assumption of randomisation, if FALSE normality

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of "greater" (default), "less" or "two.sided".

diff --git a/docs/reference/globalG.test.html b/docs/reference/globalG.test.html index c39bd3f1..7671ad62 100644 --- a/docs/reference/globalG.test.html +++ b/docs/reference/globalG.test.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,7 +72,7 @@

Global G test for spatial autocorrelation

-
globalG.test(x, listw, zero.policy=NULL, alternative="greater",
+    
globalG.test(x, listw, zero.policy=attr(listw, "zero.policy"), alternative="greater",
  spChk=NULL, adjust.n=TRUE, B1correct=TRUE, adjust.x=TRUE, Arc_all_x=FALSE)
@@ -85,7 +85,7 @@

Arguments

a listw object created for example by nb2listw; if a sequence of distance bands is to be used, it is recommended that the weights style be binary (one of c("B", "C", "U")).

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of "greater" (default), "less" or "two.sided".

diff --git a/docs/reference/graphneigh.html b/docs/reference/graphneigh.html index 28c7c1cc..f41bced1 100644 --- a/docs/reference/graphneigh.html +++ b/docs/reference/graphneigh.html @@ -20,7 +20,7 @@ spdep - 1.2-8 + 1.3-1
@@ -211,6 +211,7 @@

Examples

sp_obj <- as(sf_obj, "Spatial") coords <- st_coordinates(sf_obj) suppressMessages(col.tri.nb <- tri2nb(coords)) +#> Warning: style is M (missing); style should be set to a valid value col.gab.nb <- graph2nb(gabrielneigh(coords), sym=TRUE) col.rel.nb <- graph2nb(relativeneigh(coords), sym=TRUE) par(mfrow=c(2,2)) @@ -237,9 +238,11 @@

Examples

par(mfrow=c(1,1)) col.tri.nb_sf <- tri2nb(sf_obj) +#> Warning: style is M (missing); style should be set to a valid value all.equal(col.tri.nb, col.tri.nb_sf, check.attributes=FALSE) #> [1] TRUE col.tri.nb_sp <- tri2nb(sp_obj) +#> Warning: style is M (missing); style should be set to a valid value all.equal(col.tri.nb, col.tri.nb_sp, check.attributes=FALSE) #> [1] TRUE if (require("dbscan", quietly=TRUE)) { @@ -282,9 +285,9 @@

Examples

#> 0 1 2 3 4 5 #> 1 8 10 18 55 8 #> 8 least connected regions: -#> 46 47 48 49 96 97 98 99 with 1 link +#> with 1 link #> 8 most connected regions: -#> 10 15 20 25 30 35 40 45 with 5 links +#> with 5 links grd <- as.matrix(expand.grid(x=1:5, y=1:5)) #gridded data r2 <- gabrielneigh(grd) set.seed(1) diff --git a/docs/reference/grid2nb.html b/docs/reference/grid2nb.html index 5c0fc821..27f554ac 100644 --- a/docs/reference/grid2nb.html +++ b/docs/reference/grid2nb.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1

@@ -150,9 +150,9 @@

Examples

#> 7 11 17 26 #> 8 36 54 27 #> 8 least connected regions: -#> 1 5 21 25 101 105 121 125 with 7 links +#> with 7 links #> 27 most connected regions: -#> 32 33 34 37 38 39 42 43 44 57 58 59 62 63 64 67 68 69 82 83 84 87 88 89 92 93 94 with 26 links +#> with 26 links if (require("sp", quietly=TRUE)) { gt <- GridTopology(c(.125,.1), c(.25,.2), c(4L, 5L)) nb1 <- grid2nb(gt, queen = FALSE) diff --git a/docs/reference/hotspotmap.html b/docs/reference/hotspotmap.html index b958d4f8..ea60e102 100644 --- a/docs/reference/hotspotmap.html +++ b/docs/reference/hotspotmap.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/include.self.html b/docs/reference/include.self.html index 3b932530..1b8fad9a 100644 --- a/docs/reference/include.self.html +++ b/docs/reference/include.self.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -114,32 +114,9 @@

Examples

#> 2 3 4 5 6 7 8 9 10 #> 7 7 13 4 9 6 1 1 1 #> 7 least connected regions: -#> 1 6 31 39 42 46 47 with 2 links +#> with 2 links #> 1 most connected region: -#> 20 with 10 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.1276 0.3613 0.4566 0.4694 0.5536 0.8924 -#> -#> The decimal point is 1 digit(s) to the left of the | -#> -#> 1 | 3344 -#> 1 | 99 -#> 2 | 000011333344 -#> 2 | 556677779999 -#> 3 | 000011222222223344444444 -#> 3 | 556666777777888888889999999999 -#> 4 | 00001111112233333333334444 -#> 4 | 55666666666666777777777788888899 -#> 5 | 0011112222222222222233334444 -#> 5 | 556666667788 -#> 6 | 000000112244 -#> 6 | 5577889999 -#> 7 | 11112244 -#> 7 | 557777 -#> 8 | 1144 -#> 8 | 55999999 -#> +#> with 10 links summary(include.self(col.gal.nb), coords) #> Neighbour list object: #> Number of regions: 49 @@ -151,34 +128,9 @@

Examples

#> 3 4 5 6 7 8 9 10 11 #> 7 7 13 4 9 6 1 1 1 #> 7 least connected regions: -#> 1 6 31 39 42 46 47 with 3 links +#> with 3 links #> 1 most connected region: -#> 20 with 11 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.0000 0.2576 0.4073 0.3870 0.5232 0.8924 -#> -#> The decimal point is 1 digit(s) to the left of the | -#> -#> 0 | 0000000000000000000000000000000000000000000000000 -#> 0 | -#> 1 | 3344 -#> 1 | 99 -#> 2 | 000011333344 -#> 2 | 556677779999 -#> 3 | 000011222222223344444444 -#> 3 | 556666777777888888889999999999 -#> 4 | 00001111112233333333334444 -#> 4 | 55666666666666777777777788888899 -#> 5 | 0011112222222222222233334444 -#> 5 | 556666667788 -#> 6 | 000000112244 -#> 6 | 5577889999 -#> 7 | 11112244 -#> 7 | 557777 -#> 8 | 1144 -#> 8 | 55999999 -#> +#> with 11 links summary(remove.self(include.self(col.gal.nb)), coords) #> Neighbour list object: #> Number of regions: 49 @@ -190,32 +142,9 @@

Examples

#> 2 3 4 5 6 7 8 9 10 #> 7 7 13 4 9 6 1 1 1 #> 7 least connected regions: -#> 1 6 31 39 42 46 47 with 2 links +#> with 2 links #> 1 most connected region: -#> 20 with 10 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.1276 0.3613 0.4566 0.4694 0.5536 0.8924 -#> -#> The decimal point is 1 digit(s) to the left of the | -#> -#> 1 | 3344 -#> 1 | 99 -#> 2 | 000011333344 -#> 2 | 556677779999 -#> 3 | 000011222222223344444444 -#> 3 | 556666777777888888889999999999 -#> 4 | 00001111112233333333334444 -#> 4 | 55666666666666777777777788888899 -#> 5 | 0011112222222222222233334444 -#> 5 | 556666667788 -#> 6 | 000000112244 -#> 6 | 5577889999 -#> 7 | 11112244 -#> 7 | 557777 -#> 8 | 1144 -#> 8 | 55999999 -#> +#> with 10 links

diff --git a/docs/reference/index.html b/docs/reference/index.html index a538934b..a1029dbb 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/joincount.mc.html b/docs/reference/joincount.mc.html index 9f93aec1..d9250976 100644 --- a/docs/reference/joincount.mc.html +++ b/docs/reference/joincount.mc.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,8 +72,8 @@

Permutation test for same colour join count statistics

-
joincount.mc(fx, listw, nsim, zero.policy=FALSE, alternative="greater",
- spChk=NULL)
+
joincount.mc(fx, listw, nsim, zero.policy=attr(listw, "zero.policy"),
+ alternative="greater", spChk=NULL)
@@ -88,7 +88,7 @@

Arguments

number of permutations

zero.policy
-

if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of "greater" (default), "two.sided", or "less".

diff --git a/docs/reference/joincount.multi.html b/docs/reference/joincount.multi.html index 30a36e87..528fbbcd 100644 --- a/docs/reference/joincount.multi.html +++ b/docs/reference/joincount.multi.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,7 +72,7 @@

BB, BW and Jtot join count statistic for k-coloured factors

-
joincount.multi(fx, listw, zero.policy = FALSE,
+    
joincount.multi(fx, listw, zero.policy = attr(listw, "zero.policy"),
  spChk = NULL, adjust.n=TRUE)
 # S3 method for jcmulti
 print(x, ...)
@@ -87,7 +87,7 @@

Arguments

a listw object created for example by nb2listw

zero.policy
-

if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

adjust.n

default TRUE, if FALSE the number of observations is not adjusted for no-neighbour observations, if TRUE, the number of observations is adjusted consistently (up to and including spdep 0.3-28 the adjustment was inconsistent - thanks to Tomoki NAKAYA for a careful bug report)

@@ -127,7 +127,42 @@

See also

Examples

-
data(oldcol)
+    
columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE)
+HICRIME <- cut(columbus$CRIME, breaks=c(0,35,80), labels=c("low","high"))
+(nb <- poly2nb(columbus))
+#> Neighbour list object:
+#> Number of regions: 49 
+#> Number of nonzero links: 236 
+#> Percentage nonzero weights: 9.829238 
+#> Average number of links: 4.816327 
+lw <- nb2listw(nb, style="B")
+joincount.multi(HICRIME, lw)
+#>           Joincount Expected Variance z-value
+#> low:low      35.000   30.102   19.247  1.1164
+#> high:high    54.000   27.694   18.219  6.1630
+#> high:low     29.000   60.204   26.630 -6.0468
+#> Jtot         29.000   60.204   26.630 -6.0468
+col_geoms <- st_geometry(columbus)
+col_geoms[21] <- st_buffer(col_geoms[21], dist=-0.05)
+st_geometry(columbus) <- col_geoms
+(nb <- poly2nb(columbus))
+#> Neighbour list object:
+#> Number of regions: 49 
+#> Number of nonzero links: 230 
+#> Percentage nonzero weights: 9.579342 
+#> Average number of links: 4.693878 
+#> 1 region with no links:
+#> 21
+#> 3 disjoint connected subgraphs
+lw <- nb2listw(nb, style="B", zero.policy=TRUE)
+joincount.multi(HICRIME, lw)
+#>           Joincount Expected Variance z-value
+#> low:low      35.000   30.585   19.350  1.0036
+#> high:high    52.000   28.138   18.342  5.5716
+#> high:low     28.000   61.170   25.882 -6.5200
+#> Jtot         28.000   61.170   33.190 -5.7577
+# \dontrun{
+data(oldcol)
 HICRIME <- cut(COL.OLD$CRIME, breaks=c(0,35,80), labels=c("low","high"))
 names(HICRIME) <- rownames(COL.OLD)
 joincount.multi(HICRIME, nb2listw(COL.nb, style="B"))
@@ -136,7 +171,6 @@ 

Examples

#> high:high 54.000 27.224 17.888 6.3307 #> high:low 28.000 59.184 26.233 -6.0884 #> Jtot 28.000 59.184 26.233 -6.0884 -# \dontrun{ data(hopkins, package="spData") image(1:32, 1:32, hopkins[5:36,36:5], breaks=c(-0.5, 3.5, 20), col=c("white", "black")) diff --git a/docs/reference/joincount.test.html b/docs/reference/joincount.test.html index 6f58a8a7..87d197db 100644 --- a/docs/reference/joincount.test.html +++ b/docs/reference/joincount.test.html @@ -23,7 +23,7 @@ spdep - 1.2-8 + 1.3-1
@@ -84,7 +84,7 @@

BB join count statistic for k-coloured factors

-
joincount.test(fx, listw, zero.policy=NULL, alternative="greater",
+    
joincount.test(fx, listw, zero.policy=attr(listw, "zero.policy"), alternative="greater",
  sampling="nonfree", spChk=NULL, adjust.n=TRUE)
 # S3 method for jclist
 print(x, ...)
@@ -99,7 +99,7 @@

Arguments

a listw object created for example by nb2listw

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of "greater" (default), "less" or "two.sided".

@@ -357,6 +357,78 @@

Examples

#> Same colour statistic Expectation Variance #> 40.500000 23.000000 6.762918 #> +columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE) +HICRIME <- cut(columbus$CRIME, breaks=c(0,35,80), labels=c("low","high")) +(nb <- poly2nb(columbus)) +#> Neighbour list object: +#> Number of regions: 49 +#> Number of nonzero links: 236 +#> Percentage nonzero weights: 9.829238 +#> Average number of links: 4.816327 +lw <- nb2listw(nb, style="B") +joincount.test(HICRIME, lw) +#> +#> Join count test under nonfree sampling +#> +#> data: HICRIME +#> weights: lw +#> +#> Std. deviate for low = 1.1164, p-value = 0.1321 +#> alternative hypothesis: greater +#> sample estimates: +#> Same colour statistic Expectation Variance +#> 35.00000 30.10204 19.24708 +#> +#> +#> Join count test under nonfree sampling +#> +#> data: HICRIME +#> weights: lw +#> +#> Std. deviate for high = 6.163, p-value = 3.57e-10 +#> alternative hypothesis: greater +#> sample estimates: +#> Same colour statistic Expectation Variance +#> 54.00000 27.69388 18.21936 +#> +col_geoms <- st_geometry(columbus) +col_geoms[21] <- st_buffer(col_geoms[21], dist=-0.05) +st_geometry(columbus) <- col_geoms +(nb <- poly2nb(columbus)) +#> Neighbour list object: +#> Number of regions: 49 +#> Number of nonzero links: 230 +#> Percentage nonzero weights: 9.579342 +#> Average number of links: 4.693878 +#> 1 region with no links: +#> 21 +#> 3 disjoint connected subgraphs +lw <- nb2listw(nb, style="B", zero.policy=TRUE) +joincount.test(HICRIME, lw) +#> +#> Join count test under nonfree sampling +#> +#> data: HICRIME +#> weights: lw +#> +#> Std. deviate for low = 1.0036, p-value = 0.1578 +#> alternative hypothesis: greater +#> sample estimates: +#> Same colour statistic Expectation Variance +#> 35.00000 30.58511 19.35032 +#> +#> +#> Join count test under nonfree sampling +#> +#> data: HICRIME +#> weights: lw +#> +#> Std. deviate for high = 5.5716, p-value = 1.262e-08 +#> alternative hypothesis: greater +#> sample estimates: +#> Same colour statistic Expectation Variance +#> 52.00000 28.13830 18.34187 +#>
diff --git a/docs/reference/knearneigh.html b/docs/reference/knearneigh.html index 5f2d6b91..f5a9e742 100644 --- a/docs/reference/knearneigh.html +++ b/docs/reference/knearneigh.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -161,26 +161,9 @@

Examples

#> 4 #> 48 #> 48 least connected regions: -#> 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 with 4 links +#> with 4 links #> 48 most connected regions: -#> 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 with 4 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 93.66 297.56 393.72 414.78 513.25 956.71 -#> -#> The decimal point is 2 digit(s) to the right of the | -#> -#> 0 | 99 -#> 1 | 00112233666699 -#> 2 | 002222223344444444446677889999 -#> 3 | 00000111112222222233333333334444556666777788899999 -#> 4 | 0000001111233555555666666677788888899 -#> 5 | 001111111112222222234444455666679 -#> 6 | 002335667 -#> 7 | 0112345889 -#> 8 | 02279 -#> 9 | 56 -#> +#> with 4 links summary(gck4.nb, xy, longlat=TRUE, scale=0.5) #> Neighbour list object: #> Number of regions: 48 @@ -193,26 +176,9 @@

Examples

#> 4 #> 48 #> 48 least connected regions: -#> 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 with 4 links +#> with 4 links #> 48 most connected regions: -#> 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 with 4 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 93.66 297.09 393.72 410.42 508.50 953.23 -#> -#> The decimal point is 2 digit(s) to the right of the | -#> -#> 0 | 99 -#> 1 | 00112233666699 -#> 2 | 0022222233444444444466778899999 -#> 3 | 0000001111122222222333333333344445566677778888999 -#> 4 | 00000011112335555556666666777788888899 -#> 5 | 0001111111112222222344444456667899 -#> 6 | 0023356 -#> 7 | 000112455899 -#> 8 | 0229 -#> 9 | 5 -#> +#> with 4 links #xy1 <- SpatialPoints((as.data.frame(state.center))[m50.48,], # proj4string=CRS("+proj=longlat +ellps=GRS80")) @@ -225,7 +191,7 @@

Examples

sf_use_s2(TRUE) system.time(gck4a.nb <- knn2nb(knearneigh(xy1, k=4))) #> user system elapsed -#> 0.009 0.000 0.009 +#> 0.008 0.000 0.009 summary(gck4a.nb, xy1, scale=0.5) #> Neighbour list object: #> Number of regions: 48 @@ -238,31 +204,14 @@

Examples

#> 4 #> 48 #> 48 least connected regions: -#> 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 with 4 links +#> with 4 links #> 48 most connected regions: -#> 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 with 4 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 93.71 296.60 393.51 410.27 508.73 953.85 -#> -#> The decimal point is 2 digit(s) to the right of the | -#> -#> 0 | 99 -#> 1 | 00112233666699 -#> 2 | 0022222233444444444466778899999 -#> 3 | 0000001111122222222333333333344445566677778888999 -#> 4 | 0000001111233555555666666677778888899999 -#> 5 | 01111111112222222344444456667888 -#> 6 | 0023356 -#> 7 | 0001224558999 -#> 8 | 229 -#> 9 | 5 -#> +#> with 4 links sf_use_s2(FALSE) #> Spherical geometry (s2) switched off system.time(gck4a.nb <- knn2nb(knearneigh(xy1, k=4))) #> user system elapsed -#> 0.005 0.000 0.005 +#> 0.005 0.000 0.006 summary(gck4a.nb, xy1, scale=0.5) #> Neighbour list object: #> Number of regions: 48 @@ -275,26 +224,9 @@

Examples

#> 4 #> 48 #> 48 least connected regions: -#> 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 with 4 links +#> with 4 links #> 48 most connected regions: -#> 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 with 4 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 93.66 297.09 393.72 410.42 508.50 953.23 -#> -#> The decimal point is 2 digit(s) to the right of the | -#> -#> 0 | 99 -#> 1 | 00112233666699 -#> 2 | 0022222233444444444466778899999 -#> 3 | 0000001111122222222333333333344445566677778888999 -#> 4 | 00000011112335555556666666777788888899 -#> 5 | 0001111111112222222344444456667899 -#> 6 | 0023356 -#> 7 | 000112455899 -#> 8 | 0229 -#> 9 | 5 -#> +#> with 4 links sf_use_s2(old_use_s2) #> Spherical geometry (s2) switched on diff --git a/docs/reference/knn2nb.html b/docs/reference/knn2nb.html index f9003c46..b5986b8e 100644 --- a/docs/reference/knn2nb.html +++ b/docs/reference/knn2nb.html @@ -19,7 +19,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/lag.listw.html b/docs/reference/lag.listw.html index ffa33310..a72992d7 100644 --- a/docs/reference/lag.listw.html +++ b/docs/reference/lag.listw.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -73,7 +73,7 @@

Spatial lag of a numeric vector

# S3 method for listw
-lag(x, var, zero.policy=NULL, NAOK=FALSE, ...)
+lag(x, var, zero.policy=attr(listw, "zero.policy"), NAOK=FALSE, ...)
@@ -85,7 +85,7 @@

Arguments

a numeric vector the same length as the neighbours list in listw

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

NAOK

If 'FALSE', the presence of 'NA' values is regarded as an error; if 'TRUE' then any 'NA' or 'NaN' or 'Inf' values in var are represented as an NA lagged value.

diff --git a/docs/reference/lee.html b/docs/reference/lee.html index fd9ad10b..7338dcdc 100644 --- a/docs/reference/lee.html +++ b/docs/reference/lee.html @@ -21,7 +21,7 @@ spdep - 1.2-8 + 1.3-1
@@ -80,7 +80,7 @@

Compute Lee's statistic

-
lee(x, y, listw, n, S2, zero.policy=NULL, NAOK=FALSE)
+
lee(x, y, listw, n, S2, zero.policy=attr(listw, "zero.policy"), NAOK=FALSE)
@@ -101,7 +101,7 @@

Arguments

Sum of squared sum of weights by rows.

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

NAOK

if 'TRUE' then any 'NA' or 'NaN' or 'Inf' values in x are passed on to the foreign function. If 'FALSE', the presence of 'NA' or 'NaN' or 'Inf' values is regarded as an error.

diff --git a/docs/reference/lee.mc.html b/docs/reference/lee.mc.html index e5e21db0..d1931d48 100644 --- a/docs/reference/lee.mc.html +++ b/docs/reference/lee.mc.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,7 +72,7 @@

Permutation test for Lee's L statistic

-
lee.mc(x, y, listw, nsim, zero.policy=NULL, alternative="greater",
+    
lee.mc(x, y, listw, nsim, zero.policy=attr(listw, "zero.policy"), alternative="greater",
  na.action=na.fail, spChk=NULL, return_boot=FALSE)
@@ -91,7 +91,7 @@

Arguments

number of permutations

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of "greater" (default), "two.sided", or "less".

diff --git a/docs/reference/lee.test.html b/docs/reference/lee.test.html index 4a835694..fd17e8ff 100644 --- a/docs/reference/lee.test.html +++ b/docs/reference/lee.test.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,7 +72,7 @@

Lee's L test for spatial autocorrelation

-
lee.test(x, y, listw, zero.policy=NULL,
+    
lee.test(x, y, listw, zero.policy=attr(listw, "zero.policy"),
  alternative="greater", na.action=na.fail, spChk=NULL)
@@ -89,7 +89,7 @@

Arguments

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of greater (default), less or two.sided.

diff --git a/docs/reference/listw2sn.html b/docs/reference/listw2sn.html index fab84fd3..b5571da7 100644 --- a/docs/reference/listw2sn.html +++ b/docs/reference/listw2sn.html @@ -19,7 +19,7 @@ spdep - 1.2-8 + 1.3-1
@@ -77,7 +77,7 @@

Spatial neighbour sparse representation

listw2sn(listw)
-sn2listw(sn)
+sn2listw(sn, style = NULL, zero.policy = NULL)
@@ -88,6 +88,12 @@

Arguments

sn

a spatial.neighbour object

+
style
+

default NULL, missing, set to "M" and warning given; if not "M", passed to nb2listw to re-build the object

+ +
zero.policy
+

default NULL, use global option value; if FALSE stop with error for any empty neighbour sets, if TRUE permit the weights list to be formed with zero-length weights vectors

+

Value

diff --git a/docs/reference/lm.LMtests.html b/docs/reference/lm.LMtests.html index 9e5fafd2..ebe4fcd9 100644 --- a/docs/reference/lm.LMtests.html +++ b/docs/reference/lm.LMtests.html @@ -24,7 +24,7 @@ spdep - 1.2-8 + 1.3-1
@@ -86,7 +86,8 @@

Lagrange Multiplier diagnostics for spatial dependence in linear models

-
lm.LMtests(model, listw, zero.policy=NULL, test="LMerr", spChk=NULL, naSubset=TRUE)
+    
lm.LMtests(model, listw, zero.policy=attr(listw, "zero.policy"), test="LMerr",
+ spChk=NULL, naSubset=TRUE)
 # S3 method for LMtestlist
 print(x, ...)
 # S3 method for LMtestlist
@@ -106,7 +107,7 @@ 

Arguments

expected to be row-standardised (W-style)

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without +

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

test
diff --git a/docs/reference/lm.morantest.exact.html b/docs/reference/lm.morantest.exact.html index 391363d1..f0ecaf29 100644 --- a/docs/reference/lm.morantest.exact.html +++ b/docs/reference/lm.morantest.exact.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,9 +72,10 @@

Exact global Moran's I test

-
lm.morantest.exact(model, listw, zero.policy = NULL, alternative = "greater",
- spChk = NULL, resfun = weighted.residuals, zero.tol = 1e-07, Omega=NULL,
- save.M=NULL, save.U=NULL, useTP=FALSE, truncErr=1e-6, zeroTreat=0.1)
+    
lm.morantest.exact(model, listw, zero.policy = attr(listw, "zero.policy"),
+ alternative = "greater", spChk = NULL, resfun = weighted.residuals,
+ zero.tol = 1e-07, Omega=NULL, save.M=NULL, save.U=NULL, useTP=FALSE,
+ truncErr=1e-6, zeroTreat=0.1)
 # S3 method for moranex
 print(x, ...)
@@ -89,7 +90,7 @@

Arguments

a listw object created for example by nb2listw

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without +

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative
diff --git a/docs/reference/lm.morantest.html b/docs/reference/lm.morantest.html index 7b8e66ea..5ad302fe 100644 --- a/docs/reference/lm.morantest.html +++ b/docs/reference/lm.morantest.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,8 +72,8 @@

Moran's I test for residual spatial autocorrelation

-
lm.morantest(model, listw, zero.policy=NULL, alternative = "greater",
- spChk=NULL, resfun=weighted.residuals, naSubset=TRUE)
+
lm.morantest(model, listw, zero.policy=attr(listw, "zero.policy"),
+ alternative = "greater", spChk=NULL, resfun=weighted.residuals, naSubset=TRUE)
@@ -86,7 +86,7 @@

Arguments

a listw object created for example by nb2listw

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without +

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative
diff --git a/docs/reference/lm.morantest.sad.html b/docs/reference/lm.morantest.sad.html index 979de3e3..9fafacc5 100644 --- a/docs/reference/lm.morantest.sad.html +++ b/docs/reference/lm.morantest.sad.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1
@@ -74,10 +74,10 @@

Saddlepoint approximation of global Moran's I test

-
lm.morantest.sad(model, listw, zero.policy=NULL, alternative="greater", 
-  spChk=NULL, resfun=weighted.residuals, tol=.Machine$double.eps^0.5,
-  maxiter=1000, tol.bounds=0.0001, zero.tol = 1e-07, Omega=NULL,
-  save.M=NULL, save.U=NULL)
+    
lm.morantest.sad(model, listw, zero.policy=attr(listw, "zero.policy"),
+  alternative="greater", spChk=NULL, resfun=weighted.residuals,
+  tol=.Machine$double.eps^0.5, maxiter=1000, tol.bounds=0.0001,
+  zero.tol = 1e-07, Omega=NULL, save.M=NULL, save.U=NULL)
 # S3 method for moransad
 print(x, ...)
 # S3 method for moransad
@@ -96,7 +96,7 @@ 

Arguments

a listw object created for example by nb2listw

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without +

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative
diff --git a/docs/reference/localC.html b/docs/reference/localC.html index 4a84d1bf..1efd5e5b 100644 --- a/docs/reference/localC.html +++ b/docs/reference/localC.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1
@@ -77,29 +77,29 @@

Compute Local Geary statistic

localC(x, ..., zero.policy=NULL)
 
 # S3 method for default
-localC(x, listw, ..., zero.policy=NULL)
+localC(x, listw, ..., zero.policy=attr(listw, "zero.policy"))
 
 # S3 method for formula
-localC(formula, data, listw, ..., zero.policy=NULL)
+localC(formula, data, listw, ..., zero.policy=attr(listw, "zero.policy"))
 
 # S3 method for list
-localC(x, listw, ..., zero.policy=NULL)
+localC(x, listw, ..., zero.policy=attr(listw, "zero.policy"))
 
 # S3 method for matrix
-localC(x, listw, ..., zero.policy=NULL)
+localC(x, listw, ..., zero.policy=attr(listw, "zero.policy"))
 
 # S3 method for data.frame
-localC(x, listw, ..., zero.policy=NULL)
+localC(x, listw, ..., zero.policy=attr(listw, "zero.policy"))
 
 localC_perm(x, ..., zero.policy=NULL, iseed=NULL, no_repeat_in_row=FALSE)
 
 # S3 method for default
 localC_perm(x, listw, nsim = 499, alternative = "two.sided", ...,
- zero.policy=NULL, iseed=NULL, no_repeat_in_row=FALSE)
+ zero.policy=attr(listw, "zero.policy"), iseed=NULL, no_repeat_in_row=FALSE)
 
 # S3 method for formula
 localC_perm(formula, data, listw, nsim = 499,
- alternative = "two.sided", ..., zero.policy=NULL, iseed=NULL,
+ alternative = "two.sided", ..., zero.policy=attr(listw, "zero.policy"), iseed=NULL,
  no_repeat_in_row=FALSE)
@@ -132,7 +132,7 @@

Arguments

other arguments passed to methods.

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA.

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA.

iseed

default NULL, used to set the seed for possible parallel RNGs

@@ -247,7 +247,9 @@

Examples

# pseudo-p values probably wrongly folded https://github.com/GeoDaCenter/rgeoda/issues/28 # \dontrun{ tmap_ok <- FALSE -if (require(tmap, quietly=TRUE)) tmap_ok <- TRUE +if (require(tmap, quietly=TRUE)) tmap_ok <- TRUE +#> Breaking News: tmap 3.x is retiring. Please test v4, e.g. with +#> remotes::install_github('r-tmap/tmap') if (run) { # doi: 10.1111/gean.12164 guerry_path <- system.file("extdata", "Guerry.shp", package = "rgeoda") @@ -283,16 +285,16 @@

Examples

if (run) { g$PC1 <- o$x[, "PC1"] brks <- c(min(g$PC1), natural_breaks(k=6, g["PC1"]), max(g$PC1)) - if (tmap_ok) tm_shape(g) + tm_fill("PC1", breaks=brks, midpoint=0) + - tm_borders() # Fig. 1 + if (tmap_ok) tm_shape(g) + tm_fill("PC1", breaks=brks, midpoint=0) + + tm_borders() # Fig. 1 else pplot(g["PC1"], breaks=brks) } if (run) { g$PC2 <- -1*o$x[, "PC2"] # eigenvalue sign arbitrary brks <- c(min(g$PC2), natural_breaks(k=6, g["PC2"]), max(g$PC2)) - if (tmap_ok) tm_shape(g) + tm_fill("PC2", breaks=brks, midpoint=0) + - tm_borders() # Fig. 2 + if (tmap_ok) tm_shape(g) + tm_fill("PC2", breaks=brks, midpoint=0) + + tm_borders() # Fig. 2 else plot(g["PC2"], breaks=brks) } @@ -304,8 +306,8 @@

Examples

labels=lisa_labels(lm_PC1)[1:5]) is.na(g$lm_PC1) <- g$lm_PC1 == "Not significant" g$lm_PC1 <- droplevels(g$lm_PC1) - if (tmap_ok) tm_shape(g) + tm_fill("lm_PC1", textNA="Insignificant", - colorNA="gray95") + tm_borders() # Fig. 3 + if (tmap_ok) tm_shape(g) + tm_fill("lm_PC1", textNA="Insignificant", + colorNA="gray95") + tm_borders() # Fig. 3 else plot(g["lm_PC1"]) } @@ -316,8 +318,8 @@

Examples

g$lm_PC1_spdep <- q is.na(g$lm_PC1_spdep) <- lm_PC1_spdep[,6] > 0.02 # note folded p-values g$lm_PC1_spdep <- droplevels(g$lm_PC1_spdep) - if (tmap_ok) tm_shape(g) + tm_fill("lm_PC1_spdep", textNA="Insignificant", - colorNA="gray95") + tm_borders() # rep. Fig. 3 + if (tmap_ok) tm_shape(g) + tm_fill("lm_PC1_spdep", textNA="Insignificant", + colorNA="gray95") + tm_borders() # rep. Fig. 3 else plot(g["lm_PC1_spdep"]) } @@ -328,14 +330,14 @@

Examples

labels=lisa_labels(lg_PC1)[0:3]) is.na(g$lg_PC1) <- g$lg_PC1 == "Not significant" g$lg_PC1 <- droplevels(g$lg_PC1) - if (tmap_ok) tm_shape(g) + tm_fill("lg_PC1", textNA="Insignificant", - colorNA="gray95") + tm_borders() # Fig. 4 (wrong) + if (tmap_ok) tm_shape(g) + tm_fill("lg_PC1", textNA="Insignificant", + colorNA="gray95") + tm_borders() # Fig. 4 (wrong) else plot(g["lg_PC1"]) g$lg_PC1a <- cut(g$PC1, c(-Inf, mean(g$PC1), Inf), labels=c("Low", "High")) is.na(g$lg_PC1a) <- lisa_pvalues(lg_PC1) >= 0.01 g$lg_PC1a <- droplevels(g$lg_PC1a) - if (tmap_ok) tm_shape(g) + tm_fill("lg_PC1", textNA="Insignificant", - colorNA="gray95") + tm_borders() # Fig. 4 (guess) + if (tmap_ok) tm_shape(g) + tm_fill("lg_PC1", textNA="Insignificant", + colorNA="gray95") + tm_borders() # Fig. 4 (guess) else plot(g["lg_PC1"]) } @@ -346,8 +348,8 @@

Examples

labels=lisa_labels(lc_PC1)[1:5]) is.na(g$lc_PC1) <- g$lc_PC1 == "Not significant" g$lc_PC1 <- droplevels(g$lc_PC1) - if (tmap_ok) tm_shape(g) + tm_fill("lc_PC1", textNA="Insignificant", - colorNA="gray95") + tm_borders() # Fig. 5 + if (tmap_ok) tm_shape(g) + tm_fill("lc_PC1", textNA="Insignificant", + colorNA="gray95") + tm_borders() # Fig. 5 else plot(g["lc_PC1"]) } @@ -357,7 +359,7 @@

Examples

alternative="two.sided")) } #> user system elapsed -#> 0.378 0.008 0.387 +#> 0.376 0.001 0.377 if (run) { if (require(parallel, quietly=TRUE)) { ncpus <- max(2L, detectCores(logical=FALSE), na.rm = TRUE)-1L @@ -375,16 +377,16 @@

Examples

g$lc_PC1_spdep <- attr(lc_PC1_spdep, "cluster") is.na(g$lc_PC1_spdep) <- attr(lc_PC1_spdep, "pseudo-p")[,6] > 0.01 g$lc_PC1_spdep <- droplevels(g$lc_PC1_spdep) - if (tmap_ok) tm_shape(g) + tm_fill("lc_PC1_spdep", textNA="Insignificant", - colorNA="gray95") + tm_borders() # rep. Fig. 5 + if (tmap_ok) tm_shape(g) + tm_fill("lc_PC1_spdep", textNA="Insignificant", + colorNA="gray95") + tm_borders() # rep. Fig. 5 else plot(g["lc_PC1_spdep"]) } if (run) { g$both_PC1 <- interaction(g$lc_PC1, g$lm_PC1) g$both_PC1 <- droplevels(g$both_PC1) - if (tmap_ok) tm_shape(g) + tm_fill("both_PC1", textNA="Insignificant", - colorNA="gray95") + tm_borders() # Fig. 6 + if (tmap_ok) tm_shape(g) + tm_fill("both_PC1", textNA="Insignificant", + colorNA="gray95") + tm_borders() # Fig. 6 else plot(g["both_PC1"]) } @@ -395,8 +397,8 @@

Examples

labels=lisa_labels(lc005_PC1)[1:5]) is.na(g$lc005_PC1) <- g$lc005_PC1 == "Not significant" g$lc005_PC1 <- droplevels(g$lc005_PC1) - if (tmap_ok) tm_shape(g) + tm_fill("lc005_PC1", textNA="Insignificant", - colorNA="gray95") + tm_borders() # Fig. 7 + if (tmap_ok) tm_shape(g) + tm_fill("lc005_PC1", textNA="Insignificant", + colorNA="gray95") + tm_borders() # Fig. 7 else plot(g["lc005_PC1"]) } @@ -404,8 +406,8 @@

Examples

g$lc005_PC1_spdep <- attr(lc_PC1_spdep, "cluster") is.na(g$lc005_PC1_spdep) <- attr(lc_PC1_spdep, "pseudo-p")[,6] > 0.005 g$lc005_PC1_spdep <- droplevels(g$lc005_PC1_spdep) - if (tmap_ok) tm_shape(g) + tm_fill("lc005_PC1_spdep", textNA="Insignificant", - colorNA="gray95") + tm_borders() # rep. Fig. 7 + if (tmap_ok) tm_shape(g) + tm_fill("lc005_PC1_spdep", textNA="Insignificant", + colorNA="gray95") + tm_borders() # rep. Fig. 7 else plot(g["lc005_PC1_spdep"]) } @@ -416,15 +418,15 @@

Examples

labels=lisa_labels(lc001_PC1)[1:5]) is.na(g$lc001_PC1) <- g$lc001_PC1 == "Not significant" g$lc001_PC1 <- droplevels(g$lc001_PC1) - if (tmap_ok) tm_shape(g) + tm_fill("lc001_PC1", textNA="Insignificant", - colorNA="gray95") + tm_borders() # Fig. 8 + if (tmap_ok) tm_shape(g) + tm_fill("lc001_PC1", textNA="Insignificant", + colorNA="gray95") + tm_borders() # Fig. 8 else plot(g["lc001_PC1"]) if (run) { g$lc001_PC1_spdep <- attr(lc_PC1_spdep, "cluster") is.na(g$lc001_PC1_spdep) <- attr(lc_PC1_spdep, "pseudo-p")[,6] > 0.001 g$lc001_PC1_spdep <- droplevels(g$lc001_PC1_spdep) - if (tmap_ok) tm_shape(g) + tm_fill("lc001_PC1_spdep", textNA="Insignificant", - colorNA="gray95") + tm_borders() # rep. Fig. 8 + if (tmap_ok) tm_shape(g) + tm_fill("lc001_PC1_spdep", textNA="Insignificant", + colorNA="gray95") + tm_borders() # rep. Fig. 8 else plot(g["lc001_PC1_spdep"]) } } @@ -436,8 +438,8 @@

Examples

labels=lisa_labels(lc_PC2)[1:5]) is.na(g$lc_PC2) <- g$lc_PC2 == "Not significant" g$lc_PC2 <- droplevels(g$lc_PC2) - if (tmap_ok) tm_shape(g) + tm_fill("lc_PC2", textNA="Insignificant", - colorNA="gray95") + tm_borders() # Fig. 9 + if (tmap_ok) tm_shape(g) + tm_fill("lc_PC2", textNA="Insignificant", + colorNA="gray95") + tm_borders() # Fig. 9 else plot(g["lc_PC2"]) } @@ -454,8 +456,8 @@

Examples

#> FALSE.Positive TRUE.Positive #> 0 21 if (run) { - if (tmap_ok) tm_shape(g) + tm_fill("lmc_PC", textNA="Insignificant", - colorNA="gray95") + tm_borders() # Fig. 10 + if (tmap_ok) tm_shape(g) + tm_fill("lmc_PC", textNA="Insignificant", + colorNA="gray95") + tm_borders() # Fig. 10 else plot(g["lmc_PC"]) } @@ -473,8 +475,8 @@

Examples

g$lmc_PC_spdep <- attr(lmc_PC_spdep, "cluster") is.na(g$lmc_PC_spdep) <- p.adjust(attr(lmc_PC_spdep, "pseudo-p")[,6], "fdr") > 0.01 g$lmc_PC_spdep <- droplevels(g$lmc_PC_spdep) - if (tmap_ok) tm_shape(g) + tm_fill("lmc_PC_spdep", textNA="Insignificant", - colorNA="gray95") + tm_borders() # rep. Fig. 10 + if (tmap_ok) tm_shape(g) + tm_fill("lmc_PC_spdep", textNA="Insignificant", + colorNA="gray95") + tm_borders() # rep. Fig. 10 else plot(g["lmc_PC_spdep"]) } @@ -492,8 +494,8 @@

Examples

#> FALSE.Positive TRUE.Positive #> 0 21 if (run) { - if (tmap_ok) tm_shape(g) + tm_fill("lmc_vars", textNA="Insignificant", - colorNA="gray95") + tm_borders() # Fig. 11 + if (tmap_ok) tm_shape(g) + tm_fill("lmc_vars", textNA="Insignificant", + colorNA="gray95") + tm_borders() # Fig. 11 else plot(g["lmc_vars"]) } @@ -503,7 +505,7 @@

Examples

nsim=9999, alternative="two.sided")) } #> user system elapsed -#> 0.602 0.001 0.605 +#> 0.824 0.002 0.828 if (run) { all.equal(lisa_values(lmc_vars), c(lmc_vars_spdep)) } @@ -537,8 +539,8 @@

Examples

g$lmc_vars_spdep <- attr(lmc_vars_spdep1, "cluster") is.na(g$lmc_vars_spdep) <- p.adjust(attr(lmc_vars_spdep1, "pseudo-p")[,6], "fdr") > 0.01 g$lmc_vars_spdep <- droplevels(g$lmc_vars_spdep) - if (tmap_ok) tm_shape(g) + tm_fill("lmc_vars_spdep", textNA="Insignificant", - colorNA="gray95") + tm_borders() # rep. Fig. 11 + if (tmap_ok) tm_shape(g) + tm_fill("lmc_vars_spdep", textNA="Insignificant", + colorNA="gray95") + tm_borders() # rep. Fig. 11 else plot(g["lmc_vars_spdep"]) } @@ -567,10 +569,10 @@

Examples

#> [1] TRUE # simulation order not retained lC$p_sim[o] -#> [1] 0.251 0.447 0.091 0.025 0.151 0.022 0.316 0.451 0.171 0.001 0.132 0.129 -#> [13] 0.165 0.229 0.485 0.190 0.104 0.302 0.001 0.027 0.029 0.110 0.054 0.272 -#> [25] 0.147 0.029 0.107 0.273 0.485 0.001 0.085 0.122 0.111 0.229 0.314 0.001 -#> [37] 0.291 0.486 0.318 0.239 0.255 0.267 +#> [1] 0.278 0.460 0.112 0.019 0.121 0.038 0.330 0.412 0.147 0.001 0.113 0.141 +#> [13] 0.188 0.246 0.450 0.172 0.102 0.298 0.001 0.027 0.038 0.091 0.055 0.297 +#> [25] 0.153 0.031 0.107 0.280 0.450 0.001 0.066 0.104 0.080 0.231 0.306 0.001 +#> [37] 0.326 0.482 0.321 0.216 0.235 0.288 attr(C, "pseudo-p")[,6] #> [1] 0.408 0.374 0.144 0.056 0.010 0.284 0.032 0.264 0.186 0.004 0.150 0.224 #> [13] 0.022 0.150 0.438 0.084 0.126 0.184 0.002 0.238 0.126 0.100 0.068 0.372 diff --git a/docs/reference/localG.html b/docs/reference/localG.html index 1bb3baed..c43536ee 100644 --- a/docs/reference/localG.html +++ b/docs/reference/localG.html @@ -23,7 +23,7 @@ spdep - 1.2-8 + 1.3-1
@@ -84,9 +84,9 @@

G and Gstar local spatial statistics

-
localG(x, listw, zero.policy=NULL, spChk=NULL, GeoDa=FALSE, alternative = "two.sided",
- return_internals=TRUE)
-localG_perm(x, listw, nsim=499, zero.policy=NULL, spChk=NULL,
+    
localG(x, listw, zero.policy=attr(listw, "zero.policy"), spChk=NULL, GeoDa=FALSE,
+ alternative = "two.sided", return_internals=TRUE)
+localG_perm(x, listw, nsim=499, zero.policy=attr(listw, "zero.policy"), spChk=NULL,
  alternative = "two.sided", iseed=NULL, fix_i_in_Gstar_permutations=TRUE,
  no_repeat_in_row=FALSE)
diff --git a/docs/reference/localGS.html b/docs/reference/localGS.html index 50304b52..889a997b 100644 --- a/docs/reference/localGS.html +++ b/docs/reference/localGS.html @@ -20,7 +20,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/local_joincount_bv.html b/docs/reference/local_joincount_bv.html index cda32b30..3e7d822a 100644 --- a/docs/reference/local_joincount_bv.html +++ b/docs/reference/local_joincount_bv.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/local_joincount_uni.html b/docs/reference/local_joincount_uni.html index 8882dd1f..c6052c87 100644 --- a/docs/reference/local_joincount_uni.html +++ b/docs/reference/local_joincount_uni.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/localmoran.exact.html b/docs/reference/localmoran.exact.html index ea5c0a48..00d87773 100644 --- a/docs/reference/localmoran.exact.html +++ b/docs/reference/localmoran.exact.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/localmoran.html b/docs/reference/localmoran.html index c4ef522c..9ba2b8da 100644 --- a/docs/reference/localmoran.html +++ b/docs/reference/localmoran.html @@ -21,7 +21,7 @@ spdep - 1.2-8 + 1.3-1 @@ -80,11 +80,11 @@

Local Moran's I statistic

-
localmoran(x, listw, zero.policy=NULL, na.action=na.fail, conditional=TRUE,
-  alternative = "two.sided", mlvar=TRUE,
+    
localmoran(x, listw, zero.policy=attr(listw, "zero.policy"), na.action=na.fail,
+        conditional=TRUE, alternative = "two.sided", mlvar=TRUE,
         spChk=NULL, adjust.x=FALSE)
-localmoran_perm(x, listw, nsim=499, zero.policy=NULL, na.action=na.fail, 
-  alternative = "two.sided", mlvar=TRUE,
+localmoran_perm(x, listw, nsim=499, zero.policy=attr(listw, "zero.policy"), 
+        na.action=na.fail, alternative = "two.sided", mlvar=TRUE,
         spChk=NULL, adjust.x=FALSE, sample_Ei=TRUE, iseed=NULL,
         no_repeat_in_row=FALSE)
@@ -98,7 +98,7 @@

Arguments

a listw object created for example by nb2listw

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

na.action

a function (default na.fail), can also be na.omit or na.exclude - in these cases the weights list will be subsetted to remove NAs in the data. It may be necessary to set zero.policy to TRUE because this subsetting may create no-neighbour observations. Note that only weights lists created without using the glist argument to nb2listw may be subsetted. If na.pass is used, zero is substituted for NA values in calculating the spatial lag. (Note that na.exclude will only work properly starting from R 1.9.0, na.omit and na.exclude assign the wrong classes in 1.8.*)

diff --git a/docs/reference/localmoran.sad.html b/docs/reference/localmoran.sad.html index 37ac04bc..1cc73428 100644 --- a/docs/reference/localmoran.sad.html +++ b/docs/reference/localmoran.sad.html @@ -25,7 +25,7 @@ spdep - 1.2-8 + 1.3-1
@@ -100,7 +100,7 @@

Saddlepoint approximation of local Moran's Ii tests

summary(object, ...) # S3 method for summary.localmoransad print(x, ...) -listw2star(listw, ireg, style, n, D, a, zero.policy=NULL)
+listw2star(listw, ireg, style, n, D, a, zero.policy=attr(listw, "zero.policy"))
@@ -121,7 +121,7 @@

Arguments

can take values W, B, C, and S

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without +

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative
diff --git a/docs/reference/localmoran_bv.html b/docs/reference/localmoran_bv.html index e26ea1d3..4adc9407 100644 --- a/docs/reference/localmoran_bv.html +++ b/docs/reference/localmoran_bv.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/mat2listw.html b/docs/reference/mat2listw.html index ac57b013..096c6e5d 100644 --- a/docs/reference/mat2listw.html +++ b/docs/reference/mat2listw.html @@ -20,7 +20,7 @@ spdep - 1.2-8 + 1.3-1 @@ -78,7 +78,7 @@

Convert a square spatial weights matrix to a weights list object

-
mat2listw(x, row.names = NULL, style=NULL)
+
mat2listw(x, row.names = NULL, style=NULL, zero.policy = NULL)
@@ -93,6 +93,9 @@

Arguments

style

default NULL, missing, set to "M" and warning given; if not "M", passed to nb2listw to re-build the object

+
zero.policy
+

default NULL, use global option value; if FALSE stop with error for any empty neighbour sets, if TRUE permit the weights list to be formed with zero-length weights vectors

+

Value

@@ -131,17 +134,19 @@

Examples

#> Average number of links: 3.469388 #> 4 regions with no links: #> 1005 1006 1008 1043 +#> 8 disjoint connected subgraphs #> Link number distribution: #> #> 0 1 2 3 4 5 6 7 8 9 #> 4 11 5 8 3 9 2 2 3 2 #> 11 least connected regions: -#> 1001 1007 1018 1010 1045 1044 1046 1047 1049 1048 1015 with 1 link +#> with 1 link #> 2 most connected regions: -#> 1038 1036 with 9 links +#> with 9 links col005.w.mat <- nb2mat(col005, zero.policy=TRUE) col005.w.b <- mat2listw(col005.w.mat) #> Warning: style is M (missing); style should be set to a valid value +#> Warning: no-neighbour observations found, zero.policy set to TRUE summary(col005.w.b$neighbours) #> Neighbour list object: #> Number of regions: 49 @@ -150,14 +155,15 @@

Examples

#> Average number of links: 3.469388 #> 4 regions with no links: #> 1005 1006 1008 1043 +#> 8 disjoint connected subgraphs #> Link number distribution: #> #> 0 1 2 3 4 5 6 7 8 9 #> 4 11 5 8 3 9 2 2 3 2 #> 11 least connected regions: -#> 1001 1007 1018 1010 1045 1044 1046 1047 1049 1048 1015 with 1 link +#> with 1 link #> 2 most connected regions: -#> 1038 1036 with 9 links +#> with 9 links diffnb(col005, col005.w.b$neighbours) #> Neighbour list object: #> Number of regions: 49 @@ -169,8 +175,10 @@

Examples

#> 1009 1036 1011 1042 1041 1017 1043 1019 1012 1035 1032 1020 1021 1031 #> 1033 1034 1045 1013 1022 1044 1023 1046 1030 1024 1047 1016 1014 1049 #> 1029 1025 1028 1048 1015 1027 1026 +#> 49 disjoint connected subgraphs col005.w.mat.3T <- kronecker(diag(3), col005.w.mat) col005.w.b.3T <- mat2listw(col005.w.mat.3T, style="W") +#> Warning: no-neighbour observations found, zero.policy set to TRUE #> Warning: zero sum general weights summary(col005.w.b.3T$neighbours) #> Neighbour list object: @@ -180,14 +188,15 @@

Examples

#> Average number of links: 3.469388 #> 12 regions with no links: #> 1 3 6 21 50 52 55 70 99 101 104 119 +#> 24 disjoint connected subgraphs #> Link number distribution: #> #> 0 1 2 3 4 5 6 7 8 9 #> 12 33 15 24 9 27 6 6 9 6 #> 33 least connected regions: -#> 2 5 9 10 31 34 36 39 42 46 47 51 54 58 59 80 83 85 88 91 95 96 100 103 107 108 129 132 134 137 140 144 145 with 1 link +#> with 1 link #> 6 most connected regions: -#> 11 16 60 65 109 114 with 9 links +#> with 9 links run <- FALSE if (require("spatialreg", quiet=TRUE)) run <- TRUE if (run) { @@ -196,7 +205,10 @@

Examples

summary(col005.spM$neighbours) } #> Warning: style is M (missing); style should be set to a valid value +#> Warning: style is M (missing); style should be set to a valid value #> Warning: 1005, 1006, 1008, 1043 are not origins +#> Warning: no-neighbour observations found, zero.policy set to TRUE +#> Warning: no-neighbour observations found, zero.policy set to TRUE #> Neighbour list object: #> Number of regions: 49 #> Number of nonzero links: 170 @@ -204,14 +216,15 @@

Examples

#> Average number of links: 3.469388 #> 4 regions with no links: #> 1005 1006 1008 1043 +#> 8 disjoint connected subgraphs #> Link number distribution: #> #> 0 1 2 3 4 5 6 7 8 9 #> 4 11 5 8 3 9 2 2 3 2 #> 11 least connected regions: -#> 1001 1007 1018 1010 1045 1044 1046 1047 1049 1048 1015 with 1 link +#> with 1 link #> 2 most connected regions: -#> 1038 1036 with 9 links +#> with 9 links if (run) { diffnb(col005, col005.spM$neighbours) } @@ -225,12 +238,16 @@

Examples

#> 1009 1036 1011 1042 1041 1017 1043 1019 1012 1035 1032 1020 1021 1031 #> 1033 1034 1045 1013 1022 1044 1023 1046 1030 1024 1047 1016 1014 1049 #> 1029 1025 1028 1048 1015 1027 1026 +#> 49 disjoint connected subgraphs if (run && require("Matrix", quiet=TRUE)) { IW <- kronecker(Diagonal(3), W) col005.spM.3T <- mat2listw(as(IW, "CsparseMatrix"), style="W") summary(col005.spM.3T$neighbours) } +#> Warning: style is M (missing); style should be set to a valid value #> Warning: 1, 3, 6, 21, 50, 52, 55, 70, 99, 101, 104, 119 are not origins +#> Warning: no-neighbour observations found, zero.policy set to TRUE +#> Warning: no-neighbour observations found, zero.policy set to TRUE #> Warning: zero sum general weights #> Neighbour list object: #> Number of regions: 147 @@ -239,14 +256,15 @@

Examples

#> Average number of links: 3.469388 #> 12 regions with no links: #> 1 3 6 21 50 52 55 70 99 101 104 119 +#> 24 disjoint connected subgraphs #> Link number distribution: #> #> 0 1 2 3 4 5 6 7 8 9 #> 12 33 15 24 9 27 6 6 9 6 #> 33 least connected regions: -#> 2 5 9 10 31 34 36 39 42 46 47 51 54 58 59 80 83 85 88 91 95 96 100 103 107 108 129 132 134 137 140 144 145 with 1 link +#> with 1 link #> 6 most connected regions: -#> 11 16 60 65 109 114 with 9 links +#> with 9 links
diff --git a/docs/reference/moran.html b/docs/reference/moran.html index e6219210..6598d918 100644 --- a/docs/reference/moran.html +++ b/docs/reference/moran.html @@ -20,7 +20,7 @@ spdep - 1.2-8 + 1.3-1 @@ -78,7 +78,7 @@

Compute Moran's I

-
moran(x, listw, n, S0, zero.policy=NULL, NAOK=FALSE)
+
moran(x, listw, n, S0, zero.policy=attr(listw, "zero.policy"), NAOK=FALSE)
@@ -96,7 +96,7 @@

Arguments

global sum of weights

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

NAOK

if 'TRUE' then any 'NA' or 'NaN' or 'Inf' values in x are passed on to the foreign function. If 'FALSE', the presence of 'NA' or 'NaN' or 'Inf' values is regarded as an error.

diff --git a/docs/reference/moran.mc.html b/docs/reference/moran.mc.html index 52a3218a..070aa179 100644 --- a/docs/reference/moran.mc.html +++ b/docs/reference/moran.mc.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,8 +72,9 @@

Permutation test for Moran's I statistic

-
moran.mc(x, listw, nsim, zero.policy=NULL, alternative="greater",
- na.action=na.fail, spChk=NULL, return_boot=FALSE, adjust.n=TRUE)
+
moran.mc(x, listw, nsim, zero.policy=attr(listw, "zero.policy"),
+ alternative="greater", na.action=na.fail, spChk=NULL, return_boot=FALSE,
+ adjust.n=TRUE)
@@ -88,7 +89,7 @@

Arguments

number of permutations

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of "greater" (default), "two.sided", or "less".

diff --git a/docs/reference/moran.plot.html b/docs/reference/moran.plot.html index 8a405455..0f6e7c8f 100644 --- a/docs/reference/moran.plot.html +++ b/docs/reference/moran.plot.html @@ -20,7 +20,7 @@ spdep - 1.2-8 + 1.3-1
@@ -78,7 +78,7 @@

Moran scatterplot

-
moran.plot(x, listw, zero.policy=NULL, spChk=NULL, labels=NULL,
+    
moran.plot(x, listw, zero.policy=attr(listw, "zero.policy"), spChk=NULL, labels=NULL,
  xlab=NULL, ylab=NULL, quiet=NULL, plot=TRUE, return_df=TRUE, ...)
@@ -91,7 +91,7 @@

Arguments

a listw object created for example by nb2listw

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

spChk

should the data vector names be checked against the spatial objects for identity integrity, TRUE, or FALSE, default NULL to use get.spChkOption()

diff --git a/docs/reference/moran.test.html b/docs/reference/moran.test.html index 629f4373..cc3b3d29 100644 --- a/docs/reference/moran.test.html +++ b/docs/reference/moran.test.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
@@ -72,7 +72,7 @@

Moran's I test for spatial autocorrelation

-
moran.test(x, listw, randomisation=TRUE, zero.policy=NULL,
+    
moran.test(x, listw, randomisation=TRUE, zero.policy=attr(listw, "zero.policy"),
  alternative="greater", rank = FALSE, na.action=na.fail, spChk=NULL,
  adjust.n=TRUE, drop.EI2=FALSE)
@@ -89,7 +89,7 @@

Arguments

variance of I calculated under the assumption of randomisation, if FALSE normality

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative

a character string specifying the alternative hypothesis, must be one of greater (default), less or two.sided.

@@ -386,6 +386,50 @@

Examples

#> Moran I statistic Expectation Variance #> 0.103248466 -0.020833333 0.008736122 #> +columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE) +col_geoms <- st_geometry(columbus) +col_geoms[1] <- st_buffer(col_geoms[1], dist=-0.05) +st_geometry(columbus) <- col_geoms +(nb1 <- poly2nb(columbus)) +#> Neighbour list object: +#> Number of regions: 49 +#> Number of nonzero links: 232 +#> Percentage nonzero weights: 9.662641 +#> Average number of links: 4.734694 +#> 1 region with no links: +#> 1 +#> 2 disjoint connected subgraphs +try(lw <- nb2listw(nb1, style="W")) +#> Error in nb2listw(nb1, style = "W") : Empty neighbour sets found +(lw <- nb2listw(nb1, style="W", zero.policy=TRUE)) +#> Characteristics of weights list object: +#> Neighbour list object: +#> Number of regions: 49 +#> Number of nonzero links: 232 +#> Percentage nonzero weights: 9.662641 +#> Average number of links: 4.734694 +#> 1 region with no links: +#> 1 +#> 2 disjoint connected subgraphs +#> +#> Weights style: W +#> Weights constants summary: +#> n nn S0 S1 S2 +#> W 48 2304 48 22.23035 199.8188 +moran.test(COL.OLD$CRIME, lw) +#> +#> Moran I test under randomisation +#> +#> data: COL.OLD$CRIME +#> weights: lw n reduced by no-neighbour observations +#> +#> +#> Moran I statistic standard deviate = 2.7707, p-value = 0.002797 +#> alternative hypothesis: greater +#> sample estimates: +#> Moran I statistic Expectation Variance +#> 0.23901261 -0.02127660 0.00882535 +#>
diff --git a/docs/reference/moran_bv.html b/docs/reference/moran_bv.html index be7f8f49..60a1c7ed 100644 --- a/docs/reference/moran_bv.html +++ b/docs/reference/moran_bv.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/mstree.html b/docs/reference/mstree.html index 9f6ae8ad..5b5847db 100644 --- a/docs/reference/mstree.html +++ b/docs/reference/mstree.html @@ -21,7 +21,7 @@ spdep - 1.2-8 + 1.3-1 @@ -142,7 +142,7 @@

Examples

### find a minimum spanning tree system.time(mst.bh <- mstree(nb.w,5)) #> user system elapsed -#> 0.003 0.000 0.002 +#> 0.002 0.000 0.002 dim(mst.bh) #> [1] 97 3 head(mst.bh) diff --git a/docs/reference/nb2INLA.html b/docs/reference/nb2INLA.html index da002cd4..2ac5e00d 100644 --- a/docs/reference/nb2INLA.html +++ b/docs/reference/nb2INLA.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/nb2WB.html b/docs/reference/nb2WB.html index 0a503bb8..5081e080 100644 --- a/docs/reference/nb2WB.html +++ b/docs/reference/nb2WB.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/nb2blocknb.html b/docs/reference/nb2blocknb.html index 90332f75..c2276d23 100644 --- a/docs/reference/nb2blocknb.html +++ b/docs/reference/nb2blocknb.html @@ -20,7 +20,7 @@ spdep - 1.2-8 + 1.3-1 @@ -195,6 +195,7 @@

Examples

#> Average number of links: 9.620553 #> 17 regions with no links: #> 1 55 56 57 58 65 196 257 284 285 286 287 342 343 348 349 354 +#> 92 disjoint connected subgraphs print(is.symmetric.nb(block.nb)) #> [1] TRUE plot(block.nb, boston.utm) diff --git a/docs/reference/nb2lines.html b/docs/reference/nb2lines.html index df8b32f5..38b287ec 100644 --- a/docs/reference/nb2lines.html +++ b/docs/reference/nb2lines.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -158,12 +158,12 @@

Examples

tf <- paste0(tempfile(), ".gpkg") st_write(res, dsn=tf, driver="GPKG") #> writing: substituting ENGCRS["Undefined Cartesian SRS with unknown unit"] for missing CRS -#> Writing layer `file6a4686e6e79e4' to data source -#> `/tmp/RtmplmhMKo/file6a4686e6e79e4.gpkg' using driver `GPKG' +#> Writing layer `file706d874b42afe' to data source +#> `/tmp/RtmpMRGWgk/file706d874b42afe.gpkg' using driver `GPKG' #> Writing 230 features with 5 fields and geometry type Line String. inMap <- st_read(tf) -#> Reading layer `file6a4686e6e79e4' from data source -#> `/tmp/RtmplmhMKo/file6a4686e6e79e4.gpkg' using driver `GPKG' +#> Reading layer `file706d874b42afe' from data source +#> `/tmp/RtmpMRGWgk/file706d874b42afe.gpkg' using driver `GPKG' #> Simple feature collection with 230 features and 5 fields #> Geometry type: LINESTRING #> Dimension: XY @@ -185,6 +185,7 @@

Examples

#> 3rd Qu.:0.2500 #> Max. :0.5000 diffnb(sn2listw(df2sn(as.data.frame(inMap)))$neighbours, col.gal.nb) +#> Warning: style is M (missing); style should be set to a valid value #> Neighbour list object: #> Number of regions: 49 #> Number of nonzero links: 0 @@ -193,6 +194,7 @@

Examples

#> 49 regions with no links: #> 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 +#> 49 disjoint connected subgraphs res1 <- listw2lines(nb2listw(col.gal.nb), as(columbus, "Spatial")) summary(res1) #> Object of class SpatialLinesDataFrame diff --git a/docs/reference/nb2listw.html b/docs/reference/nb2listw.html index 0e68dfea..fd9ebeee 100644 --- a/docs/reference/nb2listw.html +++ b/docs/reference/nb2listw.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -115,6 +115,16 @@

Value

weights

the weights for the neighbours and chosen style, with attributes set to report the type of relationships (binary or general, if general the form of the glist argument), and style as above

+

and attributes:

+
region.id
+

character, as the neighbour object

+ +
call
+

the function call

+ +
zero.policy
+

logical; the value of zero.policy when the object was created

+

References

@@ -163,9 +173,9 @@

Examples

#> 2 3 4 5 6 7 8 9 10 #> 7 7 13 4 9 6 1 1 1 #> 7 least connected regions: -#> 1 6 31 39 42 46 47 with 2 links +#> with 2 links #> 1 most connected region: -#> 20 with 10 links +#> with 10 links #> #> Weights style: minmax #> Weights constants summary: diff --git a/docs/reference/nb2listwdist.html b/docs/reference/nb2listwdist.html index 195e2ba8..a6ffbf2d 100644 --- a/docs/reference/nb2listwdist.html +++ b/docs/reference/nb2listwdist.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/nb2mat.html b/docs/reference/nb2mat.html index 8f311ccd..7f17e8bb 100644 --- a/docs/reference/nb2mat.html +++ b/docs/reference/nb2mat.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -131,14 +131,15 @@

Examples

#> Average number of links: 3.469388 #> 4 regions with no links: #> 1005 1006 1008 1043 +#> 8 disjoint connected subgraphs #> Link number distribution: #> #> 0 1 2 3 4 5 6 7 8 9 #> 4 11 5 8 3 9 2 2 3 2 #> 11 least connected regions: -#> 1001 1007 1018 1010 1045 1044 1046 1047 1049 1048 1015 with 1 link +#> with 1 link #> 2 most connected regions: -#> 1038 1036 with 9 links +#> with 9 links col005.w.mat <- nb2mat(col005, style="B", zero.policy=TRUE) table(round(rowSums(col005.w.mat))) #> diff --git a/docs/reference/nbcosts.html b/docs/reference/nbcosts.html index 50108d9d..bd83b003 100644 --- a/docs/reference/nbcosts.html +++ b/docs/reference/nbcosts.html @@ -19,7 +19,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/nbdists.html b/docs/reference/nbdists.html index d4dba049..24051943 100644 --- a/docs/reference/nbdists.html +++ b/docs/reference/nbdists.html @@ -20,7 +20,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/nblag.html b/docs/reference/nblag.html index d39402b1..08180e37 100644 --- a/docs/reference/nblag.html +++ b/docs/reference/nblag.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -122,32 +122,9 @@

Examples

#> 2 3 4 5 6 7 8 9 10 #> 7 7 13 4 9 6 1 1 1 #> 7 least connected regions: -#> 1 6 31 39 42 46 47 with 2 links +#> with 2 links #> 1 most connected region: -#> 20 with 10 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.1276 0.3613 0.4566 0.4694 0.5536 0.8924 -#> -#> The decimal point is 1 digit(s) to the left of the | -#> -#> 1 | 3344 -#> 1 | 99 -#> 2 | 000011333344 -#> 2 | 556677779999 -#> 3 | 000011222222223344444444 -#> 3 | 556666777777888888889999999999 -#> 4 | 00001111112233333333334444 -#> 4 | 55666666666666777777777788888899 -#> 5 | 0011112222222222222233334444 -#> 5 | 556666667788 -#> 6 | 000000112244 -#> 6 | 5577889999 -#> 7 | 11112244 -#> 7 | 557777 -#> 8 | 1144 -#> 8 | 55999999 -#> +#> with 10 links col.lags <- nblag(col.gal.nb, 2) print(col.lags) #> [[1]] @@ -177,30 +154,9 @@

Examples

#> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #> 1 2 5 4 2 3 5 4 2 3 7 3 4 1 1 1 1 #> 1 least connected region: -#> 36 with 1 link +#> with 1 link #> 1 most connected region: -#> 25 with 17 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.3209 0.7126 0.8481 0.9023 1.0860 1.6743 -#> -#> The decimal point is 1 digit(s) to the left of the | -#> -#> 3 | 2233557799 -#> 4 | 1166777788888888 -#> 5 | 0011224455555566666688889999 -#> 6 | 11113333334455556666666666889999999999 -#> 7 | 00000011112222222233334444444455555555556666667777777777777777889999 -#> 8 | 000011111111222222222233333344444444445555555555666666999999 -#> 9 | 001111222222222233444444555555556666667777778899 -#> 10 | 0000002222223333333344666666777788889999 -#> 11 | 00112233334444555566777788 -#> 12 | 1122223333555566667777888888889999 -#> 13 | 0000001166668899 -#> 14 | 002244558888 -#> 15 | 00667788 -#> 16 | 77 -#> +#> with 17 links plot(st_geometry(columbus), border="grey") plot(col.gal.nb, coords, add=TRUE) title(main="GAL order 1 (black) and 2 (red) links") diff --git a/docs/reference/nboperations.html b/docs/reference/nboperations.html index dbd0fb72..d632b070 100644 --- a/docs/reference/nboperations.html +++ b/docs/reference/nboperations.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -123,6 +123,7 @@

Examples

coords <- st_coordinates(st_centroid(columbus)) #> Warning: st_centroid assumes attributes are constant over geometries col.tri.nb <- tri2nb(coords) +#> Warning: style is M (missing); style should be set to a valid value oldpar <- par(mfrow=c(1,2)) if (require("dbscan", quietly=TRUE)) { col.soi.nb <- graph2nb(soi.graph(col.tri.nb, coords)) diff --git a/docs/reference/p.adjustSP.html b/docs/reference/p.adjustSP.html index 3d8fca33..5f0a44b7 100644 --- a/docs/reference/p.adjustSP.html +++ b/docs/reference/p.adjustSP.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/plot.mst.html b/docs/reference/plot.mst.html index 7b2930e5..740c6c01 100644 --- a/docs/reference/plot.mst.html +++ b/docs/reference/plot.mst.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/plot.nb.html b/docs/reference/plot.nb.html index 07b9eab4..2860ffc0 100644 --- a/docs/reference/plot.nb.html +++ b/docs/reference/plot.nb.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/plot.skater.html b/docs/reference/plot.skater.html index 769b8816..4c1c8fe4 100644 --- a/docs/reference/plot.skater.html +++ b/docs/reference/plot.skater.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/poly2nb.html b/docs/reference/poly2nb.html index cb31d61a..1cad8008 100644 --- a/docs/reference/poly2nb.html +++ b/docs/reference/poly2nb.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -142,6 +142,7 @@

Examples

#> 49 regions with no links: #> 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 +#> 49 disjoint connected subgraphs sfc_xx <- poly2nb(st_geometry(columbus)) diffnb(sfc_xx, xx) #> Neighbour list object: @@ -152,6 +153,7 @@

Examples

#> 49 regions with no links: #> 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 +#> 49 disjoint connected subgraphs xxx <- poly2nb(as(columbus, "Spatial"), queen=FALSE) dxxx <- diffnb(xxx, col.gal.nb) plot(st_geometry(columbus), border = "grey") @@ -172,7 +174,7 @@

Examples

nc.sids <- st_read(system.file("shapes/sids.shp", package="spData")[1], quiet=TRUE) system.time(xxnb <- poly2nb(nc.sids)) #> user system elapsed -#> 0.019 0.000 0.019 +#> 0.018 0.000 0.018 system.time(xxnb <- poly2nb(as(nc.sids, "Spatial"))) #> user system elapsed #> 0.029 0.000 0.029 @@ -210,6 +212,18 @@

Examples

#> [1] "rook" #> attr(,"sym") #> [1] TRUE +col_geoms <- st_geometry(columbus) +col_geoms[1] <- st_buffer(col_geoms[1], dist=-0.05) +st_geometry(columbus) <- col_geoms +poly2nb(columbus) +#> Neighbour list object: +#> Number of regions: 49 +#> Number of nonzero links: 232 +#> Percentage nonzero weights: 9.662641 +#> Average number of links: 4.734694 +#> 1 region with no links: +#> 1 +#> 2 disjoint connected subgraphs
diff --git a/docs/reference/probmap.html b/docs/reference/probmap.html index e0529a74..b5530ed5 100644 --- a/docs/reference/probmap.html +++ b/docs/reference/probmap.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/prunecost.html b/docs/reference/prunecost.html index a88c24f6..643ab1dc 100644 --- a/docs/reference/prunecost.html +++ b/docs/reference/prunecost.html @@ -22,7 +22,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/prunemst.html b/docs/reference/prunemst.html index dd636156..c1c7d0cf 100644 --- a/docs/reference/prunemst.html +++ b/docs/reference/prunemst.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/read.gal.html b/docs/reference/read.gal.html index 43659888..cf909402 100644 --- a/docs/reference/read.gal.html +++ b/docs/reference/read.gal.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/read.gwt2nb.html b/docs/reference/read.gwt2nb.html index ffa0ce52..342d26f8 100644 --- a/docs/reference/read.gwt2nb.html +++ b/docs/reference/read.gwt2nb.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -160,11 +160,13 @@

Examples

#> 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 #> 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 #> 208 209 210 211 +#> 211 disjoint connected subgraphs data(oldcol) tmpMAT <- tempfile() COL.W <- nb2listw(COL.nb) write.sn2dat(listw2sn(COL.W), tmpMAT) listwmat1 <- read.dat2listw(tmpMAT) +#> Warning: style is M (missing); style should be set to a valid value diffnb(listwmat1$neighbours, COL.nb, verbose=TRUE) #> Warning: region.id differ; using ids of first list #> Neighbour list object: @@ -175,8 +177,10 @@

Examples

#> 49 regions with no links: #> 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 +#> 49 disjoint connected subgraphs listwmat2 <- read.dat2listw(system.file("etc/weights/wmat.dat", package="spdep")[1]) +#> Warning: style is M (missing); style should be set to a valid value diffnb(listwmat1$neighbours, listwmat2$neighbours, verbose=TRUE) #> Neighbour list object: #> Number of regions: 49 @@ -186,6 +190,7 @@

Examples

#> 49 regions with no links: #> 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 +#> 49 disjoint connected subgraphs
diff --git a/docs/reference/rotation.html b/docs/reference/rotation.html index 454ef2e7..14b44425 100644 --- a/docs/reference/rotation.html +++ b/docs/reference/rotation.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/set.mcOption.html b/docs/reference/set.mcOption.html index e87139e0..de30630d 100644 --- a/docs/reference/set.mcOption.html +++ b/docs/reference/set.mcOption.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/set.spChkOption.html b/docs/reference/set.spChkOption.html index 63ad4472..fba7705d 100644 --- a/docs/reference/set.spChkOption.html +++ b/docs/reference/set.spChkOption.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/skater.html b/docs/reference/skater.html index bd32d118..aefe0190 100644 --- a/docs/reference/skater.html +++ b/docs/reference/skater.html @@ -20,7 +20,7 @@ spdep - 1.2-8 + 1.3-1 @@ -299,7 +299,7 @@

Examples

### calculating costs system.time(lcosts <- nbcosts(bh.nb, dpad)) #> user system elapsed -#> 0.039 0.000 0.040 +#> 0.042 0.000 0.043 ### making listw nb.w <- nb2listw(bh.nb, lcosts, style="B") ### find a minimum spanning tree @@ -322,7 +322,7 @@

Examples

### calculating costs system.time(plcosts <- nbcosts(bh.nb, dpad)) #> user system elapsed -#> 0.038 0.000 0.038 +#> 0.04 0.00 0.04 all.equal(lcosts, plcosts, check.attributes=FALSE) #> [1] TRUE ### making listw diff --git a/docs/reference/sp.correlogram.html b/docs/reference/sp.correlogram.html index 1fbd1971..30aa225a 100644 --- a/docs/reference/sp.correlogram.html +++ b/docs/reference/sp.correlogram.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/sp.mantel.mc.html b/docs/reference/sp.mantel.mc.html index 733d6a06..6525e1ca 100644 --- a/docs/reference/sp.mantel.mc.html +++ b/docs/reference/sp.mantel.mc.html @@ -23,7 +23,7 @@ spdep - 1.2-8 + 1.3-1 @@ -84,7 +84,7 @@

Mantel-Hubert spatial general cross product statistic

-
sp.mantel.mc(var, listw, nsim, type = "moran", zero.policy = NULL,
+    
sp.mantel.mc(var, listw, nsim, type = "moran", zero.policy = attr(listw, "zero.policy"),
  alternative = "greater", spChk=NULL, return_boot=FALSE)
 # S3 method for mc.sim
 plot(x, xlim, xlab, main, sub, ..., ptype="density")
@@ -105,7 +105,7 @@

Arguments

"moran", "geary" or "sokal" criteria for similarity

zero.policy
-

default NULL, use global option value; if TRUE assign zero to the lagged value of zones without +

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE assign zero to the lagged value of zones without neighbours, if FALSE assign NA

alternative
diff --git a/docs/reference/spdep-defunct.html b/docs/reference/spdep-defunct.html index 1a7d868c..b10d4cc2 100644 --- a/docs/reference/spdep-defunct.html +++ b/docs/reference/spdep-defunct.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/spdep.html b/docs/reference/spdep.html index ff7e7ed6..61945fb8 100644 --- a/docs/reference/spdep.html +++ b/docs/reference/spdep.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/spweights.constants.html b/docs/reference/spweights.constants.html index 0241be40..36f09baa 100644 --- a/docs/reference/spweights.constants.html +++ b/docs/reference/spweights.constants.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -72,7 +72,7 @@

Provides constants for spatial weights matrices

-
spweights.constants(listw, zero.policy=NULL, adjust.n=TRUE)
+    
spweights.constants(listw, zero.policy=attr(listw, "zero.policy"), adjust.n=TRUE)
 Szero(listw)
@@ -82,7 +82,7 @@

Arguments

a listw object from for example nb2listw

zero.policy
-

default NULL, use global option value; if TRUE ignore zones without neighbours, if FALSE fail when encountered

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if TRUE ignore zones without neighbours, if FALSE fail when encountered

adjust.n

default TRUE, if FALSE the number of observations is not adjusted for no-neighbour observations, if TRUE, the number of observations is adjusted

diff --git a/docs/reference/ssw.html b/docs/reference/ssw.html index 4baf342e..807e7eab 100644 --- a/docs/reference/ssw.html +++ b/docs/reference/ssw.html @@ -18,7 +18,7 @@ spdep - 1.2-8 + 1.3-1
diff --git a/docs/reference/subset.listw.html b/docs/reference/subset.listw.html index 3fb56aae..e89702d9 100644 --- a/docs/reference/subset.listw.html +++ b/docs/reference/subset.listw.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -73,7 +73,7 @@

Subset a spatial weights list

# S3 method for listw
-subset(x, subset, zero.policy = NULL, ...)
+subset(x, subset, zero.policy = attr(x, "zero.policy"), ...)
@@ -85,7 +85,7 @@

Arguments

logical expression

zero.policy
-

default NULL, use global option value; if FALSE stop with error for any empty neighbour sets, if TRUE permit the weights list to be formed with zero-length weights vectors - passed through to nb2listw

+

default attr(x, "zero.policy") as set when x was created, if attribute not set, use global option value; if FALSE stop with error for any empty neighbour sets, if TRUE permit the weights list to be formed with zero-length weights vectors - passed through to nb2listw

...

generic function pass-through

@@ -95,7 +95,7 @@

Arguments

Value

-

The function returns an object of class listw with component style the same as the input object, component neighbours a list of integer vectors containing neighbour region number ids (compacted to run from 1:number of regions in subset), and component weights as the weights computed for neighbours using style.

+

The function returns an object of class listw with component style the same as the input object, component neighbours a list of integer vectors containing neighbour region number ids (compacted to run from 1:number of regions in subset), and component weights as the weights computed for neighbours using style. If no-neighbour observations are created by subsetting and zero.policy in the input weights object was FALSE, it will be set to TRUE and a warning issued.

Author

@@ -136,6 +136,46 @@

Examples

#> Weights constants summary: #> n nn S0 S1 S2 #> W 43 1849 43 19.26584 178.4604 +columbus <- st_read(system.file("shapes/columbus.shp", package="spData")[1], quiet=TRUE) +nb <- poly2nb(columbus) +lw <- nb2listw(nb, style="W") +attr(lw, "zero.policy") +#> [1] FALSE +(lwa <- subset(lw, 1:nrow(columbus) != c(21))) +#> Warning: subsetting caused increase in subgraph count +#> Characteristics of weights list object: +#> Neighbour list object: +#> Number of regions: 48 +#> Number of nonzero links: 230 +#> Percentage nonzero weights: 9.982639 +#> Average number of links: 4.791667 +#> 2 disjoint connected subgraphs +#> +#> Weights style: W +#> Weights constants summary: +#> n nn S0 S1 S2 +#> W 48 2304 48 22.46811 199.4398 +attr(lwa, "zero.policy") +#> [1] FALSE +(lwb <- subset(lw, !(1:nrow(columbus) %in% c(21, 36, 39)))) +#> Warning: subsetting caused increase in subgraph count +#> Warning: subsetting created no-neighbour observations, zero.policy set TRUE +#> Characteristics of weights list object: +#> Neighbour list object: +#> Number of regions: 46 +#> Number of nonzero links: 216 +#> Percentage nonzero weights: 10.20794 +#> Average number of links: 4.695652 +#> 1 region with no links: +#> 46 +#> 3 disjoint connected subgraphs +#> +#> Weights style: W +#> Weights constants summary: +#> n nn S0 S1 S2 +#> W 45 2025 45 22.857 187.4843 +attr(lwb, "zero.policy") +#> [1] TRUE
diff --git a/docs/reference/subset.nb.html b/docs/reference/subset.nb.html index e2dabf25..cf36bc0c 100644 --- a/docs/reference/subset.nb.html +++ b/docs/reference/subset.nb.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/summary.nb.html b/docs/reference/summary.nb.html index 729594e6..79407597 100644 --- a/docs/reference/summary.nb.html +++ b/docs/reference/summary.nb.html @@ -19,7 +19,7 @@ spdep - 1.2-8 + 1.3-1 @@ -81,10 +81,10 @@

Print and summary function for neighbours and weights lists

# S3 method for nb print(x, ...) # S3 method for listw -summary(object, coords, longlat, zero.policy = NULL, - scale = 1, ...) +summary(object, coords, longlat, zero.policy = attr(object, "zero.policy"), + scale = 1, adjust.n=TRUE, ...) # S3 method for listw -print(x, zero.policy = NULL, ...)
+print(x, zero.policy = attr(x, "zero.policy"), ...)
@@ -105,11 +105,14 @@

Arguments

an object of class nb

zero.policy
-

default NULL, use global option value; if FALSE stop with error for any empty neighbour sets

+

default attr(listw, "zero.policy") as set when listw was created, if attribute not set, use global option value; if FALSE stop with error for any empty neighbour sets

scale

passed through to stem() for control of plot length

+
adjust.n
+

default TRUE, if FALSE the number of observations is not adjusted for no-neighbour observations, if TRUE, the number of observations in spweights.constants is adjusted

+

Author

@@ -142,32 +145,9 @@

Examples

#> 2 3 4 5 6 7 8 9 10 #> 7 7 13 4 9 6 1 1 1 #> 7 least connected regions: -#> 1 6 31 39 42 46 47 with 2 links +#> with 2 links #> 1 most connected region: -#> 20 with 10 links -#> Summary of link distances: -#> Min. 1st Qu. Median Mean 3rd Qu. Max. -#> 0.1276 0.3613 0.4566 0.4694 0.5536 0.8924 -#> -#> The decimal point is 1 digit(s) to the left of the | -#> -#> 1 | 3344 -#> 1 | 99 -#> 2 | 000011333344 -#> 2 | 556677779999 -#> 3 | 000011222222223344444444 -#> 3 | 556666777777888888889999999999 -#> 4 | 00001111112233333333334444 -#> 4 | 55666666666666777777777788888899 -#> 5 | 0011112222222222222233334444 -#> 5 | 556666667788 -#> 6 | 000000112244 -#> 6 | 5577889999 -#> 7 | 11112244 -#> 7 | 557777 -#> 8 | 1144 -#> 8 | 55999999 -#> +#> with 10 links col.listw <- nb2listw(col.gal.nb, style="W") col.listw #> Characteristics of weights list object: @@ -193,14 +173,83 @@

Examples

#> 2 3 4 5 6 7 8 9 10 #> 7 7 13 4 9 6 1 1 1 #> 7 least connected regions: -#> 1 6 31 39 42 46 47 with 2 links +#> with 2 links #> 1 most connected region: -#> 20 with 10 links +#> with 10 links #> #> Weights style: W #> Weights constants summary: #> n nn S0 S1 S2 #> W 49 2401 49 23.48489 204.6687 +col_geoms <- st_geometry(columbus) +col_geoms[21] <- st_buffer(col_geoms[21], dist=-0.05) +st_geometry(columbus) <- col_geoms +nb <- poly2nb(columbus) +summary(nb) +#> Neighbour list object: +#> Number of regions: 49 +#> Number of nonzero links: 230 +#> Percentage nonzero weights: 9.579342 +#> Average number of links: 4.693878 +#> 1 region with no links: +#> 21 +#> 3 disjoint connected subgraphs +#> Link number distribution: +#> +#> 0 2 3 4 5 6 7 8 9 10 +#> 1 5 9 12 4 10 2 4 1 1 +#> 5 least connected regions: +#> with 2 links +#> 1 most connected region: +#> with 10 links +try(nb2listw(nb, style="W")) +#> Error in nb2listw(nb, style = "W") : Empty neighbour sets found +summary(nb2listw(nb, style="W", zero.policy=TRUE)) +#> Characteristics of weights list object: +#> Neighbour list object: +#> Number of regions: 49 +#> Number of nonzero links: 230 +#> Percentage nonzero weights: 9.579342 +#> Average number of links: 4.693878 +#> 1 region with no links: +#> 21 +#> 3 disjoint connected subgraphs +#> Link number distribution: +#> +#> 0 2 3 4 5 6 7 8 9 10 +#> 1 5 9 12 4 10 2 4 1 1 +#> 5 least connected regions: +#> with 2 links +#> 1 most connected region: +#> with 10 links +#> +#> Weights style: W +#> Weights constants summary: +#> n nn S0 S1 S2 +#> W 48 2304 48 22.46811 199.4398 +summary(nb2listw(nb, style="W", zero.policy=TRUE), adjust.n=FALSE) +#> Characteristics of weights list object: +#> Neighbour list object: +#> Number of regions: 49 +#> Number of nonzero links: 230 +#> Percentage nonzero weights: 9.579342 +#> Average number of links: 4.693878 +#> 1 region with no links: +#> 21 +#> 3 disjoint connected subgraphs +#> Link number distribution: +#> +#> 0 2 3 4 5 6 7 8 9 10 +#> 1 5 9 12 4 10 2 4 1 1 +#> 5 least connected regions: +#> with 2 links +#> 1 most connected region: +#> with 10 links +#> +#> Weights style: W +#> Weights constants summary: +#> n nn S0 S1 S2 +#> W 49 2401 48 22.46811 199.4398
diff --git a/docs/reference/testnb.html b/docs/reference/testnb.html index 100455e6..15f3b916 100644 --- a/docs/reference/testnb.html +++ b/docs/reference/testnb.html @@ -21,7 +21,7 @@ spdep - 1.2-8 + 1.3-1 diff --git a/docs/reference/tolerance.nb.html b/docs/reference/tolerance.nb.html index bab5e25c..14a72c2e 100644 --- a/docs/reference/tolerance.nb.html +++ b/docs/reference/tolerance.nb.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -131,6 +131,7 @@

Examples

nb.ex<-tolerance.nb(ex.data, unit.angle = "degrees", max.dist=1, tolerance = 30) #> Warning: style is M (missing); style should be set to a valid value +#> Warning: no-neighbour observations found, zero.policy set to TRUE ### Construct object of class nb with a tolerance angle of 30 degrees ### and a maximum distance of 2 m. The coordinates are rotated at an angle @@ -138,6 +139,7 @@

Examples

nb.ex2<-tolerance.nb(ex.data, unit.angle = "degrees", max.dist=1, tolerance = 30, rot.angle = 45) #> Warning: style is M (missing); style should be set to a valid value +#> Warning: no-neighbour observations found, zero.policy set to TRUE ### Construct object of class nb with a tolerance angle of pi/8 radians ### and a maximum distance of 1.5 m. The coordinates are rotated at @@ -145,6 +147,7 @@

Examples

nb.ex3<-tolerance.nb(ex.data, unit.angle = "radians", max.dist=1.5, tolerance = pi/8, rot.angle = -pi*2/3) #> Warning: style is M (missing); style should be set to a valid value +#> Warning: no-neighbour observations found, zero.policy set to TRUE par(mfrow=c(1,3)) plot(nb.ex,ex.data,asp=1) diff --git a/docs/reference/tri2nb.html b/docs/reference/tri2nb.html index da273b68..333cf48f 100644 --- a/docs/reference/tri2nb.html +++ b/docs/reference/tri2nb.html @@ -20,7 +20,7 @@ spdep - 1.2-8 + 1.3-1 @@ -126,6 +126,7 @@

Examples

ind <- row.names(columbus) suppressPackageStartupMessages(require(deldir)) col.tri.nb <- tri2nb(coords, row.names=ind) +#> Warning: style is M (missing); style should be set to a valid value plot(st_geometry(columbus), border="grey") plot(col.tri.nb, coords, add=TRUE) title(main="Raw triangulation links", cex.main=0.6) @@ -134,9 +135,11 @@

Examples

y <- seq(0,2,0.2) xy <- expand.grid(x, y) try(xy.nb <- tri2nb(xy)) +#> Warning: style is M (missing); style should be set to a valid value seed <- 1234 xid <- sample(1:nrow(xy)) xy.nb <- tri2nb(xy[xid,]) +#> Warning: style is M (missing); style should be set to a valid value plot(xy.nb, xy[xid,]) # example of reading points with readr::read_csv() yielding a tibble @@ -144,6 +147,7 @@

Examples

class(coords) #> [1] "spec_tbl_df" "tbl_df" "tbl" "data.frame" nb <- tri2nb(coords) +#> Warning: style is M (missing); style should be set to a valid value plot(nb, coords)
diff --git a/docs/reference/write.nb.gal.html b/docs/reference/write.nb.gal.html index f22de506..4aefdcc1 100644 --- a/docs/reference/write.nb.gal.html +++ b/docs/reference/write.nb.gal.html @@ -17,7 +17,7 @@ spdep - 1.2-8 + 1.3-1 @@ -117,6 +117,7 @@

Examples

#> 49 regions with no links: #> 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 +#> 49 disjoint connected subgraphs #> Link number distribution: #> #> 0