Package {seg}


Version: 0.6-0
Date: 2026-11-08
Title: Measuring Spatial Segregation
Depends: R (≥ 4.1.0)
Imports: sf (≥ 1.0-24), splancs, graphics, grDevices, stats
Description: Measuring spatial segregation. The methods implemented in this package include White's P index (1983) <doi:10.1086/227768>, Morrill's D(adj) (1991), Wong's D(w) and D(s) (1993) <doi:10.1080/00420989320080551>, and Reardon and O'Sullivan's set of spatial segregation measures (2004) <doi:10.1111/j.0081-1750.2004.00150.x>, with maps of where segregation is strong or weak. Spatial data are handled with 'sf'.
License: GPL (≥ 3)
URL: https://github.com/syunhong/seg
BugReports: https://github.com/syunhong/seg/issues
Encoding: UTF-8
NeedsCompilation: yes
Packaged: 2026-11-10 11:10:21 UTC; syhong
Author: Seong-Yun Hong [aut, cre], David O'Sullivan [aut], Benjamin Jarvis [ctb] (scaled kernels in localenv()), Changlock Choi [ctb]
Maintainer: Seong-Yun Hong <syhong@khu.ac.kr>
Repository: CRAN
Date/Publication: 2026-12-01 15:10:02 UTC

Measuring Spatial Segregation

Description

Functions for measuring spatial segregation: the index of dissimilarity and its spatial adjustments (Morrill 1991; Wong 1993), White's spatial proximity index (isp), Reardon and O'Sullivan's (2004) set of spatial segregation measures (spseg), and a decomposable segregation measure (deseg). The local values behind Reardon and O'Sullivan's measures can be mapped with plot.SegSpatial.

Details

Since version 0.6-0, spatial data are handled with sf. Polygon or point data can be given as sf or sfc objects, or as a two-column matrix of coordinates. The packages sp, spdep, spgrass6 and rgdal are no longer used, and GRASS is not needed for Wong's D(w) and D(s). Objects returned by the package are S3 objects whose components are extracted with $. See news(package = "seg") for other changes.

Author(s)

Seong-Yun Hong and David O'Sullivan. Maintainer: Seong-Yun Hong <syhong@khu.ac.kr>

References

Hong, S.-Y., O'Sullivan, D. and Sadahiro, Y. (2014) Implementing spatial segregation measures in R. PLoS ONE, 9(11), e113767.


Decomposable Segregation Measure: Results

Description

The class of objects returned by deseg, and its methods.

Usage

SegDecomp(d, coords, data, crs = NA)

## S3 method for class 'SegDecomp'
print(x, digits = getOption("digits"), ...)
## S3 method for class 'SegDecomp'
as.vector(x, mode = "any")
## S3 method for class 'SegDecomp'
st_as_sf(x, ...)

Arguments

d

a numeric vector of length three: the location, composition and qualitative components.

coords, data, crs

see SegLocal.

x

an object of class SegDecomp.

digits

the number of digits to print.

mode

passed to as.vector.

...

ignored.

Details

A SegDecomp object is a list with the components d, coords, data and crs, where coords and data describe the smoothed population surface.

Value

SegDecomp returns an object of class SegDecomp, as.vector the three components, and st_as_sf an sf object of the surface points.

Note

Up to version 0.5-7, SegDecomp was an S4 class. Use $ instead of @ to extract components.

Author(s)

Seong-Yun Hong

See Also

deseg

Examples

data(segdata)
xy <- expand.grid(x = 1:10 - 0.5, y = 10:1 - 0.5)
d <- deseg(xy, segdata[, 1:2], nrow = 30, ncol = 30)
d
as.vector(d)

Local Environments

Description

The class of objects returned by localenv, and its methods.

Usage

SegLocal(coords, data, env, crs = NA)

