diff --git a/DESCRIPTION b/DESCRIPTION index 45f8321..a46fad0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ndi Title: Neighborhood Deprivation Indices -Version: 0.1.6.9012 -Date: 2024-09-01 +Version: 0.1.6.9013 +Date: 2024-09-02 Authors@R: c(person(given = "Ian D.", family = "Buller", diff --git a/NAMESPACE b/NAMESPACE index ddd03a1..9db4c2c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,7 @@ export(lieberson) export(massey) export(massey_duncan) export(messer) +export(morgan_massey) export(powell_wiley) export(sudano) export(theil) diff --git a/NEWS.md b/NEWS.md index a37064e..d94eefd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # ndi (development version) -## ndi v0.1.6.9012 +## ndi v0.1.6.9013 ### New Features @@ -17,9 +17,10 @@ * 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) * 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) * 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) +* Added `morgan_massey()` function to compute the aspatial racial or ethnic Distance-Decay Isolation Index (_DPxx\*_) based on [Morgan (1983)](https://www.jstor.org/stable/20001935) and [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281) #### New Function Capabilities -* 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()`, `denton_cuzzort()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `sudano()`, `theil()`, and `white()`, `white_blau()` functions. +* 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()`, `denton_cuzzort()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `morgan_massey()`, `sudano()`, `theil()`, and `white()`, `white_blau()` functions. * Added census block group computation for `anthopolos()` by specifying `geo == 'cbg'` or `geo == 'block group'` * 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`. * Added `crs` argument to `anthopolos()`, `bravo()`, and `white_blau()` functions to provide spatial projection of the distance-based metrics @@ -45,7 +46,7 @@ * Re-formatted code and documentation throughout for consistent readability * Renamed 'race/ethnicity' or 'racial/ethnic' to 'race or ethnicity' or 'racial or ethnic' throughout documentation to use more modern, inclusive, and appropriate language * Updated documentation about value range of *V* (White) from `{0 to 1}` to `{-Inf to Inf}` -* 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 +* Added examples for `atkinson()`, `duncan_cuzzort()`, `duncan_duncan()`, `gini()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `morgan_massey()`, `theil()`, and `white_blau()` functions in vignettes and README * Added example for `holder` argument in `atkinson()` function in README * Reordered the contents of 'ndi-package.R' thematically * Reordered the README examples alphabetically diff --git a/R/anthopolos.R b/R/anthopolos.R index 4d08523..b4dca59 100644 --- a/R/anthopolos.R +++ b/R/anthopolos.R @@ -60,8 +60,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Racial Isolation Index of Black populations -#' ## of census tracts within Georgia, U.S.A., counties (2020) +#' # Racial Isolation Index (a measure of isolation) +#' ## of Black populations +#' ## in census tracts of Georgia, U.S.A. (2020) #' anthopolos( #' geo = 'tract', #' state = 'GA', diff --git a/R/atkinson.R b/R/atkinson.R index abe8ccc..63fdd33 100644 --- a/R/atkinson.R +++ b/R/atkinson.R @@ -70,8 +70,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Atkinson Index (a measure of the evenness) of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Atkinson Index (a measure of the evenness) +#' ## of Black populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' atkinson( #' geo_large = 'county', #' geo_small = 'tract', @@ -80,8 +81,9 @@ #' subgroup = c('NHoLB', 'HoLB') #' ) #' -#' # Atkinson Index of median household income -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Atkinson Index (a measure of the evenness) +#' ## of median household income +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' atkinson( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/bell.R b/R/bell.R index 80237bb..870e4a4 100644 --- a/R/bell.R +++ b/R/bell.R @@ -67,8 +67,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Interaction of non-Hispanic Black vs. non-Hispanic white populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Interaction Index (a measure of exposure) +#' ## of non-Hispanic Black vs. non-Hispanic white populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' bell( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/bemanian_beyer.R b/R/bemanian_beyer.R index fa7a75e..49cc0e6 100644 --- a/R/bemanian_beyer.R +++ b/R/bemanian_beyer.R @@ -70,8 +70,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Local Exposure and Isolation of non-Hispanic Black vs. non-Hispanic white populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Local Exposure and Isolation +#' ## of non-Hispanic Black vs. non-Hispanic white populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' bemanian_beyer( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/bravo.R b/R/bravo.R index 5ef75fa..0cf3d9f 100644 --- a/R/bravo.R +++ b/R/bravo.R @@ -47,8 +47,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Educational Isolation Index of less than some college or associate's degree attainment -#' ## of census tracts within Georgia, U.S.A., counties (2020) +#' # Educational Isolation Index (a measure of exposure) +#' ## of less than some college or associate's degree attainment +#' ## in census tracts of Georgia, U.S.A. (2020) #' bravo( #' geo = 'tract', #' state = 'GA', diff --git a/R/denton.R b/R/denton.R index ca2cc40..cd9ed75 100644 --- a/R/denton.R +++ b/R/denton.R @@ -71,8 +71,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Index of spatial proximity of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Relative Clustering (a measure of clustering) +#' ## of non-Hispanic Black vs. non-Hispanic white populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' denton( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/denton_cuzzort.R b/R/denton_cuzzort.R index abb8c0f..e2c7123 100644 --- a/R/denton_cuzzort.R +++ b/R/denton_cuzzort.R @@ -68,8 +68,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Index of spatial proximity of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Relative Concentration (a measure of concentration) +#' ## of non-Hispanic Black vs. non-Hispanic white populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' denton_cuzzort( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/duncan.R b/R/duncan.R index 85f02ad..b8f5e6f 100644 --- a/R/duncan.R +++ b/R/duncan.R @@ -67,9 +67,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Dissimilarity Index (Duncan & Duncan) +#' # Dissimilarity Index (Duncan & Duncan; a measure of evenness) #' ## of non-Hispanic Black vs. non-Hispanic white populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' duncan( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/duncan_cuzzort.R b/R/duncan_cuzzort.R index fb37a28..a627dea 100644 --- a/R/duncan_cuzzort.R +++ b/R/duncan_cuzzort.R @@ -70,8 +70,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Absolute Centralization of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Absolute Centralization (a measure of centralization) +#' ## of Black populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' duncan_cuzzort( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/duncan_duncan.R b/R/duncan_duncan.R index 051cc09..9793f58 100644 --- a/R/duncan_duncan.R +++ b/R/duncan_duncan.R @@ -71,8 +71,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Relative Centralization of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Relative Centralization (a measure of centralization) +#' ## of non-Hispanic Black vs. non-Hispanic white populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' duncan_duncan( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/gini.R b/R/gini.R index 4c02620..311b0c7 100644 --- a/R/gini.R +++ b/R/gini.R @@ -66,8 +66,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Gini Index (a metric of unevenness) of Black populations -#' ## of census tracts within Georgia, U.S.A., counties (2020) +#' # Gini Index (a metric of evenness) +#' ## of Black populations +#' ## in census tracts of Georgia, U.S.A. (2020) #' gini( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/globals.R b/R/globals.R index 60f97c5..07df090 100644 --- a/R/globals.R +++ b/R/globals.R @@ -282,6 +282,7 @@ globalVariables( 'TotalPopE', 'n_1', 'n_2', - 't_cs' + 't_cs', + 'DPxx_star' ) ) diff --git a/R/hoover.R b/R/hoover.R index 48193ba..56ae8ea 100644 --- a/R/hoover.R +++ b/R/hoover.R @@ -66,8 +66,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Delta (a measure of concentration) of non-Hispanic Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Delta (a measure of concentration) +#' ## of non-Hispanic Black populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' hoover( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/james_taeuber.R b/R/james_taeuber.R index 6245231..3d80998 100644 --- a/R/james_taeuber.R +++ b/R/james_taeuber.R @@ -66,9 +66,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Dissimilarity Index (James & Taeuber) +#' # Dissimilarity Index (James & Taeuber; a measure of evenness) #' ## of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' james_taeuber( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/lieberson.R b/R/lieberson.R index 6139a5c..fbf358d 100644 --- a/R/lieberson.R +++ b/R/lieberson.R @@ -66,8 +66,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Interaction of non-Hispanic Black vs. non-Hispanic white populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Interaction (a measure of exposure) +#' ## of non-Hispanic Black vs. non-Hispanic white populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' bell( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/massey.R b/R/massey.R index 0bb4e90..6475a9b 100644 --- a/R/massey.R +++ b/R/massey.R @@ -70,8 +70,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Index of spatial proximity of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Absolute Clustering (a measure of clustering) +#' ## of Black populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' massey( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/massey_duncan.R b/R/massey_duncan.R index e5b9bd0..83d2830 100644 --- a/R/massey_duncan.R +++ b/R/massey_duncan.R @@ -67,8 +67,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Index of spatial proximity of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Absolute Concentration (a measure of concentration) +#' ## of Black populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' massey_duncan( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/morgan_massey.R b/R/morgan_massey.R new file mode 100644 index 0000000..d588a20 --- /dev/null +++ b/R/morgan_massey.R @@ -0,0 +1,411 @@ +#' Distance-Decay Isolation Index based on Morgan (1983) and Massey & Denton (1988) +#' +#' Compute the aspatial Distance-Decay Isolation Index (Morgan) of a selected racial or ethnic subgroup(s) and U.S. geographies. +#' +#' @param geo_large Character string specifying the larger geographical unit of the data. The default is counties \code{geo_large = 'county'}. +#' @param geo_small Character string specifying the smaller geographical unit of the data. The default is census tracts \code{geo_small = 'tract'}. +#' @param year Numeric. The year to compute the estimate. The default is 2020, and the years 2009 onward are currently available. +#' @param subgroup Character string specifying the racial or ethnic subgroup(s) as the comparison population. See Details for available choices. +#' @param crs Numeric or character string specifying the coordinate reference system to compute the distance-based metric. The default is Albers North America \code{crs = 'ESRI:102008'}. +#' @param omit_NAs Logical. If FALSE, will compute index for a larger geographical unit only if all of its smaller geographical units have values. The default is TRUE. +#' @param quiet Logical. If TRUE, will display messages about potential missing census information. The default is FALSE. +#' @param ... Arguments passed to \code{\link[tidycensus]{get_acs}} to select state, county, and other arguments for census characteristics +#' +#' @details This function will compute the aspatial Distance-Decay Isolation Index (_DPxx\*_) of selected racial or ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Morgan (1986) \url{https://www.jstor.org/stable/20001935} and Massey & Denton (1988) \doi{10.1093/sf/67.2.281}. This function provides the computation of _DPxx\*_ for any of the U.S. Census Bureau race or ethnicity subgroups (including Hispanic and non-Hispanic individuals). +#' +#' The function uses the \code{\link[tidycensus]{get_acs}} function to obtain U.S. Census Bureau 5-year American Community Survey characteristics used for the computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'} and 2011 onward for \code{geo_large = 'place'}, \code{geo_large = 'csa'}, or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial or ethnic subgroups (U.S. Census Bureau definitions) are: +#' \itemize{ +#' \item \strong{B03002_002}: not Hispanic or Latino \code{'NHoL'} +#' \item \strong{B03002_003}: not Hispanic or Latino, white alone \code{'NHoLW'} +#' \item \strong{B03002_004}: not Hispanic or Latino, Black or African American alone \code{'NHoLB'} +#' \item \strong{B03002_005}: not Hispanic or Latino, American Indian and Alaska Native alone \code{'NHoLAIAN'} +#' \item \strong{B03002_006}: not Hispanic or Latino, Asian alone \code{'NHoLA'} +#' \item \strong{B03002_007}: not Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'NHoLNHOPI'} +#' \item \strong{B03002_008}: not Hispanic or Latino, Some other race alone \code{'NHoLSOR'} +#' \item \strong{B03002_009}: not Hispanic or Latino, Two or more races \code{'NHoLTOMR'} +#' \item \strong{B03002_010}: not Hispanic or Latino, Two races including Some other race \code{'NHoLTRiSOR'} +#' \item \strong{B03002_011}: not Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'NHoLTReSOR'} +#' \item \strong{B03002_012}: Hispanic or Latino \code{'HoL'} +#' \item \strong{B03002_013}: Hispanic or Latino, white alone \code{'HoLW'} +#' \item \strong{B03002_014}: Hispanic or Latino, Black or African American alone \code{'HoLB'} +#' \item \strong{B03002_015}: Hispanic or Latino, American Indian and Alaska Native alone \code{'HoLAIAN'} +#' \item \strong{B03002_016}: Hispanic or Latino, Asian alone \code{'HoLA'} +#' \item \strong{B03002_017}: Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'HoLNHOPI'} +#' \item \strong{B03002_018}: Hispanic or Latino, Some other race alone \code{'HoLSOR'} +#' \item \strong{B03002_019}: Hispanic or Latino, Two or more races \code{'HoLTOMR'} +#' \item \strong{B03002_020}: Hispanic or Latino, Two races including Some other race \code{'HoLTRiSOR'} +#' \item \strong{B03002_021}: Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'HoLTReSOR'} +#' } +#' +#' Use the internal \code{state} and \code{county} arguments within the \code{\link[tidycensus]{get_acs}} function to specify geographic extent of the data output. +#' +#' _DPxx\*_ is a measure of clustering of racial or ethnic populations within smaller geographical units that are located within larger geographical units. _DPxx\*_ is some measure of the probability that a member of one subgroup(s) will meet or interact with a member of another subgroup(s). _DPxx\*_ can range in value from 0 to 1 with higher values signifying higher probability of isolation (less isolation). +#' +#' The metric uses the exponential transform of a distance matrix (kilometers) between smaller geographical area centroids, with a diagonal defined as \code{(0.6*a_{i})^{0.5}} where \code{a_{i}} is the area (square kilometers) of smaller geographical unit \code{i} as defined by White (1983) \doi{10.1086/227768}. +#' +#' Larger geographical units available include states \code{geo_large = 'state'}, counties \code{geo_large = 'county'}, census tracts \code{geo_large = 'tract'}, census-designated places \code{geo_large = 'place'}, core-based statistical areas \code{geo_large = 'cbsa'}, combined statistical areas \code{geo_large = 'csa'}, and metropolitan divisions \code{geo_large = 'metro'}. Smaller geographical units available include, counties \code{geo_small = 'county'}, census tracts \code{geo_small = 'tract'}, and census block groups \code{geo_small = 'cbg'}. If a larger geographical unit is comprised of only one smaller geographical unit (e.g., a U.S county contains only one census tract), then the _DPxx\*_ value returned is NA. If the larger geographical unit is census-designated places \code{geo_large = 'place'}, core-based statistical areas \code{geo_large = 'cbsa'}, combined statistical areas \code{geo_large = 'csa'}, or metropolitan divisions \code{geo_large = 'metro'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{V} computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested larger geographical unit are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the _DPxx\*_ computation. +#' +#' @return An object of class 'list'. This is a named list with the following components: +#' +#' \describe{ +#' \item{\code{dpxx_star}}{An object of class 'tbl' for the GEOID, name, and _DPxx\*_ at specified larger census geographies.} +#' \item{\code{dpxx_star_data}}{An object of class 'tbl' for the raw census values at specified smaller census geographies.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute _DPxx\*_.} +#' } +#' +#' @import dplyr +#' @importFrom sf st_centroid st_distance st_drop_geometry st_transform st_within +#' @importFrom stats complete.cases +#' @importFrom stringr str_trim +#' @importFrom tidycensus get_acs +#' @importFrom tidyr pivot_longer separate +#' @importFrom tigris combined_statistical_areas core_based_statistical_areas metro_divisions places +#' @importFrom units drop_units set_units +#' @importFrom utils stack +#' @export +#' +#' @seealso \code{\link[tidycensus]{get_acs}} for additional arguments for geographic extent selection (i.e., \code{state} and \code{county}). +#' +#' @examples +#' \dontrun{ +#' # Wrapped in \dontrun{} because these examples require a Census API key. +#' +#' # Distance-Decay Isolation Index (a measure of clustering) +#' ## of Black populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) +#' morgan_massey( +#' geo_large = 'county', +#' geo_small = 'tract', +#' state = 'GA', +#' year = 2020, +#' subgroup = c('NHoLB', 'HoLB') +#' ) +#' +#' } +#' +morgan_massey <- function(geo_large = 'county', + geo_small = 'tract', + year = 2020, + subgroup, + crs = 'ESRI:102008', + omit_NAs = TRUE, + quiet = FALSE, + ...) { + + # Check arguments + match.arg(geo_large, choices = c('state', 'county', 'tract', 'place', 'cbsa', 'csa', 'metro')) + match.arg(geo_small, choices = c('county', 'tract', 'cbg', 'block group')) + stopifnot(is.numeric(year), year >= 2009) # all variables available 2009 onward + match.arg( + subgroup, + several.ok = TRUE, + choices = c( + 'NHoL', + 'NHoLW', + 'NHoLB', + 'NHoLAIAN', + 'NHoLA', + 'NHoLNHOPI', + 'NHoLSOR', + 'NHoLTOMR', + 'NHoLTRiSOR', + 'NHoLTReSOR', + 'HoL', + 'HoLW', + 'HoLB', + 'HoLAIAN', + 'HoLA', + 'HoLNHOPI', + 'HoLSOR', + 'HoLTOMR', + 'HoLTRiSOR', + 'HoLTReSOR' + ) + ) + + # Select census variables + vars <- c( + TotalPop = 'B03002_001', + NHoL = 'B03002_002', + NHoLW = 'B03002_003', + NHoLB = 'B03002_004', + NHoLAIAN = 'B03002_005', + NHoLA = 'B03002_006', + NHoLNHOPI = 'B03002_007', + NHoLSOR = 'B03002_008', + NHoLTOMR = 'B03002_009', + NHoLTRiSOR = 'B03002_010', + NHoLTReSOR = 'B03002_011', + HoL = 'B03002_012', + HoLW = 'B03002_013', + HoLB = 'B03002_014', + HoLAIAN = 'B03002_015', + HoLA = 'B03002_016', + HoLNHOPI = 'B03002_017', + HoLSOR = 'B03002_018', + HoLTOMR = 'B03002_019', + HoLTRiSOR = 'B03002_020', + HoLTReSOR = 'B03002_021' + ) + + selected_vars <- vars[c('TotalPop', subgroup)] + out_names <- c(names(selected_vars), 'ALAND') # save for output + in_subgroup <- paste0(subgroup, 'E') + + # Acquire DPxx_star variables and sf geometries + out_dat <- suppressMessages(suppressWarnings( + tidycensus::get_acs( + geography = geo_small, + year = year, + output = 'wide', + variables = selected_vars, + geometry = TRUE, + keep_geo_vars = TRUE, + ... + ) + )) + + # Format output + if (geo_small == 'county') { + out_dat <- out_dat %>% + tidyr::separate(NAME.y, into = c('county', 'state'), sep = ',') + } + if (geo_small == 'tract') { + out_dat <- out_dat %>% + tidyr::separate(NAME.y, into = c('tract', 'county', 'state'), sep = ',') %>% + dplyr::mutate(tract = gsub('[^0-9\\.]', '', tract)) + } + if (geo_small == 'cbg' | geo_small == 'block group') { + out_dat <- out_dat %>% + tidyr::separate(NAME.y, into = c('cbg', 'tract', 'county', 'state'), sep = ',') %>% + dplyr::mutate( + tract = gsub('[^0-9\\.]', '', tract), + cbg = gsub('[^0-9\\.]', '', cbg) + ) + } + + # Grouping IDs for DPxx_star computation + if (geo_large == 'state') { + out_dat <- out_dat %>% + dplyr::mutate( + oid = STATEFP, + state = stringr::str_trim(state) + ) + } + if (geo_large == 'tract') { + out_dat <- out_dat %>% + dplyr::mutate( + oid = paste0(STATEFP, COUNTYFP, TRACTCE), + state = stringr::str_trim(state), + county = stringr::str_trim(county) + ) + } + if (geo_large == 'county') { + out_dat <- out_dat %>% + dplyr::mutate( + oid = paste0(STATEFP, COUNTYFP), + state = stringr::str_trim(state), + county = stringr::str_trim(county) + ) + } + if (geo_large == 'place') { + stopifnot(is.numeric(year), year >= 2011) # Places only available 2011 onward + lgeom <- suppressMessages(suppressWarnings(tigris::places( + year = year, state = unique(out_dat$state)) + )) + wlgeom <- sf::st_within(out_dat, lgeom) + out_dat <- out_dat %>% + dplyr::mutate( + oid = lapply(wlgeom, function(x) { + tmp <- lgeom[x, 4] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + place = lapply(wlgeom, function(x) { + tmp <- lgeom[x, 5] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) + } + if (geo_large == 'cbsa') { + stopifnot(is.numeric(year), year >= 2010) # CBSAs only available 2010 onward + lgeom <- suppressMessages(suppressWarnings(tigris::core_based_statistical_areas(year = year))) + wlgeom <- sf::st_within(out_dat, lgeom) + out_dat <- out_dat %>% + dplyr::mutate( + oid = lapply(wlgeom, function(x) { + tmp <- lgeom[x, 3] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + cbsa = lapply(wlgeom, function(x) { + tmp <- lgeom[x, 4] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) + } + if (geo_large == 'csa') { + stopifnot(is.numeric(year), year >= 2011) # CSAs only available 2011 onward + lgeom <- suppressMessages(suppressWarnings(tigris::combined_statistical_areas(year = year))) + wlgeom <- sf::st_within(out_dat, lgeom) + out_dat <- out_dat %>% + dplyr::mutate( + oid = lapply(wlgeom, function(x) { + tmp <- lgeom[x, 2] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + csa = lapply(wlgeom, function(x) { + tmp <- lgeom[x, 3] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) + } + if (geo_large == 'metro') { + stopifnot(is.numeric(year), year >= 2011) # Metropolitan Divisions only available 2011 onward + lgeom <- suppressMessages(suppressWarnings(tigris::metro_divisions(year = year))) + wlgeom <- sf::st_within(out_dat, lgeom) + out_dat <- out_dat %>% + dplyr::mutate( + oid = lapply(wlgeom, function(x) { + tmp <- lgeom[x, 4] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + metro = lapply(wlgeom, function(x) { + tmp <- lgeom[x, 5] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) + } + + # Count of racial or ethnic subgroup populations + ## Count of racial or ethnic comparison subgroup population + if (length(in_subgroup) == 1) { + out_dat <- out_dat %>% + dplyr::mutate(subgroup = as.data.frame(.)[, in_subgroup]) + } else { + out_dat <- out_dat %>% + dplyr::mutate(subgroup = rowSums(as.data.frame(.)[, in_subgroup])) + } + + # Compute DPxx_star + ## From Massey & Denton (1988) https://doi.org/10.1093/sf/67.2.281 + ## DP_{xx}^{*}=\sum_{i=1}^{n}\frac{x_{i}}{X}\sum_{j=1}^{n}\frac{K_{ij}x_{j}}{t_{j}} + ## Where for i & j smaller geographical units: + ## x_{i} denotes the racial or ethnic subgroup population of smaller geographical unit i + ## X denotes the racial or ethnic subgroup population of a larger geographical unit + ## t_{j} denotes the total population of smaller geographical unit j + ## and + ## K_{ij} = \frac{exp(-d_{ij})t_{j}}{\sum_{i=1}^{n}exp(-d_{ij})t_{j}} + + ## Compute + out_tmp <- out_dat %>% + .[.$oid != 'NANA', ] %>% + split(., f = list(.$oid)) %>% + lapply(., FUN = dpxx_star_fun, crs = crs, omit_NAs = omit_NAs) %>% + utils::stack(.) %>% + dplyr::mutate( + DPxx_star = values, + oid = ind + ) %>% + dplyr::select(DPxx_star, oid) %>% + sf::st_drop_geometry() + + # Warning for missingness of census characteristics + missingYN <- out_dat[, c('TotalPopE', in_subgroup, 'ALAND')] %>% + sf::st_drop_geometry() + names(missingYN) <- out_names + missingYN <- missingYN %>% + tidyr::pivot_longer( + cols = dplyr::everything(), + names_to = 'variable', + values_to = 'val' + ) %>% + dplyr::group_by(variable) %>% + dplyr::summarise( + total = dplyr::n(), + n_missing = sum(is.na(val)), + percent_missing = paste0(round(mean(is.na(val)) * 100, 2), ' %') + ) + + if (quiet == FALSE) { + # Warning for missing census data + if (sum(missingYN$n_missing) > 0) { + message('Warning: Missing census data') + } + } + + # Format output + out <- out_dat %>% + sf::st_drop_geometry() %>% + dplyr::left_join(out_tmp, by = dplyr::join_by(oid)) + if (geo_large == 'state') { + out <- out %>% + dplyr::select(oid, state, DPxx_star) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, state, DPxx_star) + } + if (geo_large == 'county') { + out <- out %>% + dplyr::select(oid, state, county, DPxx_star) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, state, county, DPxx_star) + } + if (geo_large == 'tract') { + out <- out %>% + dplyr::select(oid, state, county, tract, DPxx_star) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, state, county, tract, DPxx_star) + } + if (geo_large == 'place') { + out <- out %>% + dplyr::select(oid, place, DPxx_star) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, place, DPxx_star) + } + if (geo_large == 'cbsa') { + out <- out %>% + dplyr::select(oid, cbsa, DPxx_star) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, cbsa, DPxx_star) + } + if (geo_large == 'csa') { + out <- out %>% + dplyr::select(oid, csa, DPxx_star) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, csa, DPxx_star) + } + if (geo_large == 'metro') { + out <- out %>% + dplyr::select(oid, metro, DPxx_star) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, metro, DPxx_star) + } + + out <- out %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::filter(!is.na(GEOID)) %>% + dplyr::distinct(GEOID, .keep_all = TRUE) %>% + dplyr::arrange(GEOID) %>% + dplyr::as_tibble() + + out_dat <- out_dat %>% + dplyr::arrange(GEOID) %>% + dplyr::as_tibble() + + out <- list(dpxx_star = out, dpxx_star_data = out_dat, missing = missingYN) + + return(out) +} diff --git a/R/ndi-package.R b/R/ndi-package.R index 8a9be5d..e7e45ef 100644 --- a/R/ndi-package.R +++ b/R/ndi-package.R @@ -34,7 +34,7 @@ #' #' \code{\link{gini}} Computes the aspatial Gini Index (\emph{G}) based on Gini (1921) \doi{10.2307/2223319}. #' -#' \code{\link{hoover}} Computes the aspatial Delta (\emph{DEL}) based on Hoover (1941) \doi{doi:10.1017/S0022050700052980} and Duncan, Cuzzort, & Duncan (1961; LC:60007089). +#' \code{\link{hoover}} Computes the aspatial Delta (\emph{DEL}) based on Hoover (1941) \doi{10.1017/S0022050700052980} and Duncan, Cuzzort, & Duncan (1961; LC:60007089). #' #' \code{\link{james_taeuber}} Computes the aspatial Dissimilarity Index (\emph{D}) based on James & Taeuber (1985) \doi{10.2307/270845}. #' @@ -44,13 +44,15 @@ #' #' \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). #' +#' \code{\link{morgan_massey}} Computes the aspatial Distance-Decay Isolation Index (\emph{DPxx\*}) based on Morgan (1986) \url{https://www.jstor.org/stable/20001935} and Massey & Denton (1988) \doi{10.1093/sf/67.2.281}. +#' #' \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}. #' #' \code{\link{theil}} Computes the aspatial Entropy (\emph{H}) based on Theil (1972; ISBN-13:978-0-444-10378-9) and Theil & Finizza (1971) \doi{110.1080/0022250X.1971.9989795}. #' #' \code{\link{white}} Computes the aspatial Correlation Ratio (\emph{V}) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}. #' -#' \code{\link{white_blau}} Computes an index of spatial proximity (\emph{SP}) based on White (1986) \doi{10.2307/3644339} and Blau (1977; ISBN-13:978-0-029-03660-0). +#' \code{\link{white_blau}} Computes an index of spatial proximity (\emph{SP}) based on White (1986) \doi{10.2307/3644339} \url{} and Blau (1977; ISBN-13:978-0-029-03660-0). #' #' \strong{Additional Indices of Socioeconomic Disparity} #' diff --git a/R/sudano.R b/R/sudano.R index 595cc8a..3564701 100644 --- a/R/sudano.R +++ b/R/sudano.R @@ -66,8 +66,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Location Quotient (a measure of relative homogeneity) of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Location Quotient (a measure of relative homogeneity) +#' ## of Black populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' sudano( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/theil.R b/R/theil.R index 3e8a558..7db6407 100644 --- a/R/theil.R +++ b/R/theil.R @@ -68,9 +68,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Entropy (Theil) +#' # Entropy (a measure of evenness) #' ## of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' theil( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/utils.R b/R/utils.R index a75f6b8..21c8770 100644 --- a/R/utils.R +++ b/R/utils.R @@ -221,6 +221,33 @@ djt_fun <- function(x, omit_NAs) { } } +# Internal function for Distance Decay Isolation +## From Massey & Denton (1988) https://doi.org/10.1093/sf/67.2.281 +## Returns NA value if only one smaller geography with population in a larger geography +dpxx_star_fun <- function(x, crs, omit_NAs) { + xx <- x %>% + dplyr::select(TotalPopE, subgroup, ALAND) %>% + dplyr::filter(TotalPopE > 0) + if (omit_NAs == TRUE) { xx <- xx[stats::complete.cases(sf::st_drop_geometry(xx)), ] } + if (nrow(sf::st_drop_geometry(xx)) < 2 || any(sf::st_drop_geometry(xx) < 0) || any(is.na(sf::st_drop_geometry(xx)))) { + NA + } else { + xx <- xx %>% sf::st_transform(crs = crs) + x_i <- x_j <- xx$subgroup + X <- sum(x_i, na.rm = TRUE) + t_j <- xx$TotalPopE + d_ij <- suppressWarnings(sf::st_distance(sf::st_centroid(xx), sf::st_centroid(xx))) + diag(d_ij) <- sqrt(0.6 * xx$ALAND) + c_ij <- -d_ij %>% + units::set_units(value = km) %>% + units::drop_units() %>% + exp() + K_ij <- c_ij * t_j / sum(c_ij * t_j, na.rm = TRUE) + DPxx_star <- sum(x_i / X, na.rm = TRUE) * sum(K_ij * x_j / t_j, na.rm = TRUE) + return(DPxx_star) + } +} + # Internal function for the Gini Index ## Gini (1921) https://doi.org/10.2307/2223319 ## Returns NA value if only one smaller geography with population in a larger geography diff --git a/R/white.R b/R/white.R index 2da0a0b..61e28a0 100644 --- a/R/white.R +++ b/R/white.R @@ -66,8 +66,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Correlation Ratio (a measure of isolation) of Black populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Correlation Ratio (a measure of exposure) +#' ## of Black populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' white( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/R/white_blau.R b/R/white_blau.R index 15041b8..3a140fd 100644 --- a/R/white_blau.R +++ b/R/white_blau.R @@ -71,8 +71,9 @@ #' \dontrun{ #' # Wrapped in \dontrun{} because these examples require a Census API key. #' -#' # Index of spatial proximity of non-Hispanic Black vs. non-Hispanic white populations -#' ## of census tracts within counties within Georgia, U.S.A., counties (2020) +#' # Index of spatial proximity (a measure of clustering) +#' ## of non-Hispanic Black vs. non-Hispanic white populations +#' ## in census tracts within counties of Georgia, U.S.A. (2020) #' white_blau( #' geo_large = 'county', #' geo_small = 'tract', diff --git a/README.md b/README.md index 73421d9..f4a9bd4 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ [![DOI](https://zenodo.org/badge/521439746.svg)](https://zenodo.org/badge/latestdoi/521439746) -**Date repository last updated**: 2024-09-01 +**Date repository last updated**: 2024-09-02 ### Overview @@ -115,6 +115,10 @@ To install the development version from GitHub: Compute the aspatial Neighborhood Deprivation Index (NDI) based on Messer et al. (2006) +morgan_massey +Compute the aspatial racial or ethnic Distance-Decay Isolation Index (DPxx*) based on Morgan (1983) and Massey & Denton (1988) + + powell_wiley Compute the aspatial Neighborhood Deprivation Index (NDI) based on Andrews et al. (2020) and Slotman et al. (2022) with variables chosen by Roux and Mair (2010) @@ -757,9 +761,9 @@ ggsave(file.path('man', 'figures', 'ei.png'), height = 7, width = 7) ![](man/figures/ei.png) ```r -# ------------------------------------------------------ # -# Compute aspatial Relative Clustering (Massey & Denton) # -# ------------------------------------------------------ # +# ----------------------------------------------------------------------- # +# Compute aspatial racial or ethnic Relative Clustering (Massey & Denton) # +# ----------------------------------------------------------------------- # # Relative Clustering based on Massey & Denton (1988) ## Selected subgroup: Not Hispanic or Latino, Black or African American alone @@ -809,9 +813,9 @@ ggsave(file.path('man', 'figures', 'rcl.png'), height = 7, width = 7) ![](man/figures/rcl.png) ```r -# --------------------------------------------------------- # -# Compute aspatial Relative Concentration (Massey & Denton) # -# --------------------------------------------------------- # +# -------------------------------------------------------------------------- # +# Compute aspatial racial or ethnic Relative Concentration (Massey & Denton) # +# -------------------------------------------------------------------------- # # Relative Concentration based on Massey & Denton (1988) and Duncan, Cuzzort, & Duncan (1961) ## Selected subgroup: Not Hispanic or Latino, Black or African American alone @@ -908,9 +912,9 @@ ggsave(file.path('man', 'figures', 'ddd.png'), height = 7, width = 7) ![](man/figures/ddd.png) ```r -# ----------------------------------------------------------- # -# Compute aspatial Absolute Centralization (Duncan & Cuzzort) # -# ----------------------------------------------------------- # +# ---------------------------------------------------------------------------- # +# Compute aspatial racial or ethnic Absolute Centralization (Duncan & Cuzzort) # +# ---------------------------------------------------------------------------- # # Absolute Centralization based on Duncan, Cuzzort, & Duncan (1961) and Massey & Denton (1988) ## Selected subgroup: Not Hispanic or Latino, Black or African American alone @@ -959,9 +963,9 @@ ggsave(file.path('man', 'figures', 'ace.png'), height = 7, width = 7) ![](man/figures/ace.png) ```r -# ---------------------------------------------------------- # -# Compute aspatial Relative Centralization (Duncan & Duncan) # -# ---------------------------------------------------------- # +# --------------------------------------------------------------------------- # +# Compute aspatial racial or ethnic Relative Centralization (Duncan & Duncan) # +# --------------------------------------------------------------------------- # # Relative Centralization based on Duncan & Duncan (1955b) and Massey & Denton (1988) ## Selected subgroup comparison: Not Hispanic or Latino, Black or African American alone @@ -1012,9 +1016,9 @@ ggsave(file.path('man', 'figures', 'rce.png'), height = 7, width = 7) ![](man/figures/rce.png) ``` r -# ------------------------------------------ # -# Compute aspatial race or ethnic Gini Index # -# ------------------------------------------ # +# -------------------------------------------- # +# Compute aspatial racial or ethnic Gini Index # +# -------------------------------------------- # # Gini Index based on Gini (1921) ## Selected subgroup: Not Hispanic or Latino, Black or African American alone @@ -1393,9 +1397,9 @@ ggsave(file.path('man', 'figures', 'xpx_star.png'), height = 7, width = 7) ![](man/figures/xpx_star.png) ```r -# ------------------------------------------------------ # -# Compute aspatial Absolute Clustering (Massey & Denton) # -# ------------------------------------------------------ # +# ----------------------------------------------------------------------- # +# Compute aspatial racial or ethnic Absolute Clustering (Massey & Denton) # +# ----------------------------------------------------------------------- # # Absolute Clustering based on Massey & Denton (1988) ## Selected subgroup: Not Hispanic or Latino, Black or African American alone @@ -1444,9 +1448,9 @@ ggsave(file.path('man', 'figures', 'acl.png'), height = 7, width = 7) ![](man/figures/acl.png) ```r -# --------------------------------------------------------- # -# Compute aspatial Absolute Concentration (Massey & Denton) # -# --------------------------------------------------------- # +# -------------------------------------------------------------------------- # +# Compute aspatial racial or ethnic Absolute Concentration (Massey & Denton) # +# -------------------------------------------------------------------------- # # Absolute Concentration based on Massey & Denton (1988) and Duncan, Cuzzort, & Duncan (1961) ## Selected subgroup: Not Hispanic or Latino, Black or African American alone @@ -1488,6 +1492,51 @@ ggsave(file.path('man', 'figures', 'aco.png'), height = 7, width = 7) ![](man/figures/aco.png) +```r +# ------------------------------------------------------------------------- # +# Compute aspatial racial or ethnic Distance-Decay Isolation Index (Morgan) # +# ------------------------------------------------------------------------- # + +# Distance-Decay Isolation Index based on Morgan (1983) and Massey & Denton (1988) +## Selected subgroup: Not Hispanic or Latino, Black or African American alone +## Selected large geography: census tract +## Selected small geography: census block group +DPxx_star_2020_DC <- morgan_massey( + geo_large = 'tract', + geo_small = 'cbg', + state = 'DC', + year = 2020, + subgroup = 'NHoLB' +) + +# Obtain the 2020 census tracts from the 'tigris' package +tract_2020_DC <- tracts(state = 'DC', year = 2020, cb = TRUE) + +# Join the DPxx* (Morgan) values to the census tract geometry +DPxx_star_2020_DC <- tract_2020_DC %>% + left_join(DPxx_star_2020_DC$dpxx_star, by = 'GEOID') + +ggplot() + + geom_sf( + data = DPxx_star_2020_DC, + aes(fill = DPxx_star), + color = 'white' + ) + + theme_bw() + + scale_fill_viridis_c(limits = c(0, 1)) + + labs( + fill = 'Index (Continuous)', + caption = 'Source: U.S. Census ACS 2016-2020 estimates' + ) + + ggtitle( + 'Distance-Decay Isolation Index (Morgan)\nCensus block groups within tracts of Washington, D.C.', + subtitle = 'Black non-Hispanic' + ) +ggsave(file.path('man', 'figures', 'dpxx_star.png'), height = 7, width = 7) +``` + +![](man/figures/dpxx_star.png) + ```r # ------------------------------------------------------------ # # Compute aspatial racial or ethnic Location Quotient (Sudano) # @@ -1624,9 +1673,9 @@ ggsave(file.path('man', 'figures', 'v.png'), height = 7, width = 7) ![](man/figures/v.png) ```r -# --------------------------------------------- # -# Compute an index of spatial proximity (White) # -# --------------------------------------------- # +# ------------------------------------------------------------- # +# Compute a racial or ethnic index of spatial proximity (White) # +# ------------------------------------------------------------- # # An index of spatial proximity based on White (1986) & Blau (1977) ## Selected subgroup: Not Hispanic or Latino, Black or African American alone diff --git a/cran-comments.md b/cran-comments.md index 4cf8f91..4cb6d7f 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -10,9 +10,10 @@ * 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) * 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) * 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) + * Added `morgan_massey()` function to compute the aspatial racial or ethnic Distance-Decay Isolation Index (_DPxx\*_) based on [Morgan (1983)](https://www.jstor.org/stable/20001935) and [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281) * 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) * 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) - * 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()`, `denton_cuzzort()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `sudano()`, `theil()`, and `white()`, `white_blau()` functions. + * 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()`, `denton_cuzzort()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `morgan_massey()`, `sudano()`, `theil()`, and `white()`, `white_blau()` functions. * Added census block group computation for `anthopolos()` by specifying `geo == 'cbg'` or `geo == 'block group'` * 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`. * Added `crs` argument to `anthopolos()`, `bravo()`, and `white_blau()` functions to provide spatial projection of the distance-based metrics @@ -30,7 +31,7 @@ * Renamed 'race/ethnicity' or 'racial/ethnic' to 'race or ethnicity' or 'racial or ethnic' throughout documentation to use more modern, inclusive, and appropriate language * Updated documentation about value range of *V* (White) from `{0 to 1}` to `{-Inf to Inf}` * 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 - * 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 + * Added examples for `atkinson()`, `duncan_cuzzort()`, `duncan_duncan()`, `gini()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `morgan_massey()`, `theil()`, and `white_blau()` functions in vignettes and README * Added example for `holder` argument in `atkinson()` function in README * Reordered the README examples alphabetically * Reordered the vignette examples to group the racial or ethnic residential segregation indices diff --git a/inst/CITATION b/inst/CITATION index 4c65114..4ae6133 100755 --- a/inst/CITATION +++ b/inst/CITATION @@ -3,7 +3,7 @@ bibentry(bibtype = 'manual', author = as.person('Ian D. Buller'), publisher = 'The Comprehensive R Archive Network', year = '2024', - number = '0.1.6.9012.', + number = '0.1.6.9013.', doi = '10.5281/zenodo.6989030', url = 'https://cran.r-project.org/package=ndi', @@ -11,7 +11,7 @@ bibentry(bibtype = 'manual', paste('Ian D. Buller (2024).', 'ndi: Neighborhood Deprivation Indices.', 'The Comprehensive R Archive Network.', - 'v0.1.6.9012.', + 'v0.1.6.9013.', 'DOI:10.5281/zenodo.6989030', 'Accessed by: https://cran.r-project.org/package=ndi'), @@ -460,6 +460,45 @@ bibentry(bibtype = 'Book', header = 'And (2):' ) +bibentry(bibtype = 'Article', + title = 'A Distance-Decay Based Interaction Index to Measure Residential Segregation', + author = as.person('Barrie S. Morgan'), + journal = 'Area', + year = '1983', + volume = '15', + issue = '4', + pages = '211--217', + url = 'https://www.jstor.org/stable/20001935', + + textVersion = + paste('Barrie S. Morgan (1983).', + 'A Distance-Decay Based Interaction Index to Measure Residential Segregation.', + 'Area, 15(4), 211-217.', + 'https://www.jstor.org/stable/20001935'), + + header = 'If you computed DPxx* (Morgan) values, please also cite (1):' +) + +bibentry(bibtype = 'Article', + title = 'The Dimensions of Residential Segregation', + author = c(as.person('Douglas S. Massey'), + as.person('Nancy A. Denton')), + journal = 'Social Forces', + year = '1988', + volume = '67', + issue = '2', + pages = '281--315', + doi = '10.1093/sf/67.2.281', + + textVersion = + paste('Douglas S. Massey & Nancy A. Denton (1988).', + 'The Dimensions of Residential Segregation.', + 'Social Forces, 67(1), 281-315.', + 'DOI:10.1093/sf/67.2.281'), + + header = 'And (2):' +) + bibentry(bibtype = 'Article', title = 'The Dimensions of Residential Segregation', author = c(as.person('Douglas S. Massey'), diff --git a/man/anthopolos.Rd b/man/anthopolos.Rd index 348d8ed..24c79a7 100644 --- a/man/anthopolos.Rd +++ b/man/anthopolos.Rd @@ -72,8 +72,9 @@ A census geography (and its neighbors) that has nearly all of its population who \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Racial Isolation Index of Black populations - ## of census tracts within Georgia, U.S.A., counties (2020) + # Racial Isolation Index (a measure of isolation) + ## of Black populations + ## in census tracts of Georgia, U.S.A. (2020) anthopolos( geo = 'tract', state = 'GA', diff --git a/man/atkinson.Rd b/man/atkinson.Rd index 05f62ef..426e8a0 100644 --- a/man/atkinson.Rd +++ b/man/atkinson.Rd @@ -86,8 +86,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Atkinson Index (a measure of the evenness) of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Atkinson Index (a measure of the evenness) + ## of Black populations + ## in census tracts within counties of Georgia, U.S.A. (2020) atkinson( geo_large = 'county', geo_small = 'tract', @@ -96,8 +97,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c subgroup = c('NHoLB', 'HoLB') ) - # Atkinson Index of median household income - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Atkinson Index (a measure of the evenness) + ## of median household income + ## in census tracts within counties of Georgia, U.S.A. (2020) atkinson( geo_large = 'county', geo_small = 'tract', diff --git a/man/bell.Rd b/man/bell.Rd index ba971c7..d5767f4 100644 --- a/man/bell.Rd +++ b/man/bell.Rd @@ -81,8 +81,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Interaction of non-Hispanic Black vs. non-Hispanic white populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Interaction Index (a measure of exposure) + ## of non-Hispanic Black vs. non-Hispanic white populations + ## in census tracts within counties of Georgia, U.S.A. (2020) bell( geo_large = 'county', geo_small = 'tract', diff --git a/man/bemanian_beyer.Rd b/man/bemanian_beyer.Rd index 2eb59ce..86530f6 100644 --- a/man/bemanian_beyer.Rd +++ b/man/bemanian_beyer.Rd @@ -83,8 +83,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Local Exposure and Isolation of non-Hispanic Black vs. non-Hispanic white populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Local Exposure and Isolation + ## of non-Hispanic Black vs. non-Hispanic white populations + ## in census tracts within counties of Georgia, U.S.A. (2020) bemanian_beyer( geo_large = 'county', geo_small = 'tract', diff --git a/man/bravo.Rd b/man/bravo.Rd index 39c16f3..9f0def6 100644 --- a/man/bravo.Rd +++ b/man/bravo.Rd @@ -58,8 +58,9 @@ A census geography (and its neighbors) that has nearly all of its population wit \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Educational Isolation Index of less than some college or associate's degree attainment - ## of census tracts within Georgia, U.S.A., counties (2020) + # Educational Isolation Index (a measure of exposure) + ## of less than some college or associate's degree attainment + ## in census tracts of Georgia, U.S.A. (2020) bravo( geo = 'tract', state = 'GA', diff --git a/man/denton.Rd b/man/denton.Rd index 44bf141..cd5a463 100644 --- a/man/denton.Rd +++ b/man/denton.Rd @@ -86,8 +86,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Index of spatial proximity of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Relative Clustering (a measure of clustering) + ## of non-Hispanic Black vs. non-Hispanic white populations + ## in census tracts within counties of Georgia, U.S.A. (2020) denton( geo_large = 'county', geo_small = 'tract', diff --git a/man/denton_cuzzort.Rd b/man/denton_cuzzort.Rd index be371e5..63c23cc 100644 --- a/man/denton_cuzzort.Rd +++ b/man/denton_cuzzort.Rd @@ -81,8 +81,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Index of spatial proximity of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Relative Concentration (a measure of concentration) + ## of non-Hispanic Black vs. non-Hispanic white populations + ## in census tracts within counties of Georgia, U.S.A. (2020) denton_cuzzort( geo_large = 'county', geo_small = 'tract', diff --git a/man/duncan.Rd b/man/duncan.Rd index e674ce1..4d2ad2d 100644 --- a/man/duncan.Rd +++ b/man/duncan.Rd @@ -81,9 +81,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Dissimilarity Index (Duncan & Duncan) + # Dissimilarity Index (Duncan & Duncan; a measure of evenness) ## of non-Hispanic Black vs. non-Hispanic white populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + ## in census tracts within counties of Georgia, U.S.A. (2020) duncan( geo_large = 'county', geo_small = 'tract', diff --git a/man/duncan_cuzzort.Rd b/man/duncan_cuzzort.Rd index 660632f..3355186 100644 --- a/man/duncan_cuzzort.Rd +++ b/man/duncan_cuzzort.Rd @@ -83,8 +83,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Absolute Centralization of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Absolute Centralization (a measure of centralization) + ## of Black populations + ## in census tracts within counties of Georgia, U.S.A. (2020) duncan_cuzzort( geo_large = 'county', geo_small = 'tract', diff --git a/man/duncan_duncan.Rd b/man/duncan_duncan.Rd index 13737ac..ddfc1cb 100644 --- a/man/duncan_duncan.Rd +++ b/man/duncan_duncan.Rd @@ -86,8 +86,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Relative Centralization of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Relative Centralization (a measure of centralization) + ## of non-Hispanic Black vs. non-Hispanic white populations + ## in census tracts within counties of Georgia, U.S.A. (2020) duncan_duncan( geo_large = 'county', geo_small = 'tract', diff --git a/man/figures/dpxx_star.png b/man/figures/dpxx_star.png new file mode 100644 index 0000000..283dfce Binary files /dev/null and b/man/figures/dpxx_star.png differ diff --git a/man/gini.Rd b/man/gini.Rd index 14f63bd..6966254 100644 --- a/man/gini.Rd +++ b/man/gini.Rd @@ -78,8 +78,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Gini Index (a metric of unevenness) of Black populations - ## of census tracts within Georgia, U.S.A., counties (2020) + # Gini Index (a metric of evenness) + ## of Black populations + ## in census tracts of Georgia, U.S.A. (2020) gini( geo_large = 'county', geo_small = 'tract', diff --git a/man/hoover.Rd b/man/hoover.Rd index 33d7552..0ae5a49 100644 --- a/man/hoover.Rd +++ b/man/hoover.Rd @@ -78,8 +78,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Delta (a measure of concentration) of non-Hispanic Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Delta (a measure of concentration) + ## of non-Hispanic Black populations + ## in census tracts within counties of Georgia, U.S.A. (2020) hoover( geo_large = 'county', geo_small = 'tract', diff --git a/man/james_taeuber.Rd b/man/james_taeuber.Rd index e08c2ec..00c1f4f 100644 --- a/man/james_taeuber.Rd +++ b/man/james_taeuber.Rd @@ -78,9 +78,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Dissimilarity Index (James & Taeuber) + # Dissimilarity Index (James & Taeuber; a measure of evenness) ## of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + ## in census tracts within counties of Georgia, U.S.A. (2020) james_taeuber( geo_large = 'county', geo_small = 'tract', diff --git a/man/lieberson.Rd b/man/lieberson.Rd index 48902b8..40ae52d 100644 --- a/man/lieberson.Rd +++ b/man/lieberson.Rd @@ -78,8 +78,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Interaction of non-Hispanic Black vs. non-Hispanic white populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Interaction (a measure of exposure) + ## of non-Hispanic Black vs. non-Hispanic white populations + ## in census tracts within counties of Georgia, U.S.A. (2020) bell( geo_large = 'county', geo_small = 'tract', diff --git a/man/massey.Rd b/man/massey.Rd index 50e755e..6d861d0 100644 --- a/man/massey.Rd +++ b/man/massey.Rd @@ -83,8 +83,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Index of spatial proximity of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Absolute Clustering (a measure of clustering) + ## of Black populations + ## in census tracts within counties of Georgia, U.S.A. (2020) massey( geo_large = 'county', geo_small = 'tract', diff --git a/man/massey_duncan.Rd b/man/massey_duncan.Rd index 98f9fdf..08b5ed4 100644 --- a/man/massey_duncan.Rd +++ b/man/massey_duncan.Rd @@ -78,8 +78,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Index of spatial proximity of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Absolute Concentration (a measure of concentration) + ## of Black populations + ## in census tracts within counties of Georgia, U.S.A. (2020) massey_duncan( geo_large = 'county', geo_small = 'tract', diff --git a/man/morgan_massey.Rd b/man/morgan_massey.Rd new file mode 100644 index 0000000..91a66a4 --- /dev/null +++ b/man/morgan_massey.Rd @@ -0,0 +1,102 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/morgan_massey.R +\name{morgan_massey} +\alias{morgan_massey} +\title{Distance-Decay Isolation Index based on Morgan (1983) and Massey & Denton (1988)} +\usage{ +morgan_massey( + geo_large = "county", + geo_small = "tract", + year = 2020, + subgroup, + crs = "ESRI:102008", + omit_NAs = TRUE, + quiet = FALSE, + ... +) +} +\arguments{ +\item{geo_large}{Character string specifying the larger geographical unit of the data. The default is counties \code{geo_large = 'county'}.} + +\item{geo_small}{Character string specifying the smaller geographical unit of the data. The default is census tracts \code{geo_small = 'tract'}.} + +\item{year}{Numeric. The year to compute the estimate. The default is 2020, and the years 2009 onward are currently available.} + +\item{subgroup}{Character string specifying the racial or ethnic subgroup(s) as the comparison population. See Details for available choices.} + +\item{crs}{Numeric or character string specifying the coordinate reference system to compute the distance-based metric. The default is Albers North America \code{crs = 'ESRI:102008'}.} + +\item{omit_NAs}{Logical. If FALSE, will compute index for a larger geographical unit only if all of its smaller geographical units have values. The default is TRUE.} + +\item{quiet}{Logical. If TRUE, will display messages about potential missing census information. The default is FALSE.} + +\item{...}{Arguments passed to \code{\link[tidycensus]{get_acs}} to select state, county, and other arguments for census characteristics} +} +\value{ +An object of class 'list'. This is a named list with the following components: + +\describe{ +\item{\code{dpxx_star}}{An object of class 'tbl' for the GEOID, name, and \emph{DPxx\*} at specified larger census geographies.} +\item{\code{dpxx_star_data}}{An object of class 'tbl' for the raw census values at specified smaller census geographies.} +\item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute \emph{DPxx\*}.} +} +} +\description{ +Compute the aspatial Distance-Decay Isolation Index (Morgan) of a selected racial or ethnic subgroup(s) and U.S. geographies. +} +\details{ +This function will compute the aspatial Distance-Decay Isolation Index (\emph{DPxx\*}) of selected racial or ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Morgan (1986) \url{https://www.jstor.org/stable/20001935} and Massey & Denton (1988) \doi{10.1093/sf/67.2.281}. This function provides the computation of \emph{DPxx\*} for any of the U.S. Census Bureau race or ethnicity subgroups (including Hispanic and non-Hispanic individuals). + +The function uses the \code{\link[tidycensus]{get_acs}} function to obtain U.S. Census Bureau 5-year American Community Survey characteristics used for the computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'} and 2011 onward for \code{geo_large = 'place'}, \code{geo_large = 'csa'}, or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial or ethnic subgroups (U.S. Census Bureau definitions) are: +\itemize{ +\item \strong{B03002_002}: not Hispanic or Latino \code{'NHoL'} +\item \strong{B03002_003}: not Hispanic or Latino, white alone \code{'NHoLW'} +\item \strong{B03002_004}: not Hispanic or Latino, Black or African American alone \code{'NHoLB'} +\item \strong{B03002_005}: not Hispanic or Latino, American Indian and Alaska Native alone \code{'NHoLAIAN'} +\item \strong{B03002_006}: not Hispanic or Latino, Asian alone \code{'NHoLA'} +\item \strong{B03002_007}: not Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'NHoLNHOPI'} +\item \strong{B03002_008}: not Hispanic or Latino, Some other race alone \code{'NHoLSOR'} +\item \strong{B03002_009}: not Hispanic or Latino, Two or more races \code{'NHoLTOMR'} +\item \strong{B03002_010}: not Hispanic or Latino, Two races including Some other race \code{'NHoLTRiSOR'} +\item \strong{B03002_011}: not Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'NHoLTReSOR'} +\item \strong{B03002_012}: Hispanic or Latino \code{'HoL'} +\item \strong{B03002_013}: Hispanic or Latino, white alone \code{'HoLW'} +\item \strong{B03002_014}: Hispanic or Latino, Black or African American alone \code{'HoLB'} +\item \strong{B03002_015}: Hispanic or Latino, American Indian and Alaska Native alone \code{'HoLAIAN'} +\item \strong{B03002_016}: Hispanic or Latino, Asian alone \code{'HoLA'} +\item \strong{B03002_017}: Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'HoLNHOPI'} +\item \strong{B03002_018}: Hispanic or Latino, Some other race alone \code{'HoLSOR'} +\item \strong{B03002_019}: Hispanic or Latino, Two or more races \code{'HoLTOMR'} +\item \strong{B03002_020}: Hispanic or Latino, Two races including Some other race \code{'HoLTRiSOR'} +\item \strong{B03002_021}: Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'HoLTReSOR'} +} + +Use the internal \code{state} and \code{county} arguments within the \code{\link[tidycensus]{get_acs}} function to specify geographic extent of the data output. + +\emph{DPxx\*} is a measure of clustering of racial or ethnic populations within smaller geographical units that are located within larger geographical units. \emph{DPxx\*} is some measure of the probability that a member of one subgroup(s) will meet or interact with a member of another subgroup(s). \emph{DPxx\*} can range in value from 0 to 1 with higher values signifying higher probability of isolation (less isolation). + +The metric uses the exponential transform of a distance matrix (kilometers) between smaller geographical area centroids, with a diagonal defined as \code{(0.6*a_{i})^{0.5}} where \code{a_{i}} is the area (square kilometers) of smaller geographical unit \code{i} as defined by White (1983) \doi{10.1086/227768}. + +Larger geographical units available include states \code{geo_large = 'state'}, counties \code{geo_large = 'county'}, census tracts \code{geo_large = 'tract'}, census-designated places \code{geo_large = 'place'}, core-based statistical areas \code{geo_large = 'cbsa'}, combined statistical areas \code{geo_large = 'csa'}, and metropolitan divisions \code{geo_large = 'metro'}. Smaller geographical units available include, counties \code{geo_small = 'county'}, census tracts \code{geo_small = 'tract'}, and census block groups \code{geo_small = 'cbg'}. If a larger geographical unit is comprised of only one smaller geographical unit (e.g., a U.S county contains only one census tract), then the \emph{DPxx\*} value returned is NA. If the larger geographical unit is census-designated places \code{geo_large = 'place'}, core-based statistical areas \code{geo_large = 'cbsa'}, combined statistical areas \code{geo_large = 'csa'}, or metropolitan divisions \code{geo_large = 'metro'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{V} computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested larger geographical unit are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the \emph{DPxx\*} computation. +} +\examples{ +\dontrun{ +# Wrapped in \dontrun{} because these examples require a Census API key. + + # Distance-Decay Isolation Index (a measure of clustering) + ## of Black populations + ## in census tracts within counties of Georgia, U.S.A. (2020) + morgan_massey( + geo_large = 'county', + geo_small = 'tract', + state = 'GA', + year = 2020, + subgroup = c('NHoLB', 'HoLB') + ) + +} + +} +\seealso{ +\code{\link[tidycensus]{get_acs}} for additional arguments for geographic extent selection (i.e., \code{state} and \code{county}). +} diff --git a/man/ndi-package.Rd b/man/ndi-package.Rd index ddd9a59..75ebaa2 100644 --- a/man/ndi-package.Rd +++ b/man/ndi-package.Rd @@ -41,7 +41,7 @@ Key content of the 'ndi' package include:\cr \code{\link{gini}} Computes the aspatial Gini Index (\emph{G}) based on Gini (1921) \doi{10.2307/2223319}. -\code{\link{hoover}} Computes the aspatial Delta (\emph{DEL}) based on Hoover (1941) \doi{doi:10.1017/S0022050700052980} and Duncan, Cuzzort, & Duncan (1961; LC:60007089). +\code{\link{hoover}} Computes the aspatial Delta (\emph{DEL}) based on Hoover (1941) \doi{10.1017/S0022050700052980} and Duncan, Cuzzort, & Duncan (1961; LC:60007089). \code{\link{james_taeuber}} Computes the aspatial Dissimilarity Index (\emph{D}) based on James & Taeuber (1985) \doi{10.2307/270845}. @@ -51,13 +51,15 @@ Key content of the 'ndi' package include:\cr \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). +\code{\link{morgan_massey}} Computes the aspatial Distance-Decay Isolation Index (\emph{DPxx\*}) based on Morgan (1986) \url{https://www.jstor.org/stable/20001935} and Massey & Denton (1988) \doi{10.1093/sf/67.2.281}. + \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}. \code{\link{theil}} Computes the aspatial Entropy (\emph{H}) based on Theil (1972; ISBN-13:978-0-444-10378-9) and Theil & Finizza (1971) \doi{110.1080/0022250X.1971.9989795}. \code{\link{white}} Computes the aspatial Correlation Ratio (\emph{V}) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}. -\code{\link{white_blau}} Computes an index of spatial proximity (\emph{SP}) based on White (1986) \doi{10.2307/3644339} and Blau (1977; ISBN-13:978-0-029-03660-0). +\code{\link{white_blau}} Computes an index of spatial proximity (\emph{SP}) based on White (1986) \doi{10.2307/3644339} \url{} and Blau (1977; ISBN-13:978-0-029-03660-0). \strong{Additional Indices of Socioeconomic Disparity} diff --git a/man/sudano.Rd b/man/sudano.Rd index f157bf4..9b07e82 100644 --- a/man/sudano.Rd +++ b/man/sudano.Rd @@ -78,8 +78,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Location Quotient (a measure of relative homogeneity) of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Location Quotient (a measure of relative homogeneity) + ## of Black populations + ## in census tracts within counties of Georgia, U.S.A. (2020) sudano( geo_large = 'county', geo_small = 'tract', diff --git a/man/theil.Rd b/man/theil.Rd index 2718847..ebc3b12 100644 --- a/man/theil.Rd +++ b/man/theil.Rd @@ -80,9 +80,9 @@ Note: The computation differs from Massey & Denton (1988) \doi{10.1093/sf/67.2.2 \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Entropy (Theil) + # Entropy (a measure of evenness) ## of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + ## in census tracts within counties of Georgia, U.S.A. (2020) theil( geo_large = 'county', geo_small = 'tract', diff --git a/man/white.Rd b/man/white.Rd index 7dad951..60c7f1e 100644 --- a/man/white.Rd +++ b/man/white.Rd @@ -78,8 +78,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Correlation Ratio (a measure of isolation) of Black populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Correlation Ratio (a measure of exposure) + ## of Black populations + ## in census tracts within counties of Georgia, U.S.A. (2020) white( geo_large = 'county', geo_small = 'tract', diff --git a/man/white_blau.Rd b/man/white_blau.Rd index 9e5d888..2e4e20e 100644 --- a/man/white_blau.Rd +++ b/man/white_blau.Rd @@ -86,8 +86,9 @@ Larger geographical units available include states \code{geo_large = 'state'}, c \dontrun{ # Wrapped in \dontrun{} because these examples require a Census API key. - # Index of spatial proximity of non-Hispanic Black vs. non-Hispanic white populations - ## of census tracts within counties within Georgia, U.S.A., counties (2020) + # Index of spatial proximity (a measure of clustering) + ## of non-Hispanic Black vs. non-Hispanic white populations + ## in census tracts within counties of Georgia, U.S.A. (2020) white_blau( geo_large = 'county', geo_small = 'tract', diff --git a/tests/testthat/test_morgan_massey.R b/tests/testthat/test_morgan_massey.R new file mode 100644 index 0000000..87d5672 --- /dev/null +++ b/tests/testthat/test_morgan_massey.R @@ -0,0 +1,79 @@ +context('morgan_massey') + +# ---------------------- # +# morgan_massey testthat # +# ---------------------- # + +test_that('morgan_massey throws error with invalid arguments', { + # Unavailable geography + expect_error( + morgan_massey( + geo_small = 'zcta', + state = 'DC', + year = 2020, + subgroup = 'NHoLB', + quiet = TRUE + ) + ) + expect_error( + morgan_massey( + geo_large = 'block group', + state = 'DC', + year = 2020, + subgroup = 'NHoLB', + quiet = TRUE + ) + ) + + # Unavailable year + expect_error(morgan_massey( + state = 'DC', + year = 2005, + subgroup = 'NHoLB', + quiet = TRUE + )) + + # Unavailable subgroup + expect_error(morgan_massey( + state = 'DC', + year = 2020, + subgroup = 'terran', + quiet = TRUE + )) + + skip_if(Sys.getenv('CENSUS_API_KEY') == '') + + # Incorrect state + expect_error(morgan_massey( + state = 'AB', + year = 2020, + subgroup = 'NHoLB', + quiet = TRUE + )) + +}) + +test_that('morgan_massey works', { + skip_if(Sys.getenv('CENSUS_API_KEY') == '') + + expect_silent(morgan_massey( + state = 'DC', + year = 2020, + subgroup = c('NHoLB', 'HoLB') + )) + + expect_silent(morgan_massey( + state = 'DC', + year = 2020, + subgroup = 'NHoLB', + quiet = TRUE + )) + + expect_silent(morgan_massey( + state = 'DC', + year = 2020, + subgroup = c('NHoLB', 'HoLB'), + quiet = TRUE + )) + +}) diff --git a/vignettes/ndi2.Rmd b/vignettes/ndi2.Rmd index e6edf99..5436f40 100644 --- a/vignettes/ndi2.Rmd +++ b/vignettes/ndi2.Rmd @@ -67,11 +67,11 @@ Since version v0.1.1, the [*ndi*](https://CRAN.R-project.org/package=ndi) packag **Clustering**: - * `massey()` function that compute Absolute Clustering (*ACL*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281) + * `massey()` function that computes Absolute Clustering (*ACL*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281) * `white_blau()` function that computes 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) * `denton()` function that compute Relative Clustering (*RCL*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281) * Distance Decay Interaction (Planned) - * Distance Decay Isolation (Planned) + * `morgan_massey()` function that computes the Distance-Decay Isolation Index (_DPxx\*_) based on [Morgan (1983)](https://www.jstor.org/stable/20001935) and [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281) ### Racial or ethnic residential segregation indices @@ -261,7 +261,7 @@ atkinson2021KY <- atkinson( epsilon = 0.67 ) -# Obtain the 2021 census counties from the 'tigris' package +# Obtain the 2021 counties from the 'tigris' package county2021KY <- counties(state = 'KY', year = 2021, cb = TRUE) # Join the A values to the county geometries @@ -307,7 +307,7 @@ duncan2010PA <- duncan( subgroup_ref = 'NHoLW' ) -# Obtain the 2010 counties from the 'tigris' package +# Obtain the 2010 counties of Pennsylvania from the 'tigris' package county2010PA <- counties(state = 'PA', year = 2010, cb = TRUE) # Remove first 9 characters from GEOID for compatibility with tigris information county2010PA$GEOID <- substring(county2010PA$GEO_ID, 10) @@ -336,7 +336,7 @@ ggplot() + scale_fill_viridis_c(limits = c(0, 1)) + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2006-2010 estimates') + ggtitle( - 'Dissimilarity Index (Duncan & Duncan)\ncensus tracts within counties of Pennsylvania', + 'Dissimilarity Index (Duncan & Duncan)\nCensus tracts within counties of Pennsylvania', subtitle = 'Black non-Hispanic vs. white non-Hispanic' ) ``` @@ -354,7 +354,7 @@ sudano2021TN <- sudano( subgroup = 'NHoLB' ) -# Obtain the 2021 census counties from the 'tigris' package +# Obtain the 2021 counties of Tennessee from the 'tigris' package county2021TN <- counties(state = 'TN', year = 2021, cb = TRUE) # Join the LQ values to the county geometry @@ -400,7 +400,7 @@ bell2021OH <- bell( subgroup_ixn = 'NHoLW' ) -# Obtain the 2021 counties from the 'tigris' package +# Obtain the 2021 counties of Ohio from the 'tigris' package county2021OH <- counties(state = 'OH', year = 2021, cb = TRUE) # Join the xPy* values to the county geometries @@ -434,7 +434,7 @@ ggplot() + #### Compute Isolation Index (_xPx\*_) -Compute the racial or ethnic _xPx\*_ values (2015-2019 5-year ACS) for census block groups within census tracts of Delaware. This metric is based on [Bell (1954)](https://doi.org/10.2307/2574118) and adapted by Lieberson (1981; ISBN-13:978-1-032-53884-6). _xPx\*_ is some measure of the probability that a member of one subgroup(s) will meet or interact with a member of another subgroup(s) with higher values signifying higher probability of interaction (less isolation) when comparing smaller geographical areas to larger ones within which the smaller geographical areas are located. _xPx\*_ can range in value from 0 to 1. +Compute the racial or ethnic _xPx\*_ values (2015-2019 5-year ACS) for census block groups within census tracts of Delaware. This metric is based on [Bell (1954)](https://doi.org/10.2307/2574118) and adapted by Lieberson (1981; ISBN-13:978-1-032-53884-6). _xPx\*_ is some measure of the probability that a member of one subgroup(s) will meet or interact with a member of another subgroup(s) with higher values signifying higher probability of interaction (less isolation) when comparing smaller geographical areas to larger ones within which the smaller geographical areas are located. _xPx\*_ can range in value from 0 to 1 with higher values signifying higher probability of interaction (less isolation). ```{r lieberson_prep, results = 'hide'} lieberson2021DE <- lieberson( @@ -445,10 +445,10 @@ lieberson2021DE <- lieberson( subgroup = 'NHoLB' ) -# Obtain the 2021 census tracts from the 'tigris' package +# Obtain the 2021 census tracts of Delaware from the 'tigris' package tract2021DE <- tracts(state = 'DE', year = 2019, cb = TRUE) -# Join the xPx* values to the cenus tract geometries +# Join the xPx* values to the census tract geometries DE2021lieberson <- tract2021DE %>% left_join(lieberson2021DE$xpx_star, by = 'GEOID') ``` @@ -490,7 +490,7 @@ white2021SC <- white( subgroup = 'NHoLB' ) -# Obtain the 2021 census counties from the 'tigris' package +# Obtain the 2021 counties of South Carolina from the 'tigris' package county2021SC <- counties(state = 'SC', year = 2021, cb = TRUE) # Join the V values to the county geometries @@ -536,7 +536,7 @@ bemanian_beyer2021MS <- bemanian_beyer( subgroup_ixn = 'NHoLW' ) -# Obtain the 2021 census counties from the 'tigris' package +# Obtain the 2021 counties of Mississippi from the 'tigris' package county2021MS <- counties(state = 'MS', year = 2021, cb = TRUE) # Join the LEx/Is values to the county geometries @@ -607,12 +607,12 @@ anthopolos2010NC <- anthopolos( subgroup = 'NHoLB' ) -# Obtain the 2010 census tracts from the 'tigris' package +# Obtain the 2010 census tracts of North Carolina from the 'tigris' package tract2010NC <- tracts(state = 'NC', year = 2010, cb = TRUE) # Remove first 9 characters from GEOID for compatibility with tigris information tract2010NC$GEOID <- substring(tract2010NC$GEO_ID, 10) -# Obtain the 2010 counties from the 'tigris' package +# Obtain the 2010 counties of North Carolina from the 'tigris' package county2010NC <- counties(state = 'NC', year = 2010, cb = TRUE) # Join the RI values to the census tract geometries @@ -654,16 +654,16 @@ anthopolos2010GNSTV <- anthopolos( subgroup = 'NHoLB' ) -# Crop to only North Carolina census tracts +# Crop to only census tracts of North Carolina anthopolos2010NCe <- anthopolos2010GNSTV$ri[anthopolos2010GNSTV$ri$GEOID %in% anthopolos2010NC$ri$GEOID, ] -# Obtain the 2010 census tracts from the 'tigris' package +# Obtain the 2010 census tracts of North Carlina from the 'tigris' package tract2010NC <- tracts(state = 'NC', year = 2010, cb = TRUE) # Remove first 9 characters from GEOID for compatibility with tigris information tract2010NC$GEOID <- substring(tract2010NC$GEO_ID, 10) -# Obtain the 2010 counties from the 'tigris' package +# Obtain the 2010 counties of North Carolina from the 'tigris' package county2010NC <- counties(state = 'NC', year = 2010, cb = TRUE) # Join the RI values to the census tract geometries @@ -708,7 +708,7 @@ hoover2021AL <- hoover( subgroup = 'NHoLB' ) -# Obtain the 2021 counties from the 'tigris' package +# Obtain the 2021 counties of Alabama from the 'tigris' package county2021AL <- counties(state = 'AL', year = 2021, cb = TRUE) # Join the DEL values to the county geometries @@ -735,7 +735,7 @@ ggplot() + scale_fill_viridis_c(limits = c(0, 1)) + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2017-2021 estimates') + ggtitle( - 'Delta (Hoover)\ncensus tracts within counties within Alabama', + 'Delta (Hoover)\nCensus tracts within counties within Alabama', subtitle = 'Black Non-Hispanic population' ) ``` @@ -759,7 +759,7 @@ cbsa2019 <- core_based_statistical_areas(year = 2019, cb = TRUE) # Obtain the 2019 state from the 'tigris' package states2019 <- states(year = 2019, cb = TRUE) -# Join the RCO values to the census-designated places geometries and filter for Connecticut +# Join the RCO values to the census-designated places geometries and filter for Wisconsin WI2019denton_cuzzort <- cbsa2019 %>% left_join(denton_cuzzort2019WI$rco, by = 'GEOID') %>% filter(!st_is_empty(.)) %>% @@ -790,7 +790,7 @@ ggplot() + ) + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2015-2019 estimates') + ggtitle( - 'Relative Concentration (Massey & Duncan)\ncensus tracts within core-based statistical areas of Wisconsin', + 'Relative Concentration (Massey & Duncan)\nCensus tracts within core-based statistical areas of Wisconsin', subtitle = 'Black non-Hispanic vs. white non-Hispanic' ) ``` @@ -813,7 +813,7 @@ cbsa2019 <- core_based_statistical_areas(year = 2019, cb = TRUE) # Obtain the 2019 state from the 'tigris' package states2019 <- states(year = 2019, cb = TRUE) -# Join the ACO values to the census-designated places geometries and filter for Connecticut +# Join the ACO values to the census-designated places geometries and filter for Wisconsin WI2019massey_duncan <- cbsa2019 %>% left_join(massey_duncan2019WI$aco, by = 'GEOID') %>% filter(!st_is_empty(.)) %>% @@ -839,7 +839,7 @@ ggplot() + scale_fill_viridis_c(limits = c(0, 1)) + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2015-2019 estimates') + ggtitle( - 'Absolute Concentration (Massey & Duncan)\ncensus tracts within core-based statistical areas of Wisconsin', + 'Absolute Concentration (Massey & Duncan)\nCensus tracts within core-based statistical areas of Wisconsin', subtitle = 'Black population' ) ``` @@ -859,7 +859,7 @@ duncan_cuzzort2017CT <- duncan_cuzzort( subgroup = c('NHoLB', 'HoLB') ) -# Obtain the 2017 census-designated places in Connecticut from the 'tigris' package +# Obtain the 2017 census-designated places of Connecticut from the 'tigris' package places2017 <- places(year = 2017, state = 'CT') # Obtain the 2017 state from the 'tigris' package states2017 <- states(year = 2017, cb = TRUE) @@ -917,7 +917,7 @@ duncan_duncan2017CT <- duncan_duncan( subgroup_ref = 'NHoLW' ) -# Obtain the 2017 census-designated places in Connecticut from the 'tigris' package +# Obtain the 2017 census-designated places of Connecticut from the 'tigris' package places2017 <- places(year = 2017, state = 'CT') # Obtain the 2017 state from the 'tigris' package states2017 <- states(year = 2017, cb = TRUE) @@ -973,7 +973,7 @@ massey2018HTX <- massey( subgroup = c('NHoLB', 'HoLB') ) -# Obtain the 2018 census tracts in Harris County, TX, from the 'tigris' package +# Obtain the 2018 census tracts of Texas from the 'tigris' package tract2018 <- tracts(year = 2018, state = 'TX') # Obtain the 2018 Texas counties from the 'tigris' package county2018 <- counties(state = 'TX', year = 2018, cb = TRUE) @@ -1086,7 +1086,7 @@ denton2018HTX <- denton( subgroup_ref = 'NHoLW' ) -# Obtain the 2018 census tracts in Harris County, TX, from the 'tigris' package +# Obtain the 2018 census tracts of Texas from the 'tigris' package tract2018 <- tracts(year = 2018, state = 'TX') # Obtain the 2018 Texas counties from the 'tigris' package county2018 <- counties(state = 'TX', year = 2018, cb = TRUE) @@ -1127,6 +1127,57 @@ ggplot() + ) ``` +#### Compute Distance-Decay Isolation Index (_DPxx\*_) + +Compute the racial or ethnic _DPxx\*_ values (2017-2021 5-year ACS) for census tracts within census-designated placed of Louisiana. This metric is based on [Morgan (1983)](https://www.jstor.org/stable/20001935) and [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281). _DPxx\*_ is some measure of the probability that a member of one subgroup(s) will meet or interact with a member of another subgroup(s). _DPxx\*_ can range in value from 0 to 1 with higher values signifying higher probability of isolation (less isolation). + +```{r morgan_massey_prep, results = 'hide'} +morgan_massey2021LA <- morgan_massey( + geo_large = 'cbsa', + geo_small = 'tract', + state = 'LA', + year = 2021, + subgroup = c('NHoLB', 'HoLB') +) + +# Obtain the 2021 core-based statistical areas from the 'tigris' package +cbsa2021 <- core_based_statistical_areas(year = 2021, cb = TRUE) +# Obtain the 2021 state from the 'tigris' package +states2021 <- states(year = 2021, cb = TRUE) + +# Join the DPxx* values to the core-based statistical area geometries and filter for Louisiana +LA2021morgan_massey <- cbsa2021 %>% + left_join(morgan_massey2021LA$dpxx_star, by = 'GEOID') %>% + filter(!st_is_empty(.)) %>% + filter(!is.na(DPxx_star)) %>% + st_filter(states2021 %>% filter(STUSPS == 'LA'), .predicate = st_within) %>% + st_make_valid() +``` + +```{r morgan_massey_plot, fig.height = 7, fig.width = 7} +# Visualize the DPxx* values (2017-2021 5-year ACS) for census tracts within core-based statistical areas of Louisiana +ggplot() + + geom_sf( + data = LA2021morgan_massey, + aes(fill = DPxx_star), + size = 0.05, + color = 'white' + ) + + geom_sf( + data = states2021 %>% filter(STUSPS == 'LA'), + fill = 'transparent', + color = 'black', + size = 0.2 + ) + + theme_minimal() + + scale_fill_viridis_c(limits = c(0, 1)) + + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2017-2021 estimates') + + ggtitle( + 'Distance-Decay Isolation Index (Morgan)\nCensus tracts within core-based statistical areas of Louisiana', + subtitle = 'Black population' + ) +``` + ```{r system} sessionInfo() ``` diff --git a/vignettes/ndi2.html b/vignettes/ndi2.html index 6a232b0..abd368d 100644 --- a/vignettes/ndi2.html +++ b/vignettes/ndi2.html @@ -12,7 +12,7 @@ - + 2. Racial or Ethnic Residential Segregation Indices @@ -341,7 +341,7 @@

2. Racial or Ethnic Residential Segregation Indices

Ian D. Buller (GitHub: @idblr)

-

2024-09-01

+

2024-09-02

@@ -429,7 +429,7 @@

Racial or Ethnic Residential Segregation Indices

Clustering:

Racial or ethnic residential segregation indices

@@ -771,7 +773,7 @@

Compute Atkinson Index (A)

epsilon = 0.67 ) -# Obtain the 2021 census counties from the 'tigris' package +# Obtain the 2021 counties from the 'tigris' package county2021KY <- counties(state = 'KY', year = 2021, cb = TRUE) # Join the A values to the county geometries @@ -825,7 +827,7 @@

Compute Dissimilarity Index (D)

subgroup_ref = 'NHoLW' ) -# Obtain the 2010 counties from the 'tigris' package +# Obtain the 2010 counties of Pennsylvania from the 'tigris' package county2010PA <- counties(state = 'PA', year = 2010, cb = TRUE) # Remove first 9 characters from GEOID for compatibility with tigris information county2010PA$GEOID <- substring(county2010PA$GEO_ID, 10) @@ -851,10 +853,10 @@

