deseg: Decomposable Segregation Measure

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

View source: R/deseg.R

Description

Calculates the decomposable segregation measure developed by Sadahiro and Hong (2013).

Usage

1
2
deseg(x, data, smoothing = "kernel", nrow = 100, ncol = 100, 
      window, sigma, verbose = FALSE)

Arguments

x

a numeric matrix or data frame with coordinates (each row is a point), or an object of class Spatial or ppp.

data

an object of class matrix, or one that can be coerced to that class. The number of rows in ‘data’ should equal the number of points in ‘x’, and the number of columns should be greater than one (i.e., at least two population groups are required). This can be missing if ‘x’ has a data frame attached to it.

smoothing

a character string indicating how to perform spatial smoothing of the population data. Currently only “kernel” is supported.

nrow

a numeric value indicating the number of row cells in the rasterised data surface.

ncol

a numeric value indicating the number of column cells.

window

an optional object of class matrix to be passed to kernel2d. See ‘Details’.

sigma

an optional numeric value specifying the kernel bandwidth to be passed to kernel2d. See also ‘Details’.

verbose

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

Details

The decomposable segregation measure is a surface-based, non-spatial method. The index calculation does not take into account the spatial arrangement of the population. It is the spatial smoothing process that deals with the spatial aspect of segregation. If the spatial smoothing is not performed properly, this measure may suffer from the same checkerboard problem as the traditional index of dissimilarity.

Currently deseg uses the function kernel2d in splancs, which employs a quartic kernel estimator. The points outside ‘window’ are not considered when computing the kernel estimates. The argument ‘window’ must be a polygon represented in a matrix form such that each row corresponds to a vertex. This is passed to kernel2d as ‘poly’. If ‘window’ is missing, a square that covers all points in ‘x’ will be used.

If ‘sigma’ is not given, bw.nrd in stats is used to find the optimal bandwidth.

Value

An object of SegDecomp-class.

Author(s)

Seong-Yun Hong

References

Sadahiro, Y. and Hong, S.-Y. (2013) Decomposition approach to the measurement of spatial segregation. CSIS Discussion Paper Series, 119, 1-33.

See Also

SegDecomp-class, kernel2d

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 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)

# displays the test data
plot(grd.sp)
plot(grd.sp[segdata[,9] == 100,], col = "Black", add = TRUE)
plot(grd.sp[segdata[,9] == 50,], col = "Grey", add = TRUE)

# tries different bandwidths for the same data
bw1 <- deseg(grd.sp, segdata[,9:10], sigma = 1, nrow = 20, ncol = 20)
print(bw1, digits = 3)
bw1.val <- sum(as.vector(bw1))
spplot(bw1, col.regions=rev(heat.colors(20)), 
       main = paste("Bandwidth = 1, S =", round(bw1.val, 2)))

bw2 <- deseg(grd.sp, segdata[,9:10], sigma = 2, nrow = 20, ncol = 20)
print(bw2, digits = 3)
bw2.val <- sum(as(bw2, "vector"))
spplot(bw2, col.regions=rev(heat.colors(20)), 
       main = paste("Bandwidth = 2, S =", round(bw2.val, 2)))

## Not run: 
# let's see how the index value changes with different bandwidths
h0 <- seq(1, 5, length.out = 10); vals <- numeric()
for (i in 1:10) {
  d <- deseg(grd.sp, segdata[,9:10], sigma = h0[i], verbose = TRUE)
  vals <- append(vals, sum(as(d, "vector")))
}
plot(h0, vals, type = "b", xlab = "Bandwidth", ylab = "S")
title(main = "segdata[,9:10]")

# calculates the index for all data sets in 'segdata'
d.segdata <- matrix(NA, nrow = 3, ncol = 8)
for (i in 1:8) {
  idx <- 2 * i
  tmp <- deseg(grd.sp, segdata[,(idx-1):idx])
  d.segdata[,i] <- as(tmp, "vector")
}

# presents the results as a bar chart
barplot(d.segdata, names.arg = LETTERS[1:8], main = "segdata",
        legend.text = c(expression(italic(paste("S"[L]))), 
                        expression(italic(paste("S"[C]))),
                        expression(italic(paste("S"[Q])))),
        args.legend = list(x = "topright", horiz = TRUE))
## End(Not run)

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

Related to deseg in seg...