## S3 method for class 'SegLocal'
print(x, ...)
## S3 method for class 'SegLocal'
summary(object, ...)
## S3 method for class 'SegLocal'
update(object, coords, data, env, crs, ...)
## S3 method for class 'SegLocal'
plot(x, which.col, main, ...)
## S3 method for class 'SegLocal'
points(x, which.col = 1, ...)
## S3 method for class 'SegLocal'
st_as_sf(x, ...)

Arguments

coords

a numeric matrix with two columns, x and y.

data

a numeric matrix with at least two columns, giving the population of each group at each point.

env

a numeric matrix with the same dimensions as ‘data’, giving the population composition of the local environment of each point. If missing, ‘data’ is used.

crs

a coordinate reference system, as accepted by sf::st_crs.

x, object

an object of class SegLocal.

which.col

the column(s) of env to plot.

main

plot title(s).

...

further arguments passed to plot and points (for plot and points) or to summary (for summary). Ignored otherwise.

Details

A SegLocal object is a list with the components coords, data, env and crs. plot and points draw the points with symbol sizes proportional to the quintile of the local environment values. st_as_sf converts the object to sf points with the columns of env as attributes.

Value

SegLocal and update return an object of class SegLocal. st_as_sf returns an sf object.

Note

Up to version 0.5-7, SegLocal was an S4 class whose slots were accessed with @, and the projection was stored as an sp CRS object in the slot proj4string. Use $ instead (e.g., x$env); the projection is now an sf crs object in x$crs.

Author(s)

Seong-Yun Hong

See Also

localenv, spatseg

Examples

data(segdata)
xy <- expand.grid(x = 1:10 - 0.5, y = 10:1 - 0.5)
env <- localenv(xy, segdata[, 1:2])
env
summary(env)
plot(env, which.col = 1)

# a SegLocal object built by hand, then the segregation measures
v <- SegLocal(xy, segdata[, 1:2], env$env)
spatseg(v)

Spatial Segregation Measures: Results and Maps

Description

The class of objects returned by spseg and spatseg, and its methods. plot maps where segregation is strong or weak.

Usage

SegSpatial(d, r, h, p, coords, data, env, crs = NA)

## S3 method for class 'SegSpatial'
print(x, digits = getOption("digits"), ...)
## S3 method for class 'SegSpatial'
as.list(x, ...)
## S3 method for class 'SegSpatial'
plot(x, index = c("dissimilarity", "diversity",
     "information"), ...)
## S3 method for class 'SegSpatial'
st_as_sf(x, ...)

Arguments

d, r, h

numeric values of the dissimilarity, relative diversity and information theory indices (numeric(0) or NULL if not computed).

p

the exposure/isolation matrix (a 0 by 0 matrix or NULL if not computed).

coords, data, env, crs

see SegLocal.

x

an object of class SegSpatial.

digits

the number of digits to print.

index

the local index to map: “dissimilarity” (default), “diversity” or “information”.

...

for plot, arguments passed to plot.sf, such as ‘main’, ‘xlab’, ‘ylab’, ‘axes’, ‘breaks’, ‘nbreaks’, ‘pal’, ‘border’, ‘key.pos’ and ‘reset’. Ignored by the other methods.

Details

A SegSpatial object is a list that extends SegLocal with the components d, r, h and p (the global indices) and local, a matrix with the local values d, r and h for each data point (see spseg). When created by spseg from an sf object, it also holds the input geometry (geometry) and, for each data point, the index of the geometry it belongs to (id).

plot draws a map of the local values. If the input was polygons, the map uses the original polygons: without smoothing, each polygon shows its own local value; with smoothing, it shows the population-weighted mean of the local values of the grid points inside it, so that the population-weighted mean over all polygons still equals the global index. Polygons without grid points are left blank. Otherwise, the data points are drawn. The default title is “Local segregation (D)” (or R, H), and the default palette runs from light yellow (weak) to dark red (strong). Room for ‘xlab’ and ‘ylab’ is made automatically.

st_as_sf returns the data being mapped as an sf object with columns d, r and h, for use with other mapping tools.

Value