Compute Dissimilarity Index (D)

scale_fill_viridis_c(limits = c(0, 1)) + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2006-2010 estimates') + ggtitle( - 'Dissimilarity Index (Duncan & Duncan)\ncensus tracts within counties of Pennsylvania', + 'Dissimilarity Index (Duncan & Duncan)\nCensus tracts within counties of Pennsylvania', subtitle = 'Black non-Hispanic vs. white non-Hispanic' )
-

+

Compute Location Quotient (LQ)

@@ -881,7 +883,7 @@

Compute Location Quotient (LQ)

subgroup = 'NHoLB' ) -# Obtain the 2021 census counties from the 'tigris' package +# Obtain the 2021 counties of Tennessee from the 'tigris' package county2021TN <- counties(state = 'TN', year = 2021, cb = TRUE) # Join the LQ values to the county geometry @@ -931,7 +933,7 @@

Compute Interaction Index (xPy*)

subgroup_ixn = 'NHoLW' ) -# Obtain the 2021 counties from the 'tigris' package +# Obtain the 2021 counties of Ohio from the 'tigris' package county2021OH <- counties(state = 'OH', year = 2021, cb = TRUE) # Join the xPy* values to the county geometries @@ -971,7 +973,8 @@

Compute Isolation Index (xPx*)

