Skip to content

Commit 1636f88

Browse files
authored
✨ Initial commit for branch "dev_massey_duncan" (ndi v0.1.6.9011) (#28)
* Added `massey_duncan()` function to compute the aspatial racial or ethnic Absolute Concentration (*ACO*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281) and Duncan, Cuzzort, & Duncan (1961; LC:60007089)
1 parent 7ee23cf commit 1636f88

File tree

16 files changed

+1184
-309
lines changed

16 files changed

+1184
-309
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: ndi
22
Title: Neighborhood Deprivation Indices
3-
Version: 0.1.6.9010
4-
Date: 2024-08-30
3+
Version: 0.1.6.9011
4+
Date: 2024-08-31
55
Authors@R:
66
c(person(given = "Ian D.",
77
family = "Buller",

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export(james_taeuber)
1515
export(krieger)
1616
export(lieberson)
1717
export(massey)
18+
export(massey_duncan)
1819
export(messer)
1920
export(powell_wiley)
2021
export(sudano)

NEWS.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ndi (development version)
22

3-
## ndi v0.1.6.9010
3+
## ndi v0.1.6.9011
44

55
### New Features
66

@@ -15,9 +15,10 @@
1515
* Added `denton()` function to compute the aspatial racial or ethnic Relative Clustering (*RCL*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281)
1616
* Added `duncan_duncan()` function to compute the aspatial racial or ethnic Relative Centralization (*RCE*) based on [Duncan & Duncan (1955b)](https://doi.org/10.1086/221609) and [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281)
1717
* Added `massey()` function to compute the aspatial racial or ethnic Absolute Clustering (*ACL*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281)
18+
* Added `massey_duncan()` function to compute the aspatial racial or ethnic Absolute Concentration (*ACO*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281) and Duncan, Cuzzort, & Duncan (1961; LC:60007089)
1819

1920
#### New Function Capabilities
20-
* Added `geo_large = 'place'` for census-designated places, `geo_large = 'cbsa'` for core-based statistical areas, `geo_large = 'csa'` for combined statistical areas, and `geo_large = 'metro'` for metropolitan divisions as the larger geographical unit in `atkinson()`, `bell()`, `bemanian_beyer()`, `denton()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `hoover()`, `james_taeuber()`, `lieberson()`, `sudano()`, `theil()`, and `white()`, `white_blau()` functions.
21+
* Added `geo_large = 'place'` for census-designated places, `geo_large = 'cbsa'` for core-based statistical areas, `geo_large = 'csa'` for combined statistical areas, and `geo_large = 'metro'` for metropolitan divisions as the larger geographical unit in `atkinson()`, `bell()`, `bemanian_beyer()`, `denton()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `sudano()`, `theil()`, and `white()`, `white_blau()` functions.
2122
* Added census block group computation for `anthopolos()` by specifying `geo == 'cbg'` or `geo == 'block group'`
2223
* Added `holder` argument to `atkinson()` function to toggle the computation with or without the Hölder mean. The function can now compute *A* without the Hölder mean. The default is `holder = FALSE`.
2324
* Added `crs` argument to `anthopolos()`, `bravo()`, and `white_blau()` functions to provide spatial projection of the distance-based metrics
@@ -43,7 +44,7 @@
4344
* Re-formatted code and documentation throughout for consistent readability
4445
* Renamed 'race/ethnicity' or 'racial/ethnic' to 'race or ethnicity' or 'racial or ethnic' throughout documentation to use more modern, inclusive, and appropriate language
4546
* Updated documentation about value range of *V* (White) from `{0 to 1}` to `{-Inf to Inf}`
46-
* Added examples for `atkinson()`, `duncan_cuzzort()`, `duncan_duncan()`, `gini()`, `hoover()`, `james_taeuber()`, `lieberson()`, `theil()`, and `white_blau()` functions in vignettes and README
47+
* Added examples for `atkinson()`, `duncan_cuzzort()`, `duncan_duncan()`, `gini()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `theil()`, and `white_blau()` functions in vignettes and README
4748
* Added example for `holder` argument in `atkinson()` function in README
4849
* Reordered the contents of 'ndi-package.R' thematically
4950
* Reordered the README examples alphabetically

R/globals.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ globalVariables(
271271
'crs',
272272
'RCE',
273273
'ACL',
274-
'RCL'
274+
'RCL',
275+
'ACO',
276+
'ALAND',
277+
'TotalPopE',
278+
'n_1',
279+
'n_2',
280+
't_cs'
275281
)
276282
)

R/massey_duncan.R

Lines changed: 414 additions & 0 deletions
Large diffs are not rendered by default.

R/ndi-package.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
#'
3737
#' \code{\link{james_taeuber}} Computes the aspatial Dissimilarity Index (\emph{D}) based on James & Taeuber (1985) \doi{10.2307/270845}.
3838
#'
39-
#' \code{\link{krieger}} Computes the aspatial Index of Concentration at the Extremes based on Feldman et al. (2015) \doi{10.1136/jech-2015-205728} and Krieger et al. (2016) \doi{10.2105/AJPH.2015.302955}.
40-
#'
4139
#' \code{\link{lieberson}} Computes the aspatial Isolation Index (\emph{xPx\*}) based on Lieberson (1981; ISBN-13:978-1-032-53884-6) and Bell (1954) \doi{10.2307/2574118}.
4240
#'
4341
#' \code{\link{massey}} Computes the aspatial Absolute Clustering (\emph{ACL}) based on Massey & Denton (1988) \doi{10.1093/sf/67.2.281}.
42+
#'
43+
#' \code{\link{massey_duncan}} Computes the aspatial Absolute Concentration (\emph{ACO}) based on Massey & Denton (1988) \doi{10.1093/sf/67.2.281} and Duncan, Cuzzort, & Duncan (1961; LC:60007089).
4444
#'
4545
#' \code{\link{sudano}} Computes the aspatial Location Quotient (\emph{LQ}) based on Merton (1939) \doi{10.2307/2084686} and Sudano et al. (2013) \doi{10.1016/j.healthplace.2012.09.015}.
4646
#'
@@ -58,6 +58,8 @@
5858
#'
5959
#' \code{\link{gini}} Also retrieves the aspatial Gini Index (\emph{G}) of income inequality based on Gini (1921) \doi{10.2307/2223319}.
6060
#'
61+
#' \code{\link{krieger}} Computes the aspatial Index of Concentration at the Extremes based on Feldman et al. (2015) \doi{10.1136/jech-2015-205728} and Krieger et al. (2016) \doi{10.2105/AJPH.2015.302955}.
62+
#'
6163
#' \strong{Pre-formatted U.S. Census Data}
6264
#'
6365
#' \code{\link{DCtracts2020}} A sample dataset containing information about U.S. Census American Community Survey 5-year estimate data for the District of Columbia census tracts (2020). The data are obtained from the \code{\link[tidycensus]{get_acs}} function and formatted for the \code{\link{messer}} and \code{\link{powell_wiley}} functions input.

R/utils.R

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,73 @@ rcl_fun <- function(x, crs, omit_NAs) {
397397
return(RCL)
398398
}
399399
}
400+
401+
# Internal function for Absolute Concentration
402+
## From Denton & Massey (1988) https://doi.org/10.1093/sf/67.2.281
403+
## Returns NA value if only one smaller geography in a larger geography
404+
aco_fun <- function(x, omit_NAs) {
405+
# x <- out_tmp[[12]]
406+
xx <- x[ , c('TotalPopE', 'subgroup', 'ALAND')]
407+
if (omit_NAs == TRUE) { xx <- xx[stats::complete.cases(sf::st_drop_geometry(xx)), ] }
408+
if (nrow(sf::st_drop_geometry(x)) < 2 || any(sf::st_drop_geometry(xx) < 0) || any(is.na(sf::st_drop_geometry(xx)))) {
409+
NA
410+
} else {
411+
a_i <- xx$ALAND
412+
x_i <- xx$subgroup
413+
X <- sum(x_i, na.rm = TRUE)
414+
xx_tmp <- xx %>%
415+
sf::st_drop_geometry(xx) %>%
416+
dplyr::arrange(ALAND) %>%
417+
dplyr::mutate(
418+
t_cs = cumsum(TotalPopE),
419+
n_1 = t_cs <= X,
420+
)
421+
if (!(TRUE %in% xx_tmp$n_1)) {
422+
xx_1 <- xx_tmp %>%
423+
dplyr::slice(1)
424+
} else {
425+
xx_1 <- xx_tmp %>%
426+
dplyr::filter(n_1 == TRUE)
427+
}
428+
if (nrow(xx_1) == 1 & 0 %in% xx_1$TotalPopE) {
429+
xx_1 <- xx_tmp %>%
430+
dplyr::filter(TotalPopE > 0) %>%
431+
dplyr::slice(1)
432+
}
433+
T_1 <- xx_1 %>%
434+
dplyr::summarise(
435+
T_1 = sum(TotalPopE)
436+
) %>%
437+
unlist()
438+
xx_tmp <- xx %>%
439+
sf::st_drop_geometry(xx) %>%
440+
dplyr::arrange(-ALAND) %>%
441+
dplyr::mutate(
442+
t_cs = cumsum(TotalPopE),
443+
n_2 = t_cs <= X,
444+
)
445+
if (!(TRUE %in% xx_tmp$n_2)) {
446+
xx_2 <- xx_tmp %>%
447+
dplyr::slice(1)
448+
} else {
449+
xx_2 <- xx_tmp %>%
450+
dplyr::filter(n_2 == TRUE)
451+
}
452+
if (nrow(xx_2) == 1 & 0 %in% xx_2$TotalPopE) {
453+
xx_2 <- xx_tmp %>%
454+
dplyr::filter(TotalPopE > 0) %>%
455+
dplyr::slice(1)
456+
}
457+
T_2 <- xx_2 %>%
458+
dplyr::summarise(
459+
T_2 = sum(TotalPopE)
460+
) %>%
461+
unlist()
462+
num <- sum((x_i * a_i) / X, na.rm = TRUE) - sum((xx_1$TotalPopE * xx_1$ALAND) / T_1, na.rm = TRUE)
463+
denom <- sum((xx_2$TotalPopE * xx_2$ALAND) / T_2, na.rm = TRUE) - sum((xx_1$TotalPopE * xx_1$ALAND) / T_1, na.rm = TRUE)
464+
ACO_tmp <- (num / denom)
465+
if (is.infinite(ACO_tmp) | is.na(ACO_tmp)) { ACO_tmp <- 0 }
466+
ACO <- 1 - ACO_tmp
467+
return(ACO)
468+
}
469+
}

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[![DOI](https://zenodo.org/badge/521439746.svg)](https://zenodo.org/badge/latestdoi/521439746)
1313
<!-- badges: end -->
1414

15-
**Date repository last updated**: 2024-08-30
15+
**Date repository last updated**: 2024-08-31
1616

1717
### Overview
1818

@@ -103,6 +103,10 @@ To install the development version from GitHub:
103103
<td>Compute the aspatial racial or ethnic Absolute Clustering (<i>ACL</i>) based on <a href='https://doi.org/10.1093/sf/67.2.281'>Massey & Denton (1988)</a></td>
104104
</tr>
105105
<tr>
106+
<td><a href='/R/massey_duncan.R'><code>massey_duncan</code></a></td>
107+
<td>Compute the aspatial racial or ethnic Absolute Concentration (<i>ACO</i>) based on <a href='https://doi.org/10.1093/sf/67.2.281'>Massey & Denton (1988)</a> and Duncan, Cuzzort, & Duncan (1961; LC:60007089)</td>
108+
</tr>
109+
<tr>
106110
<td><a href='/R/messer.R'><code>messer</code></a></td>
107111
<td>Compute the aspatial Neighborhood Deprivation Index (<i>NDI</i>) based on <a href='https://doi.org/10.1007/s11524-006-9094-x'>Messer et al. (2006)</a></td>
108112
</tr>
@@ -1368,6 +1372,51 @@ ggplot() +
13681372

13691373
![](man/figures/acl.png)
13701374

1375+
```r
1376+
# --------------------------------------------------------- #
1377+
# Compute aspatial Absolute Concentration (Massey & Denton) #
1378+
# --------------------------------------------------------- #
1379+
1380+
# Absolute Concentration based on Massey & Denton (1988) and Duncan, Cuzzort, & Duncan (1961)
1381+
## Selected subgroup: Not Hispanic or Latino, Black or African American alone
1382+
## Selected large geography: census tract
1383+
## Selected small geography: census block group
1384+
ACO_2020_DC <- massey_duncan(
1385+
geo_large = 'tract',
1386+
geo_small = 'cbg',
1387+
state = 'DC',
1388+
year = 2020,
1389+
subgroup = 'NHoLB'
1390+
)
1391+
1392+
# Obtain the 2020 census tracts from the 'tigris' package
1393+
tract_2020_DC <- tracts(state = 'DC', year = 2020, cb = TRUE)
1394+
1395+
# Join the ACO (Massey & Denton) values to the census tract geometry
1396+
ACO_2020_DC <- tract_2020_DC %>%
1397+
left_join(ACO_2020_DC$aco, by = 'GEOID')
1398+
1399+
ggplot() +
1400+
geom_sf(
1401+
data = ACO_2020_DC,
1402+
aes(fill = ACO),
1403+
color = 'white'
1404+
) +
1405+
theme_bw() +
1406+
scale_fill_viridis_c(limits = c(0, 1)) +
1407+
labs(
1408+
fill = 'Index (Continuous)',
1409+
caption = 'Source: U.S. Census ACS 2016-2020 estimates'
1410+
) +
1411+
ggtitle(
1412+
'Absolute Concentration (Massey & Denton)\n
1413+
Washington, D.C. census block groups to tracts',
1414+
subtitle = 'Black non-Hispanic'
1415+
)
1416+
```
1417+
1418+
![](man/figures/aco.png)
1419+
13711420
```r
13721421
# ------------------------------------------------------------ #
13731422
# Compute aspatial racial or ethnic Location Quotient (Sudano) #

cran-comments.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
* Added `james_taeuber()` function to compute the aspatial racial or ethnic Dissimilarity Index (*D*) based on [James & Taeuber (1985)](https://doi.org/10.2307/270845)
99
* Added `lieberson()` function to compute the aspatial racial or ethnic Isolation Index (_xPx\*_) based on Lieberson (1981; ISBN-13:978-1-032-53884-6) and and [Bell (1954)](https://doi.org/10.2307/2574118)
1010
* Added `massey()` function to compute the aspatial racial or ethnic Absolute Clustering (*ACL*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281)
11+
* Added `massey_duncan()` function to compute the aspatial racial or ethnic Absolute Concentration (*ACO*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281) and Duncan, Cuzzort, & Duncan (1961; LC:60007089)
1112
* Added `theil()` function the aspatial racial or ethnic Entropy (*H*) based on Theil (1972; ISBN:978-0-444-10378-9) and [Theil & Finizza (1971)](https://doi.org/110.1080/0022250X.1971.9989795)
1213
* Added `white_blau()` function to compute an index of spatial proximity (*SP*) based on [White (1986)](https://doi.org/10.2307/3644339) and Blau (1977; ISBN-13:978-0-029-03660-0)
13-
* Added `geo_large = 'place'` for census-designated places, `geo_large = 'cbsa'` for core-based statistical areas, `geo_large = 'csa'` for combined statistical areas, and `geo_large = 'metro'` for metropolitan divisions as the larger geographical unit in `atkinson()`, `bell()`, `bemanian_beyer()`, `denton()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `sudano()`, `theil()`, and `white()`, `white_blau()` functions.
14+
* Added `geo_large = 'place'` for census-designated places, `geo_large = 'cbsa'` for core-based statistical areas, `geo_large = 'csa'` for combined statistical areas, and `geo_large = 'metro'` for metropolitan divisions as the larger geographical unit in `atkinson()`, `bell()`, `bemanian_beyer()`, `denton()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `sudano()`, `theil()`, and `white()`, `white_blau()` functions.
1415
* Added census block group computation for `anthopolos()` by specifying `geo == 'cbg'` or `geo == 'block group'`
1516
* Added `holder` argument to `atkinson()` function to toggle the computation with or without the Hölder mean. The function can now compute *A* without the Hölder mean. The default is `holder = FALSE`.
1617
* Added `crs` argument to `anthopolos()`, `bravo()`, and `white_blau()` functions to provide spatial projection of the distance-based metrics
@@ -28,7 +29,7 @@
2829
* Renamed 'race/ethnicity' or 'racial/ethnic' to 'race or ethnicity' or 'racial or ethnic' throughout documentation to use more modern, inclusive, and appropriate language
2930
* Updated documentation about value range of *V* (White) from `{0 to 1}` to `{-Inf to Inf}`
3031
* Split up vignette into three separate vignettes: 'ndi1', 'ndi2', and 'ndi3' for the *NDI*, racial or ethnic residential segregation, and additional socioeconomic disparity indices, respectively
31-
* Added examples for `atkinson()`, `duncan_cuzzort()`, `duncan_duncan()`, `gini()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `theil()`, and `white_blau()` functions in vignettes and README
32+
* Added examples for `atkinson()`, `duncan_cuzzort()`, `duncan_duncan()`, `gini()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `theil()`, and `white_blau()` functions in vignettes and README
3233
* Added example for `holder` argument in `atkinson()` function in README
3334
* Reordered the README examples alphabetically
3435
* Reordered the vignette examples to group the racial or ethnic residential segregation indices
@@ -45,7 +46,7 @@
4546
* <https://doi.org/10.2307/3644339>
4647
* <https://doi.org/10.2307/2084686>
4748

48-
* Some tests and examples for `anthopolos()`, `atkinson()`, `bell()`, `bemanian_beyer()`, `bravo()`, `denton()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `gini()`, `hoover()`, `james_taeuber()`, `krieger()`, `lieberson()`, `massey()`, `messer()`, `powell_wiley()`, `sudano()`, `theil()`, `white()`, and `white_blau()` functions require a Census API key so they are skipped if NULL or not run
49+
* Some tests and examples for `anthopolos()`, `atkinson()`, `bell()`, `bemanian_beyer()`, `bravo()`, `denton()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `gini()`, `hoover()`, `james_taeuber()`, `krieger()`, `lieberson()`, `massey()`, `massey_duncan()`, `messer()`, `powell_wiley()`, `sudano()`, `theil()`, `white()`, and `white_blau()` functions require a Census API key so they are skipped if NULL or not run
4950

5051
## Test environments
5152
* local Windows install, R 4.4.1

inst/CITATION

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ bibentry(bibtype = 'manual',
33
author = as.person('Ian D. Buller'),
44
publisher = 'The Comprehensive R Archive Network',
55
year = '2024',
6-
number = '0.1.6.9010.',
6+
number = '0.1.6.9011.',
77
doi = '10.5281/zenodo.6989030',
88
url = 'https://cran.r-project.org/package=ndi',
99

@@ -422,6 +422,44 @@ bibentry(bibtype = 'Article',
422422
header = 'If you computed ACL (Massey & Denton) values, please also cite:'
423423
)
424424

425+
bibentry(bibtype = 'Article',
426+
title = 'The Dimensions of Residential Segregation',
427+
author = c(as.person('Douglas S. Massey'),
428+
as.person('Nancy A. Denton')),
429+
journal = 'Social Forces',
430+
year = '1988',
431+
volume = '67',
432+
issue = '2',
433+
pages = '281--315',
434+
doi = '10.1093/sf/67.2.281',
435+
436+
textVersion =
437+
paste('Douglas S. Massey & Nancy A. Denton (1988).',
438+
'The Dimensions of Residential Segregation.',
439+
'Social Forces, 67(1), 281-315.',
440+
'DOI:10.1093/sf/67.2.281'),
441+
442+
header = 'If you computed ACO (Massey & Denton) values, please also cite (1):'
443+
)
444+
445+
bibentry(bibtype = 'Book',
446+
title = 'Statistical Geography: Problems in Analyzing Area Data',
447+
author = c(as.person('Otis D. Duncan'),
448+
as.person('Ray P. Cuzzort'),
449+
as.person('Beverly Duncan')),
450+
year = '1961',
451+
publisher = 'Free Press',
452+
lc = '60007089',
453+
454+
textVersion =
455+
paste('Otis D. Duncan, Ray P. Cuzzort, & Beverly Duncan (1961).',
456+
'Statistical Geography: Problems in Analyzing Area Data.',
457+
'Free Press',
458+
'LC:60007089'),
459+
460+
header = 'And (2):'
461+
)
462+
425463
bibentry(bibtype = 'Article',
426464
title = 'The Dimensions of Residential Segregation',
427465
author = c(as.person('Douglas S. Massey'),

0 commit comments

Comments
 (0)