SegSpatial returns an object of class c("SegSpatial", "SegLocal"). as.list returns a list with the elements d, r, h and p. plot invisibly returns the sf object that was mapped.

Note

Up to version 0.5-7, SegSpatial was an S4 class whose slots were accessed with @. Use $ instead (e.g., x$d). The spplot methods have been replaced by plot and st_as_sf.

Author(s)

Seong-Yun Hong

See Also

spseg, SegLocal

Examples

library(sf)
data(segdata)
grd <- st_make_grid(st_bbox(c(xmin = 0, ymin = 0, xmax = 10, ymax = 10)),
                    n = 10)
grd <- grd[as.vector(matrix(1:100, 10)[, 10:1])]
a <- spseg(st_sf(segdata[, 3:4], geometry = grd))

a$d
head(a$local)

# the population-weighted mean of the local values is the global index
w <- rowSums(a$data) / sum(a$data)
c(sum(w * a$local[, "d"]), a$d)

plot(a, main = "Pattern B", breaks = seq(0, 1, 0.1))
plot(a, index = "diversity", xlab = "x", ylab = "y", axes = TRUE)

st_as_sf(a)

Concentration Profile

Description

Draws the concentration profile of a population group and computes the summary index proposed by Hong and Sadahiro (2014).

Usage

conprof(data, grpID = 1, n = 999, graph = TRUE, add = FALSE, ...)

Arguments

data

a numeric matrix or data frame with at least two columns, one for each population group, and one row for each geographic unit.

grpID

the column of the group to analyse.

n

the number of threshold values at which the profile is evaluated.

graph

logical. If TRUE, draw the profile.

add

logical. If TRUE, add the profile to the current plot.

...

further graphical arguments passed to plot, axis and lines.

Details

For each threshold t between 0 and 1, the profile gives the proportion of the group that lives in units where the group's share of the population is at least t. The summary index measures the area between the profile and the profile expected without segregation, scaled to lie between 0 and 1.

Value

A list with the threshold values x, the profile y and the summary index d.

Author(s)

Seong-Yun Hong

References

Poulsen, M., Johnston, R. and Forrest, J. (2002) Plural cities and ethnic enclaves: Introducing a measurement procedure for comparative study. International Journal of Urban and Regional Research, 26, 229-243.

Hong, S.-Y. and Sadahiro, Y. (2014) Measuring geographic segregation: a graph-based approach. Journal of Geographical Systems, 16, 211-231.

See Also

dissim

Examples

data(segdata)
a <- conprof(segdata[, 1:2], main = "Concentration profiles")
b <- conprof(segdata[, 7:8], add = TRUE, lty = 2)
c(a$d, b$d)

Decomposable Segregation Measure

Description

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

Usage

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), an sf or sfc object with point or polygon geometries, or an object of class ppp. For polygons, the centroids are used.

data

a numeric matrix or data frame with at least two columns, one for each population group. This can be missing if ‘x’ has the data attached.

smoothing

a character string indicating how to construct the population surface. Currently only “kernel” is available.

nrow

the number of rows of the grid used for the population surface.

ncol

the number of columns of the grid.

window

an optional polygon, given as a two-column matrix of vertices or as an sf/sfc polygon. See ‘Details’.

sigma

an optional kernel bandwidth. See ‘Details’.

verbose

logical. If TRUE, report the progress of the computation.

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 that deals with the spatial aspect of segregation. If the smoothing is not done properly, the measure may suffer from the same checkerboard problem as the traditional index of dissimilarity.

deseg uses kernel2d in splancs, a quartic kernel estimator with edge correction. Each person is treated as a point, so the population counts should be integers; non-integer counts are truncated, with a warning. Grid points outside ‘window’ are not used. If ‘window’ is missing, the rectangle that covers all points in ‘x’ is used. If ‘sigma’ is missing, the smaller of bw.nrd of the x and y coordinates is used.

Value

An object of class SegDecomp.

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

Examples