with higher values signifying higher probability of interaction (less isolation) when comparing smaller geographical areas to larger ones within which the smaller geographical areas are located. xPx* -can range in value from 0 to 1.

+can range in value from 0 to 1 with higher values signifying higher +probability of interaction (less isolation).

lieberson2021DE <- lieberson(
   geo_large = 'tract',
   geo_small = 'block group',
@@ -980,10 +983,10 @@ 

Compute Isolation Index (xPx*)

subgroup = 'NHoLB' ) -# Obtain the 2021 census tracts from the 'tigris' package +# Obtain the 2021 census tracts of Delaware from the 'tigris' package tract2021DE <- tracts(state = 'DE', year = 2019, cb = TRUE) -# Join the xPx* values to the cenus tract geometries +# Join the xPx* values to the census tract geometries DE2021lieberson <- tract2021DE %>% left_join(lieberson2021DE$xpx_star, by = 'GEOID')
# Visualize the xPx* values (2015-2019 5-year ACS) for census block groups within census tracts of Delaware
@@ -1031,7 +1034,7 @@ 

Compute Correlation Ratio (V)

subgroup = 'NHoLB' ) -# Obtain the 2021 census counties from the 'tigris' package +# Obtain the 2021 counties of South Carolina from the 'tigris' package county2021SC <- counties(state = 'SC', year = 2021, cb = TRUE) # Join the V values to the county geometries @@ -1095,7 +1098,7 @@

