dissim: Index of Dissimilarity

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/dissim.R

Description

Calculates the index of dissimilarity proposed by Duncan and Duncan (1955). If ‘x’ or ‘nb’ is given, the index is adjusted to reflect the spatial distribution of population.

Usage

1
2
3
dissim(x, data, nb, adjust = FALSE, p2n.args, n2m.args, 
       wVECT.args, v2n.args, verbose = FALSE)
seg(data, nb)

Arguments

x

an optional object of class SpatialPolygons or SpatialPolygonsDataFrame.

data

a numeric matrix or data frame with two columns that represent mutually exclusive population groups (e.g., Asians and non-Asians). If more than two columns are given, only the first two will be used for computing the index.

nb

an optional matrix object describing the intensity of interaction between geographic units.

adjust

logical. If TRUE, and if ‘x’ is given, the index of dissimilarity is adjusted according to the suggestions of Morrill (1991) and Wong (1993), depending on packages installed on the system. See ‘Details’ for more information. Ignore if ‘x’ is not given.

p2n.args

an optional list of arguments to be passed to poly2nb. To avoid confusion, it is best to name all objects in the list in a way that they exactly match the argument names in poly2nb.

n2m.args

an optional list of arguments to be passed to nb2mat.

wVECT.args

an optional list of arguments to be passed to writeVECT6.

v2n.args

an optional list of arguments to be passed to vect2neigh.

verbose

logical. If TRUE, print the current stage of the computation and time spent on each job to the screen.

Details

dissim calculates the index of dissimilarity for ‘data’. If ‘data’ is missing, it attempts to extract the data from ‘x’. If ‘x’ is not given, or if it is not a valid SpatialPolygonsDataFrame object, the function stops with an error.

When ‘x’ is given and ‘adjust’ is set to TRUE, the index is adjusted according to the suggestions of Morrill (1991) and Wong (1993). However, this automatic adjustment requires a number of packages to be installed on the user's system: spdep for Morrill's D(adj) and spgrass6 and rgdal for Morrill's D(w) and D(s). Note that, for D(w) and D(s), GRASS commands should be accessible from within R.

Alternatively, the index value can be adjusted using a user-specified weighting matrix ‘nb’. ‘nb’ must be a square matrix (i.e., one that has the same number of rows and columns) but does not have to be symmetric. If ‘nb’ is not specified, the function calculates the traditional index of dissimilarity proposed by Duncan and Duncan (1955).

If ‘nb’ is a rook-based contiguity matrix standardised by the total number of neighbours, the index is adjusted as described in Morrill (1991). See the example code below and nb2mat in spdep for more information regarding how to construct such a matrix. For Wong's D(w) and D(s), see https://sites.google.com/site/hongseongyun/seg. Note that the sum of all elements in ‘nb’ should equal one.

seg is a simplified version of dissim and will be deprecated later.

Value

dissim returns a list containing the following elements:

d

index of dissimilarity.

dm

index of dissimilarity adjusted according to Morrill (1991). NA if not calculated.

dw

index of dissimilarity adjusted according to Wong (1991). NA if not calculated.

ds

index of dissimilarity adjusted according to Wong (1991). NA if not calculated.

user

index of dissimilarity adjusted using the user-specified weighting matrix ‘nb’. NA if ‘nb’ is missing.

seg returns a single numeric value between 0 and 1, indicating the degree of segregation; 0 for no segregation, and 1 for complete segregation.

Author(s)

Seong-Yun Hong

References

Duncan, O. D., & Duncan, B. (1955). A methodological analysis of segregation indexes. American Sociological Review, 20, 210-217.

Morrill, R. L. (1991). On the measure of geographic segregation. Geography Research Forum, 11, 25-36.

Wong, D. W. S. (1993). Spatial indices of segregation. Urban Studies, 30, 559-572.

See Also

spseg, nb2mat

Examples

 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
if (require(spdep)) { # package 'spdep' is required

  # uses the idealised landscapes in 'segdata'
  data(segdata)
  grd <- GridTopology(cellcentre.offset=c(0.5,0.5),
                      cellsize=c(1,1), cells.dim=c(10,10))
  grd.sp <- as.SpatialPolygons.GridTopology(grd)
  grd.nb <- nb2mat(poly2nb(grd.sp, queen = FALSE), style = "B")
  grd.nb <- grd.nb / sum(grd.nb)

  d <- rep(NA, 8); m <- rep(NA, 8)
  for (i in 1:8) {
    idx <- 2 * i
    d[i] <- seg(segdata[,(idx-1):idx])
    m[i] <- seg(segdata[,(idx-1):idx], grd.nb)
    full <- segdata[,(idx-1)] == 100
    half <- segdata[,(idx-1)] == 50
    plot(grd.sp)
    plot(grd.sp[full,], col = "Black", add = TRUE)
    if (any(half))
      plot(grd.sp[half,], col = "Grey", add = TRUE)
    text(5, 11.5, labels = paste("D = ", round(d[i], 2), 
                                 ", D(adj) = ", round(m[i], 2), sep = ""))
  }
}

Example output

Loading required package: sp
Loading required package: spdep
Loading required package: Matrix
Failed with error:  'package 'spData' 0.2.5.0 was found, but >= 0.2.6.0 is required by 'spdep''
In addition: Warning message:
version 0.3.0 of 'spData' masked by 0.2.5.0 in /usr/local/lib/R/site-library 

seg documentation built on Dec. 19, 2019, 1:09 a.m.

Related to dissim in seg...