data(segdata)
xy <- expand.grid(x = 1:10 - 0.5, y = 10:1 - 0.5)

d <- sapply(1:8, function(i)
  as.vector(deseg(xy, segdata[, (2 * i - 1):(2 * i)], nrow = 30, ncol = 30)))
dimnames(d) <- list(c("Location", "Composition", "Qualitative"),
                    LETTERS[1:8])
round(d, 3)

Index of Dissimilarity

Description

Calculates the index of dissimilarity proposed by Duncan and Duncan (1955). If polygons are given in ‘x’, the index can be adjusted for the spatial arrangement of the population as suggested by Morrill (1991) and Wong (1993). The index can also be adjusted with a user-specified weighting matrix ‘nb’.

Usage

dissim(x, data, nb, adjust = FALSE, verbose = FALSE)
seg(data, nb)

Arguments

x

an optional sf or sfc object with polygon geometries.

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 are used. This can be missing if ‘x’ is an sf object with the data attached.

nb

an optional square matrix describing the intensity of interaction between geographic units. The sum of all elements should be one.

adjust

logical. If TRUE and ‘x’ is given, the index is adjusted according to Morrill (1991) and Wong (1993). See ‘Details’.

verbose

logical. If TRUE, report the progress of the computation.

Details

When ‘x’ is given and ‘adjust’ is TRUE, the boundaries shared by neighbouring polygons are found with sf, and three adjusted indices are computed. Each adjusted index takes the form

D - \sum_i \sum_j w_{ij} |z_i - z_j|,

where z_i is the proportion of group 1 in unit i and the sums run over all ordered pairs of units.

Morrill's D(adj)

w_{ij} is one for pairs of units that share a boundary (rook contiguity) and zero otherwise, divided by the sum over all pairs.

Wong's D(w)

w_{ij} is the length of the boundary shared by units i and j, divided by the sum over all pairs.

Wong's D(s)

the weights of D(w) are multiplied by ((P_i/A_i) + (P_j/A_j)) / 2 divided by the maximum of P/A, where A is the area of a unit and P its perimeter.

Note that the perimeter P used for D(s) is the length of the boundary that a unit shares with other units in the study area, not its total perimeter: boundary segments on the edge of the study area are excluded. This follows Wong (1993) and is needed to reproduce the values reported there. Earlier versions of seg computed the same quantity with GRASS.

Areas and lengths are computed by sf, so they are in metres for geographic coordinates. Units with no population are removed from the adjustment, with a warning.

If ‘nb’ is given, the index is adjusted with ‘nb’ as the weights w_{ij}. ‘nb’ does not have to be symmetric.

seg is deprecated; use dissim instead.

Value

dissim returns a list with 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 (1993) using shared boundary lengths. NA if not calculated.

ds

index of dissimilarity adjusted according to Wong (1993) using shared boundary lengths and perimeter/area ratios. NA if not calculated.

user

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

Note

Before version 0.6-0, adjust = TRUE relied on spdep, spgrass6, rgdal and a GRASS installation, and the arguments p2n.args, n2m.args, wVECT.args and v2n.args were passed to those packages. These arguments have been removed.

Author(s)

Seong-Yun Hong

References

Duncan, O. D. and 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, isp

Examples

library(sf)
data(segdata)
grd <- st_make_grid(st_bbox(c(xmin = 0, ymin = 0, xmax = 10, ymax = 10)),
                    n = 10)
grd <- grd[as.vector(matrix(1:100, 10)[, 10:1])]

# D, D(adj), D(w) and D(s) for the eight patterns
out <- sapply(1:8, function(i) {
  unlist(dissim(grd, segdata[, (2 * i - 1):(2 * i)], adjust = TRUE)[1:4])
})
colnames(out) <- LETTERS[1:8]
round(out, 3)

# a user-specified weighting matrix (here, rook contiguity)
rook <- st_relate(grd, pattern = "F***1****", sparse = FALSE) * 1
dissim(data = segdata[, 1:2], nb = rook / sum(rook))$user