Compute Local Exposure and Isolation (LEx/Is)

subgroup_ixn = 'NHoLW' ) -# Obtain the 2021 census counties from the 'tigris' package +# Obtain the 2021 counties of Mississippi from the 'tigris' package county2021MS <- counties(state = 'MS', year = 2021, cb = TRUE) # Join the LEx/Is values to the county geometries @@ -1170,12 +1173,12 @@

Compute Racial Isolation Index (RI)

subgroup = 'NHoLB' ) -# Obtain the 2010 census tracts from the 'tigris' package +# Obtain the 2010 census tracts of North Carolina from the 'tigris' package tract2010NC <- tracts(state = 'NC', year = 2010, cb = TRUE) # Remove first 9 characters from GEOID for compatibility with tigris information tract2010NC$GEOID <- substring(tract2010NC$GEO_ID, 10) -# Obtain the 2010 counties from the 'tigris' package +# Obtain the 2010 counties of North Carolina from the 'tigris' package county2010NC <- counties(state = 'NC', year = 2010, cb = TRUE) # Join the RI values to the census tract geometries @@ -1219,16 +1222,16 @@

Compute Racial Isolation Index (RI)

subgroup = 'NHoLB' ) -# Crop to only North Carolina census tracts +# Crop to only census tracts of North Carolina anthopolos2010NCe <- anthopolos2010GNSTV$ri[anthopolos2010GNSTV$ri$GEOID %in% anthopolos2010NC$ri$GEOID, ] -# Obtain the 2010 census tracts from the 'tigris' package +# Obtain the 2010 census tracts of North Carlina from the 'tigris' package tract2010NC <- tracts(state = 'NC', year = 2010, cb = TRUE) # Remove first 9 characters from GEOID for compatibility with tigris information tract2010NC$GEOID <- substring(tract2010NC$GEO_ID, 10) -# Obtain the 2010 counties from the 'tigris' package +# Obtain the 2010 counties of North Carolina from the 'tigris' package county2010NC <- counties(state = 'NC', year = 2010, cb = TRUE) # Join the RI values to the census tract geometries @@ -1276,7 +1279,7 @@

