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 @@
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 @@ @@ -410,9 +410,9 @@## 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
## 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
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
+listw2star(listw, ireg, style, n, D, a, zero.policy=attr(listw, "zero.policy"))+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.++## with 9 links@@ -172,9 +168,9 @@Syracuse <- NY8[NY8$AREANAME == "Syracuse city",] Sy0_nb <- subset(NY_nb, NY8$AREANAME == "Syracuse city") summary(Sy0_nb)
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
Creating Contiguity Neighbours @@ -186,12 +182,12 @@
Creating Contiguity Neighbours
+class(Syracuse)
-## [1] "SpatialPolygonsDataFrame" ## attr(,"package") ## [1] "sp"
@@ -80,11 +80,11 @@+@@ -210,11 +206,11 @@## [1] TRUE
Creating Contiguity Neighbours
+-## [1] FALSE
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 @@+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
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 @@+ -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 @@+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
+@@ -374,7 +373,7 @@## Triangulation Gabriel Relative SOI ## 1 1 1 1
Distance-Based Neighboursnb object by
knn2nb()
;knearneigh()
can also take alonglat=
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
@@ -73,7 +73,7 @@+-## 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. -@@ -72,8 +72,8 @@+-## Min. 1st Qu. Median Mean 3rd Qu. Max. ## 395.7 587.3 700.1 760.4 906.1 1544.6
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 @@+max_1nn <- max(dsts) max_1nn
-## [1] 1544.615
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 @@+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
+-## 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)
@@ -114,32 +114,9 @@+par(oopar)
a: Neighbours within 1,158m; b: neighbours within 1,545m; c: neighbours within 2,317m
@@ -459,7 +458,7 @@Distance-Based Neighbours -
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 @@+@@ -150,9 +150,9 @@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 -
+dsts0 <- unlist(nbdists(NY_nb, coordinates(NY8))) summary(dsts0)
## Min. 1st Qu. Median Mean 3rd Qu. Max. @@ -512,7 +511,7 @@
function takes an existing neighbour list and returns a list of lists, from first toHigher-Order Neighboursnblag()
maxlag=
order neighbours. -+@@ -72,7 +72,7 @@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 -
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 @@+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
@@ -229,9 +229,9 @@+## ## 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 @@
Comparison of sp and sf approaches} if (dothis) sf_extSoftVersion()
+## "9.3.0"## 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"
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
+## 0.0925 0.0038 0.0965## user system elapsed -## 0.0946 0.0039 0.0988
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:
-@@ -82,7 +82,7 @@+class(st_geometry(NY8_sf_old))
-## [1] "sfc_POLYGON" "sfc"
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 @@+class(st_geometry(NY8_sf_old_val))
## [1] "sfc_GEOMETRY" "sfc"
and checking the
-"sfg"
objects, two now have objects of different topological dimensions.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 @@+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: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 @@+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:
-@@ -143,46 +143,15 @@+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:
-@@ -372,20 +377,20 @@+all.equal(NY8_sf_old_1_nb_val, NY8_sf_old_1_nb, check.attributes=FALSE)
## [1] TRUE
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: -
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 @@+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: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 @@+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):
-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 @@+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:
-@@ -394,10 +399,13 @@+st_is_longlat(NY8_ct_sf)
## [1] FALSE
Graph-based neighbours
From this, we can check the graph-based neighbours (planar coordinates only):
-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 @@++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
@@ -416,44 +424,44 @@+NY86_nb <- graph2nb(gabrielneigh(NY8_ct_sf)) NY87_nb <- graph2nb(relativeneigh(NY8_ct_sf))
K-nearest neighboursdbscan::kNN() in 2D or 3D building a kd-tree is used: -
@@ -137,9 +137,9 @@+system.time(for (i in 1:reps) NY88_nb_sf <- knn2nb(knearneigh(NY8_ct_sf, k=1)))/reps
+## 0.0174 0.0009 0.0183## user system elapsed -## 0.0176 0.0009 0.0185
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
+## 0.0174 0.0013 0.0188## user system elapsed -## 0.0183 0.0009 0.0192
@@ -105,7 +105,7 @@Distance neighbours
Distance neighbours need a threshold -
-nbdists
shows the maximum distance to first nearest neighbour: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 @@+-## Min. 1st Qu. Median Mean 3rd Qu. Max. ## 82.85 912.85 1801.11 3441.04 4461.26 17033.11
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 @@+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
+## 0.0315 0.0011 0.0327## user system elapsed -## 0.0324 0.0012 0.0337
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 argumentuse_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
+## 0.0163 0.0015 0.0178## user system elapsed -## 0.0185 0.0016 0.0202
@@ -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)
@@ -475,45 +483,45 @@## [1] TRUE
K-nearest neighbourssf_use_s2() is
TRUE
,knearneigh()
will use spatially indexed points ands2::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:
-@@ -72,7 +72,7 @@+sf_use_s2(TRUE) system.time(for (i in 1:reps) pts_ll1_nb <- knn2nb(knearneigh(pts_ll, k=6)))/reps
+## 0.0252 0.0000 0.0252## user system elapsed -## 0.0254 0.0000 0.0255
For this smaller data set, the legacy approach without spatial indexing is adequate, but slows down as the number of observations increases:
-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 @@+sf_use_s2(FALSE)
-## Spherical geometry (s2) switched off
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 @@+system.time(for (i in 1:reps) pts_ll2_nb <- knn2nb(knearneigh(pts_ll, k=6)))/reps
+## 0.0191 0.0000 0.0191## user system elapsed -## 0.0195 0.0000 0.0195
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"
@@ -72,7 +72,7 @@+pts_ll1_nb[[52]]
-## [1] 15 38 48 49 50 53
+pts_ll2_nb[[52]]
-## [1] 37 38 48 49 50 53
@@ -67,7 +67,16 @@+pts_ll1_nb[[124]]
-## [1] 117 122 123 125 133 134
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 @@+pts_ll2_nb[[124]]
-## [1] 116 117 123 125 133 134
@@ -529,9 +537,9 @@+sf_use_s2(old_use_s2)
## Spherical geometry (s2) switched on
Distance neighbours. -
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 @@+-max_1nn_ll <- max(unlist(nbdists(knn2nb(knearneigh(pts_ll, k=1)), pts_ll)))
+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 @@
is run: -Distance neighbourss2::s2_dwithin_matrix()
+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) }
+## 0.0440 0.0000 0.0445## user system elapsed -## 0.0445 0.0000 0.0450
Alternatively, spherical distances can be used with
-dwithin=FALSE
ands2::s2_closest_edges()
; although running in similar time,s2::s2_closest_edges()
depends on the additionalk=
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()
respectsd1 > 0
without requiring a second pass in R, so is faster thans2::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) }
+## 0.0270 0.0000 0.0275## user system elapsed -## 0.027 0.000 0.027
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:+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)+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
+## 0.0097 0.0000 0.0097## user system elapsed -## 0.0099 0.0000 0.0100
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. -
++## 37055 37095 +## 3 disjoint connected subgraphsNY8_sf_ll <- st_transform(NY8_sf, "OGC:CRS84") st_is_longlat(NY8_sf_ll)
@@ -665,11 +673,11 @@## [1] TRUE
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: -
@@ -124,8 +124,8 @@+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
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 @@+## 0.1553 0.0013 0.1572
+all.equal(NY8_sf_1_nb, NY8_sf_1_nb_ll, check.attributes=FALSE)
## [1] TRUE
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
@@ -469,13 +470,13 @@plot(st_geometry(nc), border="grey") plot(ncCC89, st_centroid(st_geometry(nc), of_largest_polygon), add=TRUE, col="blue")
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
+tm_shape(nc) + tm_fill("pmap", breaks=brks, midpoint=0.5, palette="RdBu") + tm_layout(legend.outside=TRUE)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)
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)+tm_shape(nc) + tm_fill("stdres", breaks=brks, midpoint=0, palette="RdBu") + tm_layout(legend.outside=TRUE)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)
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)
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 @@
Changelog
-+Version 1.2-8 (development)2023-02-28
+Version 1.3-1 (development)
+
- +
summary.nb
,print.nb
,summary.listw
andprint.listw
now report the subgraph count fromn.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 creatinglistw
objects:nb2listw
,sn2listw
,mat2listw
,nb2listwdist
. Defaultzero.policy=
argument updated to useattr(., "zero.policy")
insummary.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.exact
andlm.morantest.sad
- +
confusing error message in
moran.plot()
if no-neighbour cases, butzero.policy=FALSE
- +
replace
rgrass7
withrgrass
in vignette- +
fix #133 (
edit.nb
affected by not attachingsp
)+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 @@Version 1.2-8 (2023-02-28)2023-02-28
mat2listw()
warning if nostyle=
argument given, or ifM"
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()
andlocal_joincount_uni()
getno_repeat_in_row=
arguments.- 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 @@
Address 2) in #124;
localG_perm()
andlocalmoran_perm()
getno_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.Permutation test for empirical Bayes index
-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 @@@@ -92,7 +92,7 @@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)
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 whenlistw
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 NAalternative @@ -184,7 +184,7 @@ a character string specifying the alternative hypothesis, must be one of "greater" (default), "two.sided", or "less"
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 #>Chi-square based test for local spatial heteroscedasticity
-@@ -76,7 +76,8 @@@@ -85,7 +85,7 @@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)
Arguments
a
listw
object created for example bynb2listw
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 whenlistw
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 NAna.action 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 @@ a function (default
na.fail
), can also bena.omit
orna.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 tonb2listw
may be subsetted. Ifna.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.*)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 @@@@ -72,8 +72,8 @@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 whenlistw
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 NAna.action 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 @@ a function (default
na.fail
), can also bena.omit
orna.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 tonb2listw
may be subsetted. Ifna.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.*)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 @@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 @@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 whenlistw
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 NAna.action @@ -154,10 +154,10 @@ a function (default
na.fail
), can also bena.omit
orna.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 tonb2listw
may be subsetted. Ifna.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.*)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 @@Examples
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 @@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 @@
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 @@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 @@Compute Geary's C
-@@ -72,7 +72,7 @@@@ -104,7 +104,7 @@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") -->
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
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 @@ default
attr(listw, "zero.policy")
as set whenlistw
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 NAPermutation test for Geary's C statistic
-@@ -88,7 +88,7 @@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)
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 whenlistw
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 NAalternative @@ -160,12 +160,12 @@ 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).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.2047Geary's C test for spatial autocorrelation
-@@ -72,7 +72,7 @@@@ -88,7 +88,7 @@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)
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 whenlistw
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 NAalternative 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 @@ a character string specifying the alternative hypothesis, must be one of "greater" (default), "less" or "two.sided".
Global G test for spatial autocorrelation
-@@ -211,6 +211,7 @@@@ -85,7 +85,7 @@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)
Arguments
a
listw
object created for example bynb2listw
; if a sequence of distance bands is to be used, it is recommended that the weights style be binary (one ofc("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 whenlistw
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 NAalternative 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 @@ a character string specifying the alternative hypothesis, must be one of "greater" (default), "less" or "two.sided".
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 @@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 @@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 linksPermutation 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 @@@@ -72,7 +72,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 whenlistw
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 NAalternative 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 @@ a character string specifying the alternative hypothesis, must be one of "greater" (default), "two.sided", or "less".
BB, BW and Jtot join count statistic for k-coloured factors
-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 @@@@ -161,26 +161,9 @@joincount.multi(fx, listw, zero.policy = FALSE, +
@@ -87,7 +87,7 @@joincount.multi(fx, listw, zero.policy = attr(listw, "zero.policy"), spChk = NULL, adjust.n=TRUE) # S3 method for jcmulti print(x, ...)
Arguments
a
listw
object created for example bynb2listw
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 whenlistw
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 NAadjust.n @@ -127,7 +127,42 @@ 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)
See also
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 @@Examples
-data(oldcol) +
@@ -84,7 +84,7 @@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 @@BB join count statistic for k-coloured factors
-joincount.test(fx, listw, zero.policy=NULL, alternative="greater", +
@@ -99,7 +99,7 @@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, ...)
Arguments
a
listw
object created for example bynb2listw
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 whenlistw
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 NAalternative @@ -357,6 +357,78 @@ a character string specifying the alternative hypothesis, must be one of "greater" (default), "less" or "two.sided".
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 +#>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 @@Spatial lag of a numeric vector
@@ -85,7 +85,7 @@@@ -80,7 +80,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 whenlistw
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 NANAOK 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 @@ 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.
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 @@@@ -72,7 +72,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 whenlistw
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 NANAOK 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 @@ 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.
Permutation test for Lee's L statistic
-@@ -72,7 +72,7 @@@@ -91,7 +91,7 @@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)
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 whenlistw
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 NAalternative 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 @@ a character string specifying the alternative hypothesis, must be one of "greater" (default), "two.sided", or "less".
Lee's L test for spatial autocorrelation
-@@ -77,7 +77,7 @@@@ -89,7 +89,7 @@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)
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 whenlistw
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/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 @@
a character string specifying the alternative hypothesis, must be one of greater (default), less or two.sided.
Spatial neighbour sparse representation
+sn2listw(sn, style = NULL, zero.policy = NULL)listw2sn(listw) -sn2listw(sn)
@@ -88,6 +88,12 @@Arguments
sn + a
spatial.neighbour
objectstyle ++ + default NULL, missing, set to "M" and warning given; if not "M", passed to
nb2listw
to re-build the objectzero.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
@@ -86,7 +86,8 @@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 @@Lagrange Multiplier diagnostics for spatial dependence in linear models
-lm.LMtests(model, listw, zero.policy=NULL, test="LMerr", spChk=NULL, naSubset=TRUE) +
@@ -72,9 +72,10 @@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 whenlistw
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 NAtest 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 @@Exact global Moran's I test
-@@ -72,8 +72,8 @@@@ -89,7 +90,7 @@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) +
Arguments
a
listw
object created for example bynb2listw
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 whenlistw
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 NAalternative 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 @@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 @@@@ -74,10 +74,10 @@Arguments
a
listw
object created for example bynb2listw
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 whenlistw
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 NAalternative 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 @@Saddlepoint approximation of global Moran's I test
-@@ -84,9 +84,9 @@@@ -132,7 +132,7 @@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) +
@@ -77,29 +77,29 @@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 bynb2listw
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 whenlistw
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 NAalternative 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 @@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)
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 whenlistw
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 @@ -247,7 +247,9 @@ default NULL, used to set the seed for possible parallel RNGs
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 @@G and Gstar local spatial statistics
-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 @@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 @@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)
Local Moran's I statistic
-@@ -100,7 +100,7 @@@@ -98,7 +98,7 @@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)
Arguments
a
listw
object created for example bynb2listw
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 whenlistw
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 NAna.action 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 @@ a function (default
na.fail
), can also bena.omit
orna.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 tonb2listw
may be subsetted. Ifna.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.*)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)
can take values W, B, C, and S
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
mat2listw(x, row.names = NULL, style=NULL)
mat2listw(x, row.names = NULL, style=NULL, zero.policy = NULL)
default NULL, missing, set to "M" and warning given; if not "M", passed to nb2listw
to re-build the object
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
moran(x, listw, n, S0, zero.policy=NULL, NAOK=FALSE)
moran(x, listw, n, S0, zero.policy=attr(listw, "zero.policy"), NAOK=FALSE)
global sum of weights
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
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.
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)
number of permutations
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
a character string specifying the alternative hypothesis, must be one of "greater" (default), "two.sided", or "less".
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, ...)
a listw
object created for example by nb2listw
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
should the data vector names be checked against the spatial objects for identity integrity, TRUE, or FALSE, default NULL to use get.spChkOption()
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)
variance of I calculated under the assumption of randomisation, if FALSE normality
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
a character string specifying the alternative hypothesis, must be one of greater (default), less or two.sided.
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:
+character, as the neighbour object
the function call
logical; the value of zero.policy
when the object was created
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 @@
spweights.constants(listw, zero.policy=NULL, adjust.n=TRUE)
+ spweights.constants(listw, zero.policy=attr(listw, "zero.policy"), adjust.n=TRUE)
Szero(listw)
a listw
object from for example nb2listw
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
default TRUE, if FALSE the number of observations is not adjusted for no-neighbour observations, if TRUE, the number of observations is adjusted
# S3 method for listw
-subset(x, subset, zero.policy = NULL, ...)
logical expression
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
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.
an object of class nb
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
passed through to stem()
for control of plot length
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