White's Spatial Proximity Index

Description

Calculates the index of spatial proximity proposed by White (1983).

Usage

isp(x, data, nb, fun, verbose = FALSE, ...)
whiteseg(x, data, nb, fun, verbose = FALSE, ...)

Arguments

x

a numeric matrix or data frame with coordinates (each row is a point), an sf or sfc object with point or polygon geometries, or an object of class ppp. For polygons, the centroids are used.

data

a numeric matrix or data frame with at least two columns, one for each population group. The number of rows must equal the number of points in ‘x’. This can be missing if ‘x’ is an sf or ppp object with the data attached.

nb

an optional matrix of distances between the points. If missing, Euclidean distances between the coordinates are used.

fun

an optional function of distance that gives the degree of spatial interaction. The default is function(z) exp(-z).

verbose

logical. Currently unused; kept for compatibility.

...

optional arguments passed to dist when ‘nb’ is missing.

Details

Pairs of points with a distance of zero, including each point paired with itself, are excluded. whiteseg is deprecated; use isp instead.

Value

A single numeric value. A value of one indicates no spatial clustering of the groups; values greater than one indicate that members of each group live closer to one another than to members of the other groups.

Author(s)

Seong-Yun Hong

References

White, M. J. (1983) The measurement of spatial segregation. American Journal of Sociology, 88, 1008-1018.

See Also

dissim, spseg

Examples

library(sf)
data(segdata)
grd <- st_make_grid(st_bbox(c(xmin = 0, ymin = 0, xmax = 10, ymax = 10)),
                    n = 10)
grd <- grd[as.vector(matrix(1:100, 10)[, 10:1])]

isp(grd, segdata[, 1:2])
isp(grd, segdata[, 5:6])

# a different distance-decay function
isp(grd, segdata[, 1:2], fun = function(z) 1 / (1 + z^2))

Population Composition of the Local Environment

Description

Computes the population composition of the local environment of each data point, as a distance-weighted average of the population at all points. The result is used by spatseg and spseg.

Usage

localenv(x, data, power = 2, useExp = TRUE, scale = FALSE, maxdist, sprel,
         tol = .Machine$double.eps)

Arguments

x

a numeric matrix or data frame with coordinates (each row is a point), an sf or sfc object with point or polygon geometries, or an object of class ppp. For polygons, the centroids (of the largest part) are used.

data

a numeric matrix or data frame with at least two columns, one for each population group. This can be missing if ‘x’ has the data attached.

power

a numeric value that determines how quickly the weight declines with distance. See ‘Details’.

useExp

logical. If TRUE (default), a negative exponential function of distance is used; otherwise an inverse distance function.

scale

logical. If TRUE, the weights are scaled by ‘maxdist’. See ‘Details’.

maxdist

an optional numeric value giving the maximum search radius. Points further away get a weight of zero. Required if ‘scale’ is TRUE.

sprel

an optional object of class dist or nb describing the spatial relationships between the points. See ‘Details’.

tol

a small positive value added to distances in the inverse distance function to avoid division by zero.

Details

For points i and j at distance d, the weight is \exp(-p d) if ‘useExp’ is TRUE and 1/(d + tol)^p otherwise, where p is ‘power’. The coordinates are treated as planar, so data with geographic coordinates should be projected first (e.g., with sf::st_transform). Note that the appropriate value of ‘power’ depends on the units of the coordinates.

If ‘scale’ is TRUE, the weight is (1 - (d/r)^p)^p (a biweight kernel) when ‘useExp’ is FALSE, and (\exp(-p d/r) - \exp(-p)) / (1 - \exp(-p)) (a scaled and normalised exponential decay) when ‘useExp’ is TRUE, where r is ‘maxdist’.

If ‘sprel’ is a dist object, its distances are used in place of the Euclidean distances between the coordinates (‘scale’ is ignored). If it is an nb object (e.g., from spdep::poly2nb), the local environment of a unit is the average population of its neighbours, i.e., row-standardised weights. Every unit must have at least one neighbour.