Compute Delta (DEL)

subgroup = 'NHoLB' ) -# Obtain the 2021 counties from the 'tigris' package +# Obtain the 2021 counties of Alabama from the 'tigris' package county2021AL <- counties(state = 'AL', year = 2021, cb = TRUE) # Join the DEL values to the county geometries @@ -1300,10 +1303,10 @@

Compute Delta (DEL)

scale_fill_viridis_c(limits = c(0, 1)) + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2017-2021 estimates') + ggtitle( - 'Delta (Hoover)\ncensus tracts within counties within Alabama', + 'Delta (Hoover)\nCensus tracts within counties within Alabama', subtitle = 'Black Non-Hispanic population' )
-

+

Compute Relative Concentration (RCO)

@@ -1336,7 +1339,7 @@

Compute Relative Concentration (RCO)

# Obtain the 2019 state from the 'tigris' package states2019 <- states(year = 2019, cb = TRUE) -# Join the RCO values to the census-designated places geometries and filter for Connecticut +# Join the RCO values to the census-designated places geometries and filter for Wisconsin WI2019denton_cuzzort <- cbsa2019 %>% left_join(denton_cuzzort2019WI$rco, by = 'GEOID') %>% filter(!st_is_empty(.)) %>% @@ -1364,10 +1367,10 @@

