Learn R Programming

seg (version 0.2-2)

seg: Calculate Index of Dissimilarity

Description

seg calculates Duncan and Duncan's index of dissimilarity between two population groups. If nb is given, the index can be adjusted to reflect the spatial distribution of population.

Usage

seg(data, nb, verbose = FALSE)

Arguments

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.
verbose
logical. If TRUE, print the current stage of the computation and time spent on each job to the screen.

Value

  • A single numeric value between 0 and 1, indicating the degree of segregation; 0 for no segregation, and 1 for complete segregation.

Details

nb must be a square matrix (same number of rows and columns) but does not have to be symmetric. When nb is not specified, seg 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 calculation follows the Morrill's adjusted index of dissimilarity (1991). See the example code below and help(nb2mat) for more information regarding how to construct such a matrix.

If nb contains row-standardised shared boundary lengths between geographic units, the computed index is Wong's adjusted D. In R, vect2neigh in the spgrass6 package can be used to obtain the shared boundary lengths.

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, whiteseg

Examples

Run this code
if (require(spdep)) {
  data(segdata)
  segdata.df <- data.frame(segdata)
  segdata.nb <- nb2mat(poly2nb(segdata, queen = FALSE), style = "B")
  segdata.nb <- segdata.nb / sum(segdata.nb)
  dd <- numeric(); dm <- numeric()
  par(mfrow = c(2, 4), mar = c(0, 1, 0, 1))
  for (i in 1:8) {
    idx <- 2 * i
    dd <- append(dd, seg(segdata.df[,(idx-1):idx]))
    dm <- append(dm, seg(segdata.df[,(idx-1):idx], segdata.nb))
    full <- segdata.df[,(idx-1)] == 100
    half <- segdata.df[,(idx-1)] == 50
    plot(segdata)
    plot(segdata[full,], col = "Black", add = TRUE)
    if (any(half))
      plot(segdata[half,], col = "Grey", add = TRUE)
    text(5, 11.5, labels = paste("D = ", round(dd[i], 2), 
                                 ", D(adj) = ", round(dm[i], 2), sep = ""))
  }
  
  data(nzcity)
  dd2 <- numeric(); dm2 <- numeric()
  for (i in 1:16) {
    city.df <- data.frame(nzcity[[i]])
    city.df <- cbind(city.df[,4], apply(city.df[,c(2:3, 5:7)], 1, sum))
    city.nb <- nb2mat(poly2nb(nzcity[[i]], queen = FALSE), style = "B",
                      zero.policy = TRUE)
    city.nb <- city.nb / sum(city.nb)
    dd2 <- append(dd2, seg(city.df))
    dm2 <- append(dm2, seg(city.df, city.nb))
  }
  nzcity.lm <- lm(dm2 ~ dd2)
  summary(nzcity.lm)
  plot(dd2, dm2, xlab = "D", ylab = "D(adj)", 
       main = paste("Residential Segregation of
",
                    "Pacific Peoples in 16 New Zealand Cities", sep = ""))
  abline(a = nzcity.lm$coefficients[1], 
         b = nzcity.lm$coefficients[2], col = "Red", lty = "dotted")
  which.pos <- c(3, 2, 2, 3, 3, 3, 2, 3, 3, 4, 3, 2, 3, 3, 3, 1)
  text(dd2, dm2, pos = which.pos, labels = names(nzcity), cex = 0.8)
}

Run the code above in your browser using DataLab