Value

An object of class SegLocal.

Author(s)

Seong-Yun Hong; the scaled kernels were contributed by Benjamin Jarvis.

References

Reardon, S. F. and O'Sullivan, D. (2004) Measures of spatial segregation. Sociological Methodology, 34, 121-162.

See Also

SegLocal, spseg

Examples

library(sf)
data(segdata)
grd <- st_make_grid(st_bbox(c(xmin = 0, ymin = 0, xmax = 10, ymax = 10)),
                    n = 10)
grd <- grd[as.vector(matrix(1:100, 10)[, 10:1])]

# negative exponential function of distance
env1 <- localenv(grd, segdata[, 1:2])
env1

# inverse distance, and equal weights (power = 0)
env2 <- localenv(grd, segdata[, 1:2], useExp = FALSE)
env3 <- localenv(grd, segdata[, 1:2], useExp = FALSE, power = 0)

# map the composition of the local environments
plot(st_sf(prop = env1$env[, 1] / rowSums(env1$env), geometry = grd),
     main = "Group 1 share of the local environment")

Hypothetical Patterns of Segregation

Description

This data set contains eight different spatial configurations that were used by Morrill (1991) and Wong (1993) to test their segregation measures.

Usage

data(segdata)

Format

A data frame with 100 rows and 16 columns, representing eight idealised spatial patterns on a 10 by 10 grid. The rows are the grid cells, ordered from the top-left cell row by row. Columns A1 and A2 are the populations of group 1 and group 2 in pattern A, B1 and B2 those in pattern B, and so on up to H1 and H2.

Source

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.

Examples

library(sf)
data(segdata)

# a 10 x 10 grid in the same order as the rows of 'segdata'
grd <- st_make_grid(st_bbox(c(xmin = 0, ymin = 0, xmax = 10, ymax = 10)),
                    n = 10)
grd <- grd[as.vector(matrix(1:100, 10)[, 10:1])]

op <- par(mfrow = c(2, 4), mar = c(0, 1, 1.5, 1))
for (i in 1:8) {
  share <- segdata[, 2 * i - 1] / 100
  plot(grd, col = grey(1 - share), main = paste("Pattern", LETTERS[i]))
}
par(op)

Spatial Segregation Measures

Description

Calculates the set of spatial segregation measures developed by Reardon and O'Sullivan (2004), together with the local values that show where segregation is strong or weak.

Usage

spseg(x, data, method = "all", smoothing = "none", nrow = 100, ncol = 100,
      window, sigma, useC = TRUE, negative.rm = FALSE,
      tol = .Machine$double.eps, verbose = FALSE, ...)
spatseg(env, method = "all", useC = TRUE, negative.rm = FALSE,
        tol = .Machine$double.eps)

Arguments

x

a numeric matrix or data frame with coordinates (each row is a point), an sf or sfc object with point or polygon geometries, or an object of class ppp. For polygons, the centroids (of the largest part) are used as data points.

env

an object of class SegLocal.

data

a numeric matrix or data frame with at least two columns, one for each population group. The number of rows must equal the number of points or polygons in ‘x’. This can be missing if ‘x’ is an sf or ppp object with the data attached.

method

a vector of character strings indicating the measures to be computed: one or more of “all” (default), “exposure”, “information”, “diversity” and “dissimilarity”. Abbreviations are accepted.

smoothing

a character string indicating how to construct the population surface: “none” (default), “kernel” or “equal”. See ‘Details’.

nrow

the number of rows of the grid used for the population surface. Ignored if ‘smoothing’ is “none”.

ncol

the number of columns of the grid.

window

an optional polygon, given as a two-column matrix of vertices or as an sf/sfc polygon, within which the kernel surface is estimated. See deseg.

sigma

an optional kernel bandwidth. See deseg.

useC

logical. If TRUE, the global indices are calculated in C.