Compute Relative Concentration (RCO)

) + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2015-2019 estimates') + ggtitle( - 'Relative Concentration (Massey & Duncan)\ncensus tracts within core-based statistical areas of Wisconsin', + 'Relative Concentration (Massey & Duncan)\nCensus tracts within core-based statistical areas of Wisconsin', subtitle = 'Black non-Hispanic vs. white non-Hispanic' )
-

+

Compute Absolute Concentration (ACO)

@@ -1398,7 +1401,7 @@

Compute Absolute Concentration (ACO)

# Obtain the 2019 state from the 'tigris' package states2019 <- states(year = 2019, cb = TRUE) -# Join the ACO values to the census-designated places geometries and filter for Connecticut +# Join the ACO values to the census-designated places geometries and filter for Wisconsin WI2019massey_duncan <- cbsa2019 %>% left_join(massey_duncan2019WI$aco, by = 'GEOID') %>% filter(!st_is_empty(.)) %>% @@ -1421,10 +1424,10 @@

Compute Absolute Concentration (ACO)

scale_fill_viridis_c(limits = c(0, 1)) + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2015-2019 estimates') + ggtitle( - 'Absolute Concentration (Massey & Duncan)\ncensus tracts within core-based statistical areas of Wisconsin', + 'Absolute Concentration (Massey & Duncan)\nCensus tracts within core-based statistical areas of Wisconsin', subtitle = 'Black population' )
-