negative.rm

logical. If TRUE, data points where at least one group has a population of zero or less are removed, to prevent -Inf or NaN in the information theory index. If FALSE, such values are replaced with ‘tol’.

tol

a small positive value. See ‘Details’.

verbose

logical. If TRUE, report the progress of the computation.

...

optional arguments passed to localenv, such as ‘power’, ‘useExp’ and ‘maxdist’.

Details

spatseg computes the measures from the local environments in a SegLocal object. spseg is a wrapper that first constructs the population surface and its local environments.

With smoothing = "none", the data points are the input points or polygon centroids. With "equal", the population of each polygon is spread evenly over the points of an ‘nrow’ by ‘ncol’ grid that fall inside it; polygons that contain no grid point are dropped with a warning, so ‘nrow’ and ‘ncol’ should be large enough for the smallest polygon. With "kernel", a quartic kernel surface is estimated with splancs::kernel2d (see deseg).

tol is added to all population values, so that v * log(v) is computed as (v + tol) * log(v + tol) and does not become NaN when v = 0.

Each of the dissimilarity (D), relative diversity (R) and information theory (H) indices is a population-weighted average of local values,

D = \sum_p \frac{t_p}{T} d_p, \quad d_p = \frac{\sum_m |\tilde\pi_{pm} - \pi_m|}{2I},

R = \sum_p \frac{t_p}{T} r_p, \quad r_p = 1 - \frac{\tilde I_p}{I},

H = \sum_p \frac{t_p}{T} h_p, \quad h_p = 1 - \frac{\tilde E_p}{E},

where t_p is the population at point p, T the total population, \pi_m the overall proportion of group m, \tilde\pi_{pm} its proportion in the local environment of p, and I, \tilde I_p, E and \tilde E_p the interaction (Simpson) and entropy indices of the region and of the local environment of p. The local values are returned in the component local and mapped by plot.SegSpatial. Larger values indicate places that contribute more to segregation. r_p and h_p are negative where the local environment is more diverse than the region as a whole.

Value

An object of class SegSpatial.

Note

The exposure/isolation index, P, is a matrix. The spatial exposure of group ‘m’ to group ‘n’ is in row ‘m’ and column ‘n’. The matrix is rarely symmetric, so it should be interpreted with care. The diagonal cells are the spatial isolation indices.

Author(s)

Seong-Yun Hong

References

Reardon, S. F. and O'Sullivan, D. (2004) Measures of spatial segregation. Sociological Methodology, 34, 121-162.

Reardon, S. F., Farrell, C. R., Matthews, S. A., O'Sullivan, D., Bischoff, K. and Firebaugh, G. (2009) Race and space in the 1990s: Changes in the geographic scale of racial residential segregation, 1990-2000. Social Science Research, 38, 55-70.

See Also

SegSpatial, plot.SegSpatial, localenv, deseg

Examples

library(sf)
data(segdata)
grd <- st_make_grid(st_bbox(c(xmin = 0, ymin = 0, xmax = 10, ymax = 10)),
                    n = 10)
grd <- grd[as.vector(matrix(1:100, 10)[, 10:1])]
x <- st_sf(segdata[, 1:2], geometry = grd)

# no spatial smoothing
a <- spseg(x)
print(a, digits = 3)
plot(a)
plot(a, index = "information", main = "Local H",
     xlab = "Easting", ylab = "Northing", axes = TRUE)

# population spread evenly within each polygon
b <- spseg(x, smoothing = "equal", nrow = 50, ncol = 50)
print(b, digits = 3)

# kernel smoothing within a boundary polygon
w <- matrix(c(1.5, 1.5, 1.5, 8.5, 8.5, 8.5, 8.5, 4.5, 5.5, 4.5, 5.5, 1.5),
            ncol = 2, byrow = TRUE)
k <- spseg(x, smoothing = "kernel", window = w, nrow = 20, ncol = 20)
print(k, digits = 3)

# the index values as a list
as.list(k)