+

Compute Absolute Centralization (ACE)

@@ -1459,7 +1462,7 @@

Compute Absolute Centralization (ACE)

subgroup = c('NHoLB', 'HoLB') ) -# Obtain the 2017 census-designated places in Connecticut from the 'tigris' package +# Obtain the 2017 census-designated places of Connecticut from the 'tigris' package places2017 <- places(year = 2017, state = 'CT') # Obtain the 2017 state from the 'tigris' package states2017 <- states(year = 2017, cb = TRUE) @@ -1536,7 +1539,7 @@

Compute Relative Centralization (RCE)

subgroup_ref = 'NHoLW' ) -# Obtain the 2017 census-designated places in Connecticut from the 'tigris' package +# Obtain the 2017 census-designated places of Connecticut from the 'tigris' package places2017 <- places(year = 2017, state = 'CT') # Obtain the 2017 state from the 'tigris' package states2017 <- states(year = 2017, cb = TRUE) @@ -1598,7 +1601,7 @@

Compute Absolute Clustering (ACL)

subgroup = c('NHoLB', 'HoLB') ) -# Obtain the 2018 census tracts in Harris County, TX, from the 'tigris' package +# Obtain the 2018 census tracts of Texas from the 'tigris' package tract2018 <- tracts(year = 2018, state = 'TX') # Obtain the 2018 Texas counties from the 'tigris' package county2018 <- counties(state = 'TX', year = 2018, cb = TRUE) @@ -1724,7 +1727,7 @@

Compute Relative Clustering (RCL)

subgroup_ref = 'NHoLW' ) -# Obtain the 2018 census tracts in Harris County, TX, from the 'tigris' package +# Obtain the 2018 census tracts of Texas from the 'tigris' package tract2018 <- tracts(year = 2018, state = 'TX') # Obtain the 2018 Texas counties from the 'tigris' package county2018 <- counties(state = 'TX', year = 2018, cb = TRUE) @@ -1761,7 +1764,59 @@

Compute Relative Clustering (RCL)

subtitle = 'Black non-Hispanic vs. white non-Hispanic' )

-
sessionInfo()
+ +
+

Compute Distance-Decay Isolation Index (DPxx*)

+

Compute the racial or ethnic DPxx* values (2017-2021 5-year +ACS) for census tracts within census-designated placed of Louisiana. +This metric is based on Morgan (1983) and Massey & Denton +(1988). DPxx* is some measure of the probability that a +member of one subgroup(s) will meet or interact with a member of another +subgroup(s). DPxx* can range in value from 0 to 1 with higher +values signifying higher probability of isolation (less isolation).

+
morgan_massey2021LA <- morgan_massey(
+  geo_large = 'cbsa',
+  geo_small = 'tract',
+  state = 'LA',
+  year = 2021,
+  subgroup = c('NHoLB', 'HoLB')
+)
+
+# Obtain the 2021 core-based statistical areas from the 'tigris' package
+cbsa2021 <- core_based_statistical_areas(year = 2021, cb = TRUE)
+# Obtain the 2021 state from the 'tigris' package
+states2021 <- states(year = 2021, cb = TRUE)
+
+# Join the DPxx* values to the core-based statistical area geometries and filter for Louisiana
+LA2021morgan_massey <- cbsa2021 %>%
+  left_join(morgan_massey2021LA$dpxx_star, by = 'GEOID') %>%
+  filter(!st_is_empty(.)) %>%
+  filter(!is.na(DPxx_star)) %>%
+  st_filter(states2021 %>% filter(STUSPS == 'LA'), .predicate = st_within) %>%
+  st_make_valid()
+
# Visualize the DPxx* values (2017-2021 5-year ACS) for census tracts within core-based statistical areas of Louisiana
+ggplot() +
+  geom_sf(
+    data = LA2021morgan_massey,
+    aes(fill = DPxx_star),
+    size = 0.05,
+    color = 'white'
+  ) +
+  geom_sf(
+    data = states2021 %>% filter(STUSPS == 'LA'),
+    fill = 'transparent',
+    color = 'black',
+    size = 0.2
+  ) +
+  theme_minimal() +
+  scale_fill_viridis_c(limits = c(0, 1)) +
+  labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2017-2021 estimates') +
+  ggtitle(
+    'Distance-Decay Isolation Index (Morgan)\nCensus tracts within core-based statistical areas of Louisiana',
+    subtitle = 'Black population'
+  )
+

+
sessionInfo()
## R version 4.4.1 (2024-06-14 ucrt)
 ## Platform: x86_64-w64-mingw32/x64
 ## Running under: Windows 10 x64 (build 19045)
@@ -1783,7 +1838,7 @@ 

Compute Relative Clustering (RCL)

## [1] stats graphics grDevices utils datasets methods base ## ## other attached packages: -## [1] tigris_2.1 tidycensus_1.6.5 sf_1.0-16 ndi_0.1.6.9012 +## [1] tigris_2.1 tidycensus_1.6.5 sf_1.0-16 ndi_0.1.6.9013 ## [5] ggplot2_3.5.1 dplyr_1.1.4 knitr_1.48 ## ## loaded via a namespace (and not attached):