From 4a4147ceeda1fe924a7ba252b4217ae2457322ed Mon Sep 17 00:00:00 2001 From: Ian D Buller Date: Mon, 19 Aug 2024 20:41:46 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=80=20Merge=20`branch:dev=5Fhoover`=20?= =?UTF-8?q?into=20`branch:main`=20(#15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :sparkles: CSAs and metro divisions now available as a larger geographical unit * Added `geo_large = 'csa'` for Core Based Statistical Areas and `geo_large = 'metro'` for Metropolitan Divisions as the larger geographical unit in `atkinson()`, `bell()`, `bemanian_beyer()`, `duncan()`, `hoover()`, `sudano()`, and `white()` functions. * Updated documentation throughout --- DESCRIPTION | 18 +++---- NAMESPACE | 2 + NEWS.md | 4 +- R/anthopolos.R | 50 ++++++++--------- R/atkinson.R | 116 ++++++++++++++++++++++++++++++---------- R/bell.R | 116 ++++++++++++++++++++++++++++++---------- R/bemanian_beyer.R | 112 +++++++++++++++++++++++++++----------- R/bravo.R | 22 ++++---- R/duncan.R | 116 ++++++++++++++++++++++++++++++---------- R/gini.R | 8 +-- R/globals.R | 2 + R/hoover.R | 121 +++++++++++++++++++++++++++++++----------- R/krieger.R | 30 +++++------ R/messer.R | 32 +++++------ R/ndi-package.R | 28 +++++----- R/powell_wiley.R | 40 +++++++------- R/sudano.R | 108 +++++++++++++++++++++++++++---------- R/white.R | 116 ++++++++++++++++++++++++++++++---------- README.md | 30 +++++------ cran-comments.md | 2 +- man/atkinson.Rd | 4 +- man/bell.Rd | 4 +- man/bemanian_beyer.Rd | 4 +- man/duncan.Rd | 4 +- man/gini.Rd | 8 +-- man/hoover.Rd | 4 +- man/krieger.Rd | 2 +- man/ndi-package.Rd | 26 ++++----- man/sudano.Rd | 4 +- man/white.Rd | 4 +- 30 files changed, 767 insertions(+), 370 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 69f32bd..1aa83d4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ndi Title: Neighborhood Deprivation Indices Version: 0.1.6.9000 -Date: 2024-07-06 +Date: 2024-08-19 Authors@R: c(person(given = "Ian D.", family = "Buller", @@ -31,20 +31,20 @@ Description: Computes various metrics of socio-economic deprivation and disparit Concentration at the Extremes (ICE) based on Feldman et al. (2015) and Krieger et al. (2016) , (4) compute the aspatial racial/ethnic - Dissimilarity Index based on Duncan & Duncan (1955) , (5) - compute the aspatial income or racial/ethnic Atkinson Index based on Atkinson + Dissimilarity Index (DI) based on Duncan & Duncan (1955) , (5) + compute the aspatial income or racial/ethnic Atkinson Index (AI) based on Atkinson (1970) , (6) aspatial racial/ethnic Isolation Index (II) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell - (1954) , (7) aspatial racial/ethnic Correlation Ratio + (1954) , (7) aspatial racial/ethnic Correlation Ratio (V) based on Bell (1954) and White (1986) , (8) aspatial racial/ethnic Location Quotient (LQ) based on Merton (1939) and Sudano et al. (2013) , (9) aspatial racial/ethnic Local - Exposure and Isolation metric based on Bemanian & Beyer (2017) - , and (10) aspatial racial/ethnic Delta based on - Hoover (1941) and Duncan et al. (1961; LC:60007089). - Also using data from the ACS-5 (2005-2009 onward), the package can retrieve the - aspatial Gini Index based Gini (1921) . + Exposure and Isolation (LEx/Is) metric based on Bemanian & Beyer (2017) + , and (10) aspatial racial/ethnic Delta (DEL) + based on Hoover (1941) and Duncan et al. (1961; + LC:60007089). Also using data from the ACS-5 (2005-2009 onward), the package can + retrieve the aspatial Gini Index (G) based Gini (1921) . License: Apache License (>= 2.0) Encoding: UTF-8 LazyData: true diff --git a/NAMESPACE b/NAMESPACE index 5ac1e51..f57fcd6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -37,5 +37,7 @@ importFrom(stringr,str_trim) importFrom(tidycensus,get_acs) importFrom(tidyr,pivot_longer) importFrom(tidyr,separate) +importFrom(tigris,combined_statistical_areas) importFrom(tigris,core_based_statistical_areas) +importFrom(tigris,metro_divisions) importFrom(utils,stack) diff --git a/NEWS.md b/NEWS.md index a82643e..c4fdedb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ ### New Features * Added `hoover()` function to compute the aspatial racial/ethnic Delta (*DEL*) based on [Hoover (1941)](https://doi.org/10.1017/S0022050700052980) and Duncan et al. (1961; LC:60007089) -* Added `geo_large = 'cbsa'` option for computing Core Based Statistical Areas as the larger geographical unit in `atkinson()`, `bell()`, `bemanian_beyer()`, `duncan()`, `hoover()`, `sudano()`, and `white()` functions. +* Added `geo_large = 'cbsa'` for computing 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()`, `duncan()`, `hoover()`, `sudano()`, and `white()` functions. * Thank you for the feature suggestions, [Symielle Gaston](https://orcid.org/0000-0001-9495-1592) ### Updates @@ -97,7 +97,7 @@ ### New Features * Added `anthopolos()` function to compute the Racial Isolation Index (*RI*) based on based on [Anthopolos et al. (2011)](https://doi.org/10.1016/j.sste.2011.06.002) for specified counties/tracts 2009 onward * Added `bravo()` function to compute the Educational Isolation Index (*EI*) based on based on [Bravo et al. (2021)](https://doi.org/10.3390/ijerph18179384) for specified counties/tracts 2009 onward -* Added `gini()` function to retrieve the Gini Index based on [Gini (1921)](https://doi.org/10.2307/2223319) for specified counties/tracts 2009 onward +* Added `gini()` function to retrieve the Gini Index (*G*) based on [Gini (1921)](https://doi.org/10.2307/2223319) for specified counties/tracts 2009 onward * Thank you for the feature suggestions, [Jessica Madrigal](https://orcid.org/0000-0001-5303-5109) ### Updates diff --git a/R/anthopolos.R b/R/anthopolos.R index 4824e4f..c5ef606 100644 --- a/R/anthopolos.R +++ b/R/anthopolos.R @@ -8,41 +8,41 @@ #' @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 spatial Racial Isolation Index (*RI*) of U.S. census tracts or counties for a specified geographical extent (e.g., the entire U.S. or a single state) based on Anthopolos et al. (2011) \doi{10.1016/j.sste.2011.06.002} who originally designed the metric for the racial isolation of non-Hispanic Black individuals. This function provides the computation of *RI* for any of the U.S. Census Bureau race/ethnicity subgroups (including Hispanic and non-Hispanic individuals). +#' @details This function will compute the spatial Racial Isolation Index (\emph{RI}) of U.S. census tracts or counties for a specified geographical extent (e.g., the entire U.S. or a single state) based on Anthopolos et al. (2011) \doi{10.1016/j.sste.2011.06.002} who originally designed the metric for the racial isolation of non-Hispanic Black individuals. This function provides the computation of \emph{RI} for any of the U.S. Census Bureau race/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 geospatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available but are available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: #' \itemize{ -#' \item **B03002_002**: not Hispanic or Latino \code{'NHoL'} -#' \item **B03002_003**: not Hispanic or Latino, white alone\code{'NHoLW'} -#' \item **B03002_004**: not Hispanic or Latino, Black or African American alone \code{'NHoLB'} -#' \item **B03002_005**: not Hispanic or Latino, American Indian and Alaska Native alone \code{'NHoLAIAN'} -#' \item **B03002_006**: not Hispanic or Latino, Asian alone \code{'NHoLA'} -#' \item **B03002_007**: not Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'NHoLNHOPI'} -#' \item **B03002_008**: not Hispanic or Latino, Some other race alone \code{'NHoLSOR'} -#' \item **B03002_009**: not Hispanic or Latino, Two or more races \code{'NHoLTOMR'} -#' \item **B03002_010**: not Hispanic or Latino, Two races including Some other race \code{'NHoLTRiSOR'} -#' \item **B03002_011**: not Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'NHoLTReSOR'} -#' \item **B03002_012**: Hispanic or Latino \code{'HoL'} -#' \item **B03002_013**: Hispanic or Latino, white alone \code{'HoLW'} -#' \item **B03002_014**: Hispanic or Latino, Black or African American alone \code{'HoLB'} -#' \item **B03002_015**: Hispanic or Latino, American Indian and Alaska Native alone \code{'HoLAIAN'} -#' \item **B03002_016**: Hispanic or Latino, Asian alone \code{'HoLA'} -#' \item **B03002_017**: Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'HoLNHOPI'} -#' \item **B03002_018**: Hispanic or Latino, Some other race alone \code{'HoLSOR'} -#' \item **B03002_019**: Hispanic or Latino, Two or more races \code{'HoLTOMR'} -#' \item **B03002_020**: Hispanic or Latino, Two races including Some other race \code{'HoLTRiSOR'} -#' \item **B03002_021**: Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'HoLTReSOR'} +#' \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. NOTE: Current version does not correct for edge effects (e.g., census geographies along the specified spatial extent border, coastline, or U.S.-Mexico / U.S.-Canada border) may have few neighboring census geographies, and *RI* values in these census geographies may be unstable. A stop-gap solution for the former source of edge effect is to compute the *RI* for neighboring census geographies (i.e., the states bordering a study area of interest) and then use the estimates of the study area of interest. +#' 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. NOTE: Current version does not correct for edge effects (e.g., census geographies along the specified spatial extent border, coastline, or U.S.-Mexico / U.S.-Canada border) may have few neighboring census geographies, and \emph{RI} values in these census geographies may be unstable. A stop-gap solution for the former source of edge effect is to compute the \emph{RI} for neighboring census geographies (i.e., the states bordering a study area of interest) and then use the estimates of the study area of interest. #' -#' A census geography (and its neighbors) that has nearly all of its population who identify with the specified race/ethnicity subgroup(s) (e.g., non-Hispanic or Latino, Black or African American alone) will have an *RI* value close to 1. In contrast, a census geography (and its neighbors) that has nearly none of its population who identify with the specified race/ethnicity subgroup(s) (e.g., not non-Hispanic or Latino, Black or African American alone) will have an *RI* value close to 0. +#' A census geography (and its neighbors) that has nearly all of its population who identify with the specified race/ethnicity subgroup(s) (e.g., non-Hispanic or Latino, Black or African American alone) will have an \emph{RI} value close to 1. In contrast, a census geography (and its neighbors) that has nearly none of its population who identify with the specified race/ethnicity subgroup(s) (e.g., not non-Hispanic or Latino, Black or African American alone) will have an \emph{RI} value close to 0. #' #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{ri}}{An object of class 'tbl' for the GEOID, name, *RI*, and raw census values of specified census geographies.} -#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute *RI*.} +#' \item{\code{ri}}{An object of class 'tbl' for the GEOID, name, \emph{RI}, and raw census values of specified 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{RI}.} #' } #' #' @import dplyr diff --git a/R/atkinson.R b/R/atkinson.R index 7080587..cc11355 100644 --- a/R/atkinson.R +++ b/R/atkinson.R @@ -11,46 +11,46 @@ #' @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 Atkinson Index (*AI*) of income or selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}. This function provides the computation of *AI* for median household income and any of the U.S. Census Bureau race/ethnicity subgroups (including Hispanic and non-Hispanic individuals). +#' @details This function will compute the aspatial Atkinson Index (\emph{AI}) of income or selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}. This function provides the computation of \emph{AI} for median household income and any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. When \code{subgroup = 'MedHHInc'}, the metric will be computed for median household income ('B19013_001'). The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +#' 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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. When \code{subgroup = 'MedHHInc'}, the metric will be computed for median household income ('B19013_001'). The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: #' \itemize{ -#' \item **B03002_002**: not Hispanic or Latino \code{'NHoL'} -#' \item **B03002_003**: not Hispanic or Latino, white alone \code{'NHoLW'} -#' \item **B03002_004**: not Hispanic or Latino, Black or African American alone \code{'NHoLB'} -#' \item **B03002_005**: not Hispanic or Latino, American Indian and Alaska Native alone \code{'NHoLAIAN'} -#' \item **B03002_006**: not Hispanic or Latino, Asian alone \code{'NHoLA'} -#' \item **B03002_007**: not Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'NHoLNHOPI'} -#' \item **B03002_008**: not Hispanic or Latino, Some other race alone \code{'NHoLSOR'} -#' \item **B03002_009**: not Hispanic or Latino, Two or more races \code{'NHoLTOMR'} -#' \item **B03002_010**: not Hispanic or Latino, Two races including Some other race \code{'NHoLTRiSOR'} -#' \item **B03002_011**: not Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'NHoLTReSOR'} -#' \item **B03002_012**: Hispanic or Latino \code{'HoL'} -#' \item **B03002_013**: Hispanic or Latino, white alone \code{'HoLW'} -#' \item **B03002_014**: Hispanic or Latino, Black or African American alone \code{'HoLB'} -#' \item **B03002_015**: Hispanic or Latino, American Indian and Alaska Native alone \code{'HoLAIAN'} -#' \item **B03002_016**: Hispanic or Latino, Asian alone \code{'HoLA'} -#' \item **B03002_017**: Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'HoLNHOPI'} -#' \item **B03002_018**: Hispanic or Latino, Some other race alone \code{'HoLSOR'} -#' \item **B03002_019**: Hispanic or Latino, Two or more races \code{'HoLTOMR'} -#' \item **B03002_020**: Hispanic or Latino, Two races including Some other race \code{'HoLTRiSOR'} -#' \item **B03002_021**: Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'HoLTReSOR'} +#' \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. #' -#' *AI* is a measure of the evenness of residential inequality (e.g., racial/ethnic segregation) when comparing smaller geographical areas to larger ones within which the smaller geographical areas are located. *AI* can range in value from 0 to 1 with smaller values indicating lower levels of inequality (e.g., less segregation). +#' \emph{AI} is a measure of the evenness of residential inequality (e.g., racial/ethnic segregation) when comparing smaller geographical areas to larger ones within which the smaller geographical areas are located. \emph{AI} can range in value from 0 to 1 with smaller values indicating lower levels of inequality (e.g., less segregation). #' #' The \code{epsilon} argument that determines how to weight the increments to inequality contributed by different proportions of the Lorenz curve. A user must explicitly decide how heavily to weight smaller geographical units at different points on the Lorenz curve (i.e., whether the index should take greater account of differences among areas of over- or under-representation). The \code{epsilon} argument must have values between 0 and 1.0. For \code{0 <= epsilon < 0.5} or less 'inequality-averse,' smaller geographical units with a subgroup proportion smaller than the subgroup proportion of the larger geographical unit contribute more to inequality ('over-representation'). For \code{0.5 < epsilon <= 1.0} or more 'inequality-averse,' smaller geographical units with a subgroup proportion larger than the subgroup proportion of the larger geographical unit contribute more to inequality ('under-representation'). If \code{epsilon = 0.5} (the default), units of over- and under-representation contribute equally to the index. See Section 2.3 of Saint-Jacques et al. (2020) \doi{10.48550/arXiv.2002.05819} for one method to select \code{epsilon}. #' -#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the *AI* value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the *AI* computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the *AI* computation. +#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{AI} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{AI} 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{AI} computation. #' #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{ai}}{An object of class 'tbl' for the GEOID, name, and *AI* at specified larger census geographies.} +#' \item{\code{ai}}{An object of class 'tbl' for the GEOID, name, and \emph{AI} at specified larger census geographies.} #' \item{\code{ai_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 *AI*.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute \emph{AI}.} #' } #' #' @import dplyr @@ -58,7 +58,7 @@ #' @importFrom stats na.omit #' @importFrom tidycensus get_acs #' @importFrom tidyr pivot_longer separate -#' @importFrom tigris core_based_statistical_areas +#' @importFrom tigris combined_statistical_areas core_based_statistical_areas metro_divisions #' @importFrom utils stack #' @export #' @@ -90,7 +90,7 @@ atkinson <- function(geo_large = 'county', ...) { # Check arguments - match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa')) + match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa', 'csa', 'metro')) match.arg(geo_small, choices = c('county', 'tract', 'block group')) stopifnot(is.numeric(year), year >= 2009) # all variables available 2009 onward match.arg( @@ -217,7 +217,7 @@ atkinson <- function(geo_large = 'county', ai_data <- ai_data %>% dplyr::mutate( oid = lapply(win_cbsa, function(x) { - tmp <- dat_cbsa[x, 2] %>% sf::st_drop_geometry() + tmp <- dat_cbsa[x, 3] %>% sf::st_drop_geometry() lapply(tmp, function(x) { if (length(x) == 0) NA else x }) }) %>% unlist(), @@ -229,6 +229,44 @@ atkinson <- function(geo_large = 'county', ) %>% sf::st_drop_geometry() } + if (geo_large == 'csa') { + stopifnot(is.numeric(year), year >= 2011) # Metro Divisions only available 2011 onward + dat_csa <- suppressMessages(suppressWarnings(tigris::combined_statistical_areas(year = year))) + win_csa <- sf::st_within(ai_data, dat_csa) + ai_data <- ai_data %>% + dplyr::mutate( + oid = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 2] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + csa = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 3] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } + if (geo_large == 'metro') { + stopifnot(is.numeric(year), year >= 2011) # CSAs only available 2011 onward + dat_metro <- suppressMessages(suppressWarnings(tigris::metro_divisions(year = year))) + win_metro <- sf::st_within(ai_data, dat_metro) + ai_data <- ai_data %>% + dplyr::mutate( + oid = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 4] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + metro = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 5] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } # Count of racial/ethnic subgroup populations ## Count of racial/ethnic subgroup population @@ -328,6 +366,26 @@ atkinson <- function(geo_large = 'county', .[.$GEOID != 'NANA', ] %>% dplyr::distinct(GEOID, .keep_all = TRUE) } + if (geo_large == 'csa') { + ai <- ai_data %>% + dplyr::left_join(AItmp, by = dplyr::join_by(oid)) %>% + dplyr::select(oid, csa, AI) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, csa, AI) %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::distinct(GEOID, .keep_all = TRUE) + } + if (geo_large == 'metro') { + ai <- ai_data %>% + dplyr::left_join(AItmp, by = dplyr::join_by(oid)) %>% + dplyr::select(oid, metro, AI) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, metro, AI) %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::distinct(GEOID, .keep_all = TRUE) + } ai <- ai %>% dplyr::arrange(GEOID) %>% diff --git a/R/bell.R b/R/bell.R index 1331b83..62ac4e0 100644 --- a/R/bell.R +++ b/R/bell.R @@ -11,44 +11,44 @@ #' @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 Isolation Index (*II*) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}. This function provides the computation of *II* for any of the U.S. Census Bureau race/ethnicity subgroups (including Hispanic and non-Hispanic individuals). +#' @details This function will compute the aspatial Isolation Index (\emph{II}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}. This function provides the computation of \emph{II} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +#' 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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: #' \itemize{ -#' \item **B03002_002**: not Hispanic or Latino \code{'NHoL'} -#' \item **B03002_003**: not Hispanic or Latino, white alone \code{'NHoLW'} -#' \item **B03002_004**: not Hispanic or Latino, Black or African American alone \code{'NHoLB'} -#' \item **B03002_005**: not Hispanic or Latino, American Indian and Alaska Native alone \code{'NHoLAIAN'} -#' \item **B03002_006**: not Hispanic or Latino, Asian alone \code{'NHoLA'} -#' \item **B03002_007**: not Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'NHoLNHOPI'} -#' \item **B03002_008**: not Hispanic or Latino, Some other race alone \code{'NHoLSOR'} -#' \item **B03002_009**: not Hispanic or Latino, Two or more races \code{'NHoLTOMR'} -#' \item **B03002_010**: not Hispanic or Latino, Two races including Some other race \code{'NHoLTRiSOR'} -#' \item **B03002_011**: not Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'NHoLTReSOR'} -#' \item **B03002_012**: Hispanic or Latino \code{'HoL'} -#' \item **B03002_013**: Hispanic or Latino, white alone \code{'HoLW'} -#' \item **B03002_014**: Hispanic or Latino, Black or African American alone \code{'HoLB'} -#' \item **B03002_015**: Hispanic or Latino, American Indian and Alaska Native alone \code{'HoLAIAN'} -#' \item **B03002_016**: Hispanic or Latino, Asian alone \code{'HoLA'} -#' \item **B03002_017**: Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'HoLNHOPI'} -#' \item **B03002_018**: Hispanic or Latino, Some other race alone \code{'HoLSOR'} -#' \item **B03002_019**: Hispanic or Latino, Two or more races \code{'HoLTOMR'} -#' \item **B03002_020**: Hispanic or Latino, Two races including Some other race \code{'HoLTRiSOR'} -#' \item **B03002_021**: Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'HoLTReSOR'} +#' \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. #' -#' *II* 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). *II* can range in value from 0 to 1. +#' \emph{II} 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). \emph{II} can range in value from 0 to 1. #' -#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the *II* value returned is NA. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the *II* value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the *II* computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the *II* computation. +#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{II} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{II} 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{II} computation. #' #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{ii}}{An object of class 'tbl' for the GEOID, name, and *II* at specified larger census geographies.} +#' \item{\code{ii}}{An object of class 'tbl' for the GEOID, name, and \emph{II} at specified larger census geographies.} #' \item{\code{ii_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 *II*.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute \emph{II}.} #' } #' #' @import dplyr @@ -56,7 +56,7 @@ #' @importFrom stats complete.cases #' @importFrom tidycensus get_acs #' @importFrom tidyr pivot_longer separate -#' @importFrom tigris core_based_statistical_areas +#' @importFrom tigris combined_statistical_areas core_based_statistical_areas metro_divisions #' @importFrom utils stack #' @export #' @@ -89,7 +89,7 @@ bell <- function(geo_large = 'county', ...) { # Check arguments - match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa')) + match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa', 'csa', 'metro')) match.arg(geo_small, choices = c('county', 'tract', 'block group')) stopifnot(is.numeric(year), year >= 2009) # all variables available 2009 onward match.arg( @@ -242,7 +242,7 @@ bell <- function(geo_large = 'county', ii_data <- ii_data %>% dplyr::mutate( oid = lapply(win_cbsa, function(x) { - tmp <- dat_cbsa[x, 2] %>% sf::st_drop_geometry() + tmp <- dat_cbsa[x, 3] %>% sf::st_drop_geometry() lapply(tmp, function(x) { if (length(x) == 0) NA else x }) }) %>% unlist(), @@ -254,6 +254,44 @@ bell <- function(geo_large = 'county', ) %>% sf::st_drop_geometry() } + if (geo_large == 'csa') { + stopifnot(is.numeric(year), year >= 2011) # CSAs only available 2011 onward + dat_csa <- suppressMessages(suppressWarnings(tigris::combined_statistical_areas(year = year))) + win_csa <- sf::st_within(ii_data, dat_csa) + ii_data <- ii_data %>% + dplyr::mutate( + oid = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 2] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + csa = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 3] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } + if (geo_large == 'metro') { + stopifnot(is.numeric(year), year >= 2011) # Metro Divisions only available 2011 onward + dat_metro <- suppressMessages(suppressWarnings(tigris::metro_divisions(year = year))) + win_metro <- sf::st_within(ii_data, dat_metro) + ii_data <- ii_data %>% + dplyr::mutate( + oid = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 4] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + metro = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 5] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } # Count of racial/ethnic subgroup populations ## Count of racial/ethnic comparison subgroup population @@ -355,6 +393,26 @@ bell <- function(geo_large = 'county', .[.$GEOID != 'NANA', ] %>% dplyr::distinct(GEOID, .keep_all = TRUE) } + if (geo_large == 'csa') { + ii <- ii_data %>% + dplyr::left_join(IItmp, by = dplyr::join_by(oid)) %>% + dplyr::select(oid, csa, II) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, csa, II) %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::distinct(GEOID, .keep_all = TRUE) + } + if (geo_large == 'metro') { + ii <- ii_data %>% + dplyr::left_join(IItmp, by = dplyr::join_by(oid)) %>% + dplyr::select(oid, metro, II) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, metro, II) %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::distinct(GEOID, .keep_all = TRUE) + } ii <- ii %>% dplyr::arrange(GEOID) %>% diff --git a/R/bemanian_beyer.R b/R/bemanian_beyer.R index bc94ee0..55f41db 100644 --- a/R/bemanian_beyer.R +++ b/R/bemanian_beyer.R @@ -11,46 +11,46 @@ #' @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 Local Exposure and Isolation (*LEx/Is*) metric of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Bemanian & Beyer (2017) \doi{10.1158/1055-9965.EPI-16-0926}. This function provides the computation of *LEx/Is* for any of the U.S. Census Bureau race/ethnicity subgroups (including Hispanic and non-Hispanic individuals). +#' @details This function will compute the aspatial Local Exposure and Isolation (\emph{LEx/Is}) metric of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Bemanian & Beyer (2017) \doi{10.1158/1055-9965.EPI-16-0926}. This function provides the computation of \emph{LEx/Is} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +#' 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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: #' \itemize{ -#' \item **B03002_002**: not Hispanic or Latino \code{'NHoL'} -#' \item **B03002_003**: not Hispanic or Latino, white alone \code{'NHoLW'} -#' \item **B03002_004**: not Hispanic or Latino, Black or African American alone \code{'NHoLB'} -#' \item **B03002_005**: not Hispanic or Latino, American Indian and Alaska Native alone \code{'NHoLAIAN'} -#' \item **B03002_006**: not Hispanic or Latino, Asian alone \code{'NHoLA'} -#' \item **B03002_007**: not Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'NHoLNHOPI'} -#' \item **B03002_008**: not Hispanic or Latino, Some other race alone \code{'NHoLSOR'} -#' \item **B03002_009**: not Hispanic or Latino, Two or more races \code{'NHoLTOMR'} -#' \item **B03002_010**: not Hispanic or Latino, Two races including Some other race \code{'NHoLTRiSOR'} -#' \item **B03002_011**: not Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'NHoLTReSOR'} -#' \item **B03002_012**: Hispanic or Latino \code{'HoL'} -#' \item **B03002_013**: Hispanic or Latino, white alone \code{'HoLW'} -#' \item **B03002_014**: Hispanic or Latino, Black or African American alone \code{'HoLB'} -#' \item **B03002_015**: Hispanic or Latino, American Indian and Alaska Native alone \code{'HoLAIAN'} -#' \item **B03002_016**: Hispanic or Latino, Asian alone \code{'HoLA'} -#' \item **B03002_017**: Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'HoLNHOPI'} -#' \item **B03002_018**: Hispanic or Latino, Some other race alone \code{'HoLSOR'} -#' \item **B03002_019**: Hispanic or Latino, Two or more races \code{'HoLTOMR'} -#' \item **B03002_020**: Hispanic or Latino, Two races including Some other race \code{'HoLTRiSOR'} -#' \item **B03002_021**: Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'HoLTReSOR'} +#' \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. #' -#' *LEx/Is* is a measure of the probability that two individuals living within a specific smaller geography (e.g., census tract) of either different (i.e., exposure) or the same (i.e., isolation) racial/ethnic subgroup(s) will interact, assuming that individuals within a smaller geography are randomly mixed. *LEx/Is* is standardized with a logit transformation and centered against an expected case that all races/ethnicities are evenly distributed across a larger geography. (Note: will adjust data by 0.025 if probabilities are zero, one, or undefined. The output will include a warning if adjusted. See \code{\link[car]{logit}} for additional details.) +#' \emph{LEx/Is} is a measure of the probability that two individuals living within a specific smaller geography (e.g., census tract) of either different (i.e., exposure) or the same (i.e., isolation) racial/ethnic subgroup(s) will interact, assuming that individuals within a smaller geography are randomly mixed. \emph{LEx/Is} is standardized with a logit transformation and centered against an expected case that all races/ethnicities are evenly distributed across a larger geography. (Note: will adjust data by 0.025 if probabilities are zero, one, or undefined. The output will include a warning if adjusted. See \code{\link[car]{logit}} for additional details.) #' -#' *LEx/Is* can range from negative infinity to infinity. If *LEx/Is* is zero then the estimated probability of the interaction between two people of the given subgroup(s) within a smaller geography is equal to the expected probability if the subgroup(s) were perfectly mixed in the larger geography. If *LEx/Is* is greater than zero then the interaction is more likely to occur within the smaller geography than in the larger geography, and if *LEx/Is* is less than zero then the interaction is less likely to occur within the smaller geography than in the larger geography. Note: the exponentiation of each *LEx/Is* metric results in the odds ratio of the specific exposure or isolation of interest in a smaller geography relative to the larger geography. +#' \emph{LEx/Is} can range from negative infinity to infinity. If \emph{LEx/Is} is zero then the estimated probability of the interaction between two people of the given subgroup(s) within a smaller geography is equal to the expected probability if the subgroup(s) were perfectly mixed in the larger geography. If \emph{LEx/Is} is greater than zero then the interaction is more likely to occur within the smaller geography than in the larger geography, and if \emph{LEx/Is} is less than zero then the interaction is less likely to occur within the smaller geography than in the larger geography. Note: the exponentiation of each \emph{LEx/Is} metric results in the odds ratio of the specific exposure or isolation of interest in a smaller geography relative to the larger geography. +#' +#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{LEx/Is} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{LEx/Is} 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{LEx/Is} computation. #' -#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the *LEx/Is* value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the *LEx/Is* computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the *LEx/Is* computation. -#' #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{lexis}}{An object of class 'tbl' for the GEOID, name, and *LEx/Is* at specified smaller census geographies.} +#' \item{\code{lexis}}{An object of class 'tbl' for the GEOID, name, and \emph{LEx/Is} at specified smaller census geographies.} #' \item{\code{lexis_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 *LEx/Is*.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute \emph{LEx/Is}.} #' } #' #' @import dplyr @@ -59,7 +59,7 @@ #' @importFrom stats complete.cases #' @importFrom tidycensus get_acs #' @importFrom tidyr pivot_longer separate -#' @importFrom tigris core_based_statistical_areas +#' @importFrom tigris combined_statistical_areas core_based_statistical_areas metro_divisions #' @importFrom utils stack #' @export #' @@ -92,7 +92,7 @@ bemanian_beyer <- function(geo_large = 'county', ...) { # Check arguments - match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa')) + match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa', 'csa', 'metro')) match.arg(geo_small, choices = c('county', 'tract', 'block group')) stopifnot(is.numeric(year), year >= 2009) # all variables available 2009 onward match.arg( @@ -244,7 +244,7 @@ bemanian_beyer <- function(geo_large = 'county', lexis_data <- lexis_data %>% dplyr::mutate( oid = lapply(win_cbsa, function(x) { - tmp <- dat_cbsa[x, 2] %>% sf::st_drop_geometry() + tmp <- dat_cbsa[x, 3] %>% sf::st_drop_geometry() lapply(tmp, function(x) { if (length(x) == 0) NA else x }) }) %>% unlist(), @@ -256,6 +256,44 @@ bemanian_beyer <- function(geo_large = 'county', ) %>% sf::st_drop_geometry() } + if (geo_large == 'csa') { + stopifnot(is.numeric(year), year >= 2011) # CSAs only available 2011 onward + dat_csa <- suppressMessages(suppressWarnings(tigris::combined_statistical_areas(year = year))) + win_csa <- sf::st_within(lexis_data, dat_csa) + lexis_data <- lexis_data %>% + dplyr::mutate( + oid = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 2] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + csa = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 3] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } + if (geo_large == 'metro') { + stopifnot(is.numeric(year), year >= 2011) # Metro Divisions only available 2011 onward + dat_metro <- suppressMessages(suppressWarnings(tigris::metro_divisions(year = year))) + win_metro <- sf::st_within(lexis_data, dat_metro) + lexis_data <- lexis_data %>% + dplyr::mutate( + oid = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 4] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + metro = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 5] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } # Count of racial/ethnic subgroup populations ## Count of racial/ethnic comparison subgroup population @@ -341,6 +379,18 @@ bemanian_beyer <- function(geo_large = 'county', dplyr::left_join(lexis, ., by = dplyr::join_by(GEOID)) %>% dplyr::relocate(cbsa, .after = county) } + if (geo_large == 'csa') { + lexis <- lexis_data %>% + dplyr::select(GEOID, csa) %>% + dplyr::left_join(lexis, ., by = dplyr::join_by(GEOID)) %>% + dplyr::relocate(csa, .after = county) + } + if (geo_large == 'metro') { + lexis <- lexis_data %>% + dplyr::select(GEOID, metro) %>% + dplyr::left_join(lexis, ., by = dplyr::join_by(GEOID)) %>% + dplyr::relocate(metro, .after = county) + } lexis <- lexis %>% unique(.) %>% diff --git a/R/bravo.R b/R/bravo.R index f74febf..b2b9cd2 100644 --- a/R/bravo.R +++ b/R/bravo.R @@ -8,27 +8,27 @@ #' @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 spatial Educational Isolation Index (*EI*) of U.S. census tracts or counties for a specified geographical extent (e.g., the entire U.S. or a single state) based on Bravo et al. (2021) \doi{10.3390/ijerph18179384} who originally designed the metric for the educational isolation of individual without a college degree. This function provides the computation of *EI* for any of the U.S. Census Bureau educational attainment levels. +#' @details This function will compute the spatial Educational Isolation Index (\emph{EI}) of U.S. census tracts or counties for a specified geographical extent (e.g., the entire U.S. or a single state) based on Bravo et al. (2021) \doi{10.3390/ijerph18179384} who originally designed the metric for the educational isolation of individual without a college degree. This function provides the computation of \emph{EI} for any of the U.S. Census Bureau educational attainment levels. #' #' The function uses the \code{\link[tidycensus]{get_acs}} to obtain U.S. Census Bureau 5-year American Community Survey characteristics used for the geospatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available but are available from other U.S. Census Bureau surveys. The five educational attainment levels (U.S. Census Bureau definitions) are: #' \itemize{ -#' \item **B06009_002**: Less than high school graduate \code{'LtHS'} -#' \item **B06009_003**: High school graduate (includes equivalency) \code{'HSGiE'} -#' \item **B06009_004**: Some college or associate's degree \code{'SCoAD'} -#' \item **B06009_005**: Bachelor's degree \code{'BD'} -#' \item **B06009_006**: Graduate or professional degree \code{'GoPD'} +#' \item \strong{B06009_002}: Less than high school graduate \code{'LtHS'} +#' \item \strong{B06009_003}: High school graduate (includes equivalency) \code{'HSGiE'} +#' \item \strong{B06009_004}: Some college or associate's degree \code{'SCoAD'} +#' \item \strong{B06009_005}: Bachelor's degree \code{'BD'} +#' \item \strong{B06009_006}: Graduate or professional degree \code{'GoPD'} #' } -#' Note: If \code{year = 2009}, then the ACS-5 data (2005-2009) are from the **B15002** question. +#' Note: If \code{year = 2009}, then the ACS-5 data (2005-2009) are from the \strong{B15002} question. #' -#' 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. NOTE: Current version does not correct for edge effects (e.g., census geographies along the specified spatial extent border, coastline, or U.S.-Mexico / U.S.-Canada border) may have few neighboring census geographies, and *EI* values in these census geographies may be unstable. A stop-gap solution for the former source of edge effect is to compute the *EI* for neighboring census geographies (i.e., the states bordering a study area of interest) and then use the estimates of the study area of interest. +#' 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. NOTE: Current version does not correct for edge effects (e.g., census geographies along the specified spatial extent border, coastline, or U.S.-Mexico / U.S.-Canada border) may have few neighboring census geographies, and \emph{EI} values in these census geographies may be unstable. A stop-gap solution for the former source of edge effect is to compute the \emph{EI} for neighboring census geographies (i.e., the states bordering a study area of interest) and then use the estimates of the study area of interest. #' -#' A census geography (and its neighbors) that has nearly all of its population with the specified educational attainment category (e.g., a Bachelor's degree or more) will have an *EI* value close to 1. In contrast, a census geography (and its neighbors) that is nearly none of its population with the specified educational attainment category (e.g., less than a Bachelor's degree) will have an *EI* value close to 0. +#' A census geography (and its neighbors) that has nearly all of its population with the specified educational attainment category (e.g., a Bachelor's degree or more) will have an \emph{EI} value close to 1. In contrast, a census geography (and its neighbors) that is nearly none of its population with the specified educational attainment category (e.g., less than a Bachelor's degree) will have an \emph{EI} value close to 0. #' #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{ei}}{An object of class 'tbl' for the GEOID, name, *EI*, and raw census values of specified census geographies.} -#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute *EI*.} +#' \item{\code{ei}}{An object of class 'tbl' for the GEOID, name, \emph{EI}, and raw census values of specified 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{EI}.} #' } #' #' @import dplyr diff --git a/R/duncan.R b/R/duncan.R index 6ce71e0..9f68b3a 100644 --- a/R/duncan.R +++ b/R/duncan.R @@ -11,44 +11,44 @@ #' @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 Dissimilarity Index (*DI*) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Duncan & Duncan (1955) \doi{10.2307/2088328}. This function provides the computation of *DI* for any of the U.S. Census Bureau race/ethnicity subgroups (including Hispanic and non-Hispanic individuals). +#' @details This function will compute the aspatial Dissimilarity Index (\emph{DI}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Duncan & Duncan (1955) \doi{10.2307/2088328}. This function provides the computation of \emph{DI} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +#' 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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: #' \itemize{ -#' \item **B03002_002**: not Hispanic or Latino \code{'NHoL'} -#' \item **B03002_003**: not Hispanic or Latino, white alone \code{'NHoLW'} -#' \item **B03002_004**: not Hispanic or Latino, Black or African American alone \code{'NHoLB'} -#' \item **B03002_005**: not Hispanic or Latino, American Indian and Alaska Native alone \code{'NHoLAIAN'} -#' \item **B03002_006**: not Hispanic or Latino, Asian alone \code{'NHoLA'} -#' \item **B03002_007**: not Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'NHoLNHOPI'} -#' \item **B03002_008**: not Hispanic or Latino, Some other race alone \code{'NHoLSOR'} -#' \item **B03002_009**: not Hispanic or Latino, Two or more races \code{'NHoLTOMR'} -#' \item **B03002_010**: not Hispanic or Latino, Two races including Some other race \code{'NHoLTRiSOR'} -#' \item **B03002_011**: not Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'NHoLTReSOR'} -#' \item **B03002_012**: Hispanic or Latino \code{'HoL'} -#' \item **B03002_013**: Hispanic or Latino, white alone \code{'HoLW'} -#' \item **B03002_014**: Hispanic or Latino, Black or African American alone \code{'HoLB'} -#' \item **B03002_015**: Hispanic or Latino, American Indian and Alaska Native alone \code{'HoLAIAN'} -#' \item **B03002_016**: Hispanic or Latino, Asian alone \code{'HoLA'} -#' \item **B03002_017**: Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'HoLNHOPI'} -#' \item **B03002_018**: Hispanic or Latino, Some other race alone \code{'HoLSOR'} -#' \item **B03002_019**: Hispanic or Latino, Two or more races \code{'HoLTOMR'} -#' \item **B03002_020**: Hispanic or Latino, Two races including Some other race \code{'HoLTRiSOR'} -#' \item **B03002_021**: Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'HoLTReSOR'} +#' \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. #' -#' *DI* is a measure of the evenness of racial/ethnic residential segregation when comparing smaller geographical areas to larger ones within which the smaller geographical areas are located. *DI* can range in value from 0 to 1 and represents the proportion of racial/ethnic subgroup members that would have to change their area of residence to achieve an even distribution within the larger geographical area under conditions of maximum segregation. +#' \emph{DI} is a measure of the evenness of racial/ethnic residential segregation when comparing smaller geographical areas to larger ones within which the smaller geographical areas are located. \emph{DI} can range in value from 0 to 1 and represents the proportion of racial/ethnic subgroup members that would have to change their area of residence to achieve an even distribution within the larger geographical area under conditions of maximum segregation. #' -#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the *DI* value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the *DI* computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the *DI* computation. +#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{DI} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{DI} 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{DI} computation. #' #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{di}}{An object of class 'tbl' for the GEOID, name, and *DI* at specified larger census geographies.} +#' \item{\code{di}}{An object of class 'tbl' for the GEOID, name, and \emph{DI} at specified larger census geographies.} #' \item{\code{di_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 *DI*.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute \emph{DI}.} #' } #' #' @import dplyr @@ -56,7 +56,7 @@ #' @importFrom stats complete.cases #' @importFrom tidycensus get_acs #' @importFrom tidyr pivot_longer separate -#' @importFrom tigris core_based_statistical_areas +#' @importFrom tigris combined_statistical_areas core_based_statistical_areas metro_divisions #' @importFrom utils stack #' @export #' @@ -89,7 +89,7 @@ duncan <- function(geo_large = 'county', ...) { # Check arguments - match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa')) + match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa', 'csa', 'metro')) match.arg(geo_small, choices = c('county', 'tract', 'block group')) stopifnot(is.numeric(year), year >= 2009) # all variables available 2009 onward match.arg( @@ -240,7 +240,7 @@ duncan <- function(geo_large = 'county', di_data <- di_data %>% dplyr::mutate( oid = lapply(win_cbsa, function(x) { - tmp <- dat_cbsa[x, 2] %>% sf::st_drop_geometry() + tmp <- dat_cbsa[x, 3] %>% sf::st_drop_geometry() lapply(tmp, function(x) { if (length(x) == 0) NA else x }) }) %>% unlist(), @@ -252,6 +252,44 @@ duncan <- function(geo_large = 'county', ) %>% sf::st_drop_geometry() } + if (geo_large == 'csa') { + stopifnot(is.numeric(year), year >= 2011) # CSAs only available 2011 onward + dat_csa <- suppressMessages(suppressWarnings(tigris::combined_statistical_areas(year = year))) + win_csa <- sf::st_within(di_data, dat_csa) + di_data <- di_data %>% + dplyr::mutate( + oid = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 2] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + csa = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 3] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } + if (geo_large == 'metro') { + stopifnot(is.numeric(year), year >= 2011) # Metro Divisions only available 2011 onward + dat_metro <- suppressMessages(suppressWarnings(tigris::metro_divisions(year = year))) + win_metro <- sf::st_within(di_data, dat_metro) + di_data <- di_data %>% + dplyr::mutate( + oid = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 4] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + metro = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 5] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } # Count of racial/ethnic subgroup populations ## Count of racial/ethnic comparison subgroup population @@ -353,6 +391,26 @@ duncan <- function(geo_large = 'county', .[.$GEOID != 'NANA', ] %>% dplyr::distinct(GEOID, .keep_all = TRUE) } + if (geo_large == 'csa') { + di <- di_data %>% + dplyr::left_join(DItmp, by = dplyr::join_by(oid)) %>% + dplyr::select(oid, csa, DI) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, csa, DI) %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::distinct(GEOID, .keep_all = TRUE) + } + if (geo_large == 'metro') { + di <- di_data %>% + dplyr::left_join(DItmp, by = dplyr::join_by(oid)) %>% + dplyr::select(oid, metro, DI) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, metro, DI) %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::distinct(GEOID, .keep_all = TRUE) + } di <- di %>% dplyr::arrange(GEOID) %>% diff --git a/R/gini.R b/R/gini.R index 09da8a2..8f3c1d4 100644 --- a/R/gini.R +++ b/R/gini.R @@ -7,9 +7,9 @@ #' @param quiet Logical. If TRUE, will display messages about potential missing census information #' @param ... Arguments passed to \code{\link[tidycensus]{get_acs}} to select state, county, and other arguments for census characteristics #' -#' @details This function will retrieve the aspatial Gini Index of U.S. census tracts or counties for a specified geographical extent (e.g., the entire U.S. or a single state) based on Gini (1921) \doi{10.2307/2223319}. +#' @details This function will retrieve the aspatial Gini Index (\emph{G}) of U.S. census tracts or counties for a specified geographical extent (e.g., the entire U.S. or a single state) based on Gini (1921) \doi{10.2307/2223319}. #' -#' The function uses the \code{\link[tidycensus]{get_acs}} function to obtain U.S. Census Bureau 5-year American Community Survey estimates of the Gini Index for income inequality (ACS: B19083). The estimates are available for 2009 onward when ACS-5 data are available but are available from other U.S. Census Bureau surveys. +#' The function uses the \code{\link[tidycensus]{get_acs}} function to obtain U.S. Census Bureau 5-year American Community Survey estimates of \emph{G} for income inequality (ACS: B19083). The estimates are available for 2009 onward when ACS-5 data are available but are available from other U.S. Census Bureau surveys. #' #' 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. #' @@ -18,8 +18,8 @@ #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{gini}}{An object of class 'tbl' for the GEOID, name, and Gini index of specified census geographies.} -#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for the Gini index.} +#' \item{\code{gini}}{An object of class 'tbl' for the GEOID, name, and \emph{G} of specified census geographies.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for \emph{G}.} #' } #' #' @import dplyr diff --git a/R/globals.R b/R/globals.R index f381fe1..78f646a 100644 --- a/R/globals.R +++ b/R/globals.R @@ -119,6 +119,8 @@ globalVariables( 'COUNTYFP', 'TRACTCE', 'cbsa', + 'csa', + 'metro', 'val', 'variable', 'giniE', diff --git a/R/hoover.R b/R/hoover.R index 5538f78..8b45050 100644 --- a/R/hoover.R +++ b/R/hoover.R @@ -10,44 +10,44 @@ #' @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 Delta (*DEL*) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Hoover (1941) \doi{10.1017/S0022050700052980} and Duncan, Cuzzort, and Duncan (1961; LC:60007089). This function provides the computation of *DEL* for any of the U.S. Census Bureau race/ethnicity subgroups (including Hispanic and non-Hispanic individuals). +#' @details This function will compute the aspatial Delta (\emph{DEL}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Hoover (1941) \doi{10.1017/S0022050700052980} and Duncan, Cuzzort, and Duncan (1961; LC:60007089). This function provides the computation of \emph{DEL} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +#' 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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: #' \itemize{ -#' \item **B03002_002**: not Hispanic or Latino \code{'NHoL'} -#' \item **B03002_003**: not Hispanic or Latino, white alone \code{'NHoLW'} -#' \item **B03002_004**: not Hispanic or Latino, Black or African American alone \code{'NHoLB'} -#' \item **B03002_005**: not Hispanic or Latino, American Indian and Alaska Native alone \code{'NHoLAIAN'} -#' \item **B03002_006**: not Hispanic or Latino, Asian alone \code{'NHoLA'} -#' \item **B03002_007**: not Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'NHoLNHOPI'} -#' \item **B03002_008**: not Hispanic or Latino, Some other race alone \code{'NHoLSOR'} -#' \item **B03002_009**: not Hispanic or Latino, Two or more races \code{'NHoLTOMR'} -#' \item **B03002_010**: not Hispanic or Latino, Two races including Some other race \code{'NHoLTRiSOR'} -#' \item **B03002_011**: not Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'NHoLTReSOR'} -#' \item **B03002_012**: Hispanic or Latino \code{'HoL'} -#' \item **B03002_013**: Hispanic or Latino, white alone \code{'HoLW'} -#' \item **B03002_014**: Hispanic or Latino, Black or African American alone \code{'HoLB'} -#' \item **B03002_015**: Hispanic or Latino, American Indian and Alaska Native alone \code{'HoLAIAN'} -#' \item **B03002_016**: Hispanic or Latino, Asian alone \code{'HoLA'} -#' \item **B03002_017**: Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'HoLNHOPI'} -#' \item **B03002_018**: Hispanic or Latino, Some other race alone \code{'HoLSOR'} -#' \item **B03002_019**: Hispanic or Latino, Two or more races \code{'HoLTOMR'} -#' \item **B03002_020**: Hispanic or Latino, Two races including Some other race \code{'HoLTRiSOR'} -#' \item **B03002_021**: Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'HoLTReSOR'} +#' \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. #' -#' *DEL* is a measure of the proportion of members of one subgroup(s) residing in geographic units with above average density of members of the subgroup(s). The index provides the proportion of a subgroup population that would have to move across geographic units to achieve a uniform density. *DEL* can range in value from 0 to 1. +#' \emph{DEL} is a measure of the proportion of members of one subgroup(s) residing in geographic units with above average density of members of the subgroup(s). The index provides the proportion of a subgroup population that would have to move across geographic units to achieve a uniform density. \emph{DEL} can range in value from 0 to 1. #' -#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the *DEL* value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the *DEL* computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the *DEL* computation. +#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{DEL} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{DEL} 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{DEL} computation. #' #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{del}}{An object of class 'tbl' for the GEOID, name, and *DEL* at specified larger census geographies.} +#' \item{\code{del}}{An object of class 'tbl' for the GEOID, name, and \emph{DEL} at specified larger census geographies.} #' \item{\code{del_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 *DEL*.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute \emph{DEL}.} #' } #' #' @import dplyr @@ -55,7 +55,7 @@ #' @importFrom stats complete.cases #' @importFrom tidycensus get_acs #' @importFrom tidyr pivot_longer separate -#' @importFrom tigris core_based_statistical_areas +#' @importFrom tigris combined_statistical_areas core_based_statistical_areas metro_divisions #' @importFrom utils stack #' @export #' @@ -86,7 +86,7 @@ hoover <- function(geo_large = 'county', ...) { # Check arguments - match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa')) + match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa', 'csa', 'metro')) match.arg(geo_small, choices = c('county', 'tract', 'block group')) stopifnot(is.numeric(year), year >= 2009) # all variables available 2009 onward match.arg( @@ -210,7 +210,7 @@ hoover <- function(geo_large = 'county', del_data <- del_data %>% dplyr::mutate( oid = lapply(win_cbsa, function(x) { - tmp <- dat_cbsa[x, 2] %>% sf::st_drop_geometry() + tmp <- dat_cbsa[x, 3] %>% sf::st_drop_geometry() lapply(tmp, function(x) { if (length(x) == 0) NA else x }) }) %>% unlist(), @@ -222,6 +222,44 @@ hoover <- function(geo_large = 'county', ) %>% sf::st_drop_geometry() } + if (geo_large == 'csa') { + stopifnot(is.numeric(year), year >= 2011) # CSAs only available 2011 onward + dat_csa <- suppressMessages(suppressWarnings(tigris::combined_statistical_areas(year = year))) + win_csa <- sf::st_within(del_data, dat_csa) + del_data <- del_data %>% + dplyr::mutate( + oid = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 2] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + csa = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 3] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } + if (geo_large == 'metro') { + stopifnot(is.numeric(year), year >= 2011) # Metro Divisions only available 2011 onward + dat_metro <- suppressMessages(suppressWarnings(tigris::metro_divisions(year = year))) + win_metro <- sf::st_within(del_data, dat_metro) + del_data <- del_data %>% + dplyr::mutate( + oid = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 4] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + metro = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 5] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } # Count of racial/ethnic subgroup populations ## Count of racial/ethnic comparison subgroup population @@ -305,7 +343,30 @@ hoover <- function(geo_large = 'county', dplyr::mutate(GEOID = oid) %>% dplyr::select(GEOID, cbsa, DEL) %>% .[.$GEOID != 'NANA', ] %>% - dplyr::distinct(GEOID, .keep_all = TRUE) + dplyr::distinct(GEOID, .keep_all = TRUE) %>% + dplyr::filter(complete.cases(.)) + } + if (geo_large == 'csa') { + del <- del_data %>% + dplyr::left_join(DELtmp, by = dplyr::join_by(oid)) %>% + dplyr::select(oid, csa, DEL) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, csa, DEL) %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::distinct(GEOID, .keep_all = TRUE) %>% + dplyr::filter(complete.cases(.)) + } + if (geo_large == 'metro') { + del <- del_data %>% + dplyr::left_join(DELtmp, by = dplyr::join_by(oid)) %>% + dplyr::select(oid, metro, DEL) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, metro, DEL) %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::distinct(GEOID, .keep_all = TRUE) %>% + dplyr::filter(complete.cases(.)) } del <- del %>% diff --git a/R/krieger.R b/R/krieger.R index d9575c6..cc104eb 100644 --- a/R/krieger.R +++ b/R/krieger.R @@ -7,34 +7,34 @@ #' @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 three aspatial Index of Concentration at the Extremes (*ICE*) of U.S. census tracts or counties for a specified geographical extent (e.g., entire U.S. or a single state) based on Feldman et al. (2015) \doi{10.1136/jech-2015-205728} and Krieger et al. (2016) \doi{10.2105/AJPH.2015.302955}. The authors expanded the metric designed by Massey in a chapter of Booth & Crouter (2001) \doi{10.4324/9781410600141} who initially designed the metric for residential segregation. This function computes five *ICE* metrics: +#' @details This function will compute three aspatial Index of Concentration at the Extremes (\emph{ICE}) of U.S. census tracts or counties for a specified geographical extent (e.g., entire U.S. or a single state) based on Feldman et al. (2015) \doi{10.1136/jech-2015-205728} and Krieger et al. (2016) \doi{10.2105/AJPH.2015.302955}. The authors expanded the metric designed by Massey in a chapter of Booth & Crouter (2001) \doi{10.4324/9781410600141} who initially designed the metric for residential segregation. This function computes five \emph{ICE} metrics: #' #' \itemize{ -#' \item **Income**: 80th income percentile vs. 20th income percentile -#' \item **Education**: less than high school vs. four-year college degree or more -#' \item **Race/Ethnicity**: white non-Hispanic vs. black non-Hispanic -#' \item **Income and race/ethnicity combined**: white non-Hispanic in 80th income percentile vs. black alone (including Hispanic) in 20th income percentile -#' \item **Income and race/ethnicity combined**: white non-Hispanic in 80th income percentile vs. white non-Hispanic in 20th income percentile +#' \item \strong{Income}: 80th income percentile vs. 20th income percentile +#' \item \strong{Education}: less than high school vs. four-year college degree or more +#' \item \strong{Race/Ethnicity}: white non-Hispanic vs. black non-Hispanic +#' \item \strong{Income and race/ethnicity combined}: white non-Hispanic in 80th income percentile vs. black alone (including Hispanic) in 20th income percentile +#' \item \strong{Income and race/ethnicity combined}: white non-Hispanic in 80th income percentile vs. white non-Hispanic in 20th income percentile #' } #' -#' 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 geospatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available but are available from other U.S. Census Bureau surveys. The ACS-5 groups used in the computation of the five *ICE* metrics are: +#' 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 geospatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available but are available from other U.S. Census Bureau surveys. The ACS-5 groups used in the computation of the five \emph{ICE} metrics are: #' \itemize{ -#' \item **B03002**: HISPANIC OR LATINO ORIGIN BY RACE -#' \item **B15002**: SEX BY EDUCATIONAL ATTAINMENT FOR THE POPULATION 25 YEARS AND OVER -#' \item **B19001**: HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 20XX INFLATION-ADJUSTED DOLLARS) -#' \item **B19001B**: HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 20XX INFLATION-ADJUSTED DOLLARS) (BLACK OR AFRICAN AMERICAN ALONE HOUSEHOLDER) -#' \item **B19001H**: HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 20XX INFLATION-ADJUSTED DOLLARS) (WHITE ALONE, NOT HISPANIC OR LATINO HOUSEHOLDER) +#' \item \strong{B03002}: HISPANIC OR LATINO ORIGIN BY RACE +#' \item \strong{B15002}: SEX BY EDUCATIONAL ATTAINMENT FOR THE POPULATION 25 YEARS AND OVER +#' \item \strong{B19001}: HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 20XX INFLATION-ADJUSTED DOLLARS) +#' \item \strong{B19001B}: HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 20XX INFLATION-ADJUSTED DOLLARS) (BLACK OR AFRICAN AMERICAN ALONE HOUSEHOLDER) +#' \item \strong{B19001H}: HOUSEHOLD INCOME IN THE PAST 12 MONTHS (IN 20XX INFLATION-ADJUSTED DOLLARS) (WHITE ALONE, NOT HISPANIC OR LATINO HOUSEHOLDER) #' } #' #' 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. #' -#' *ICE* metrics can range in value from -1 (most deprived) to 1 (most privileged). A value of 0 can thus represent two possibilities: (1) none of the residents are in the most privileged or most deprived categories, or (2) an equal number of persons are in the most privileged and most deprived categories, and in both cases indicates that the area is not dominated by extreme concentrations of either of the two groups. +#' \emph{ICE} metrics can range in value from -1 (most deprived) to 1 (most privileged). A value of 0 can thus represent two possibilities: (1) none of the residents are in the most privileged or most deprived categories, or (2) an equal number of persons are in the most privileged and most deprived categories, and in both cases indicates that the area is not dominated by extreme concentrations of either of the two groups. #' #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{ice}}{An object of class 'tbl' for the GEOID, name, *ICE* metrics, and raw census values of specified census geographies.} -#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute the *ICE* metrics.} +#' \item{\code{ice}}{An object of class 'tbl' for the GEOID, name, \emph{ICE} metrics, and raw census values of specified census geographies.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute the \emph{ICE} metrics.} #' } #' #' @import dplyr diff --git a/R/messer.R b/R/messer.R index 05ed4fa..4ecc470 100644 --- a/R/messer.R +++ b/R/messer.R @@ -6,28 +6,28 @@ #' @param year Numeric. The year to compute the estimate. The default is 2020, and the years 2010 onward are currently available. #' @param imp Logical. If TRUE, will impute missing census characteristics within the internal \code{\link[psych]{principal}}. If FALSE (the default), will not impute. #' @param quiet Logical. If TRUE, will display messages about potential missing census information and the proportion of variance explained by principal component analysis. The default is FALSE. -#' @param round_output Logical. If TRUE, will round the output of raw census and *NDI* values from the \code{\link[tidycensus]{get_acs}} at one and four significant digits, respectively. The default is FALSE. +#' @param round_output Logical. If TRUE, will round the output of raw census and \emph{NDI} values from the \code{\link[tidycensus]{get_acs}} at one and four significant digits, respectively. The default is FALSE. #' @param df Optional. Pass a pre-formatted \code{'dataframe'} or \code{'tibble'} with the desired variables through the function. Bypasses the data obtained by \code{\link[tidycensus]{get_acs}}. The default is NULL. See Details below. #' @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 Neighborhood Deprivation Index (*NDI*) of U.S. census tracts or counties for a specified geographical referent (e.g., US-standardized) based on Messer et al. (2006) \doi{10.1007/s11524-006-9094-x}. +#' @details This function will compute the aspatial Neighborhood Deprivation Index (\emph{NDI}) of U.S. census tracts or counties for a specified geographical referent (e.g., US-standardized) based on Messer et al. (2006) \doi{10.1007/s11524-006-9094-x}. #' #' The function uses the \code{\link[tidycensus]{get_acs}} function to obtain U.S. Census Bureau 5-year American Community Survey characteristics used for computation involving a principal component analysis with the \code{\link[psych]{principal}} function. The yearly estimates are available for 2010 and after when all census characteristics became available. The eight characteristics are: #' \itemize{ -#' \item **OCC (C24030)**: percent males in management, science, and arts occupation -#' \item **CWD (B25014)**: percent of crowded housing -#' \item **POV (B17017)**: percent of households in poverty -#' \item **FHH (B25115)**: percent of female headed households with dependents -#' \item **PUB (B19058)**: percent of households on public assistance -#' \item **U30 (B19001)**: percent of households earning <$30,000 per year -#' \item **EDU (B06009)**: percent earning less than a high school education -#' \item **EMP (B23025)**: percent unemployed (2011 onward) -#' \item **EMP (B23001)**: percent unemployed (2010 only) +#' \item \strong{OCC (C24030)}: percent males in management, science, and arts occupation +#' \item \strong{CWD (B25014)}: percent of crowded housing +#' \item \strong{POV (B17017)}: percent of households in poverty +#' \item \strong{FHH (B25115)}: percent of female headed households with dependents +#' \item \strong{PUB (B19058)}: percent of households on public assistance +#' \item \strong{U30 (B19001)}: percent of households earning <$30,000 per year +#' \item \strong{EDU (B06009)}: percent earning less than a high school education +#' \item \strong{EMP (B23025)}: percent unemployed (2011 onward) +#' \item \strong{EMP (B23001)}: percent unemployed (2010 only) #' } #' -#' Use the internal \code{state} and \code{county} arguments within the \code{\link[tidycensus]{get_acs}} function to specify the referent for standardizing the *NDI* (Messer) values. For example, if all U.S. states are specified for the \code{state} argument, then the output would be a U.S.-standardized index. +#' Use the internal \code{state} and \code{county} arguments within the \code{\link[tidycensus]{get_acs}} function to specify the referent for standardizing the \emph{NDI} (Messer) values. For example, if all U.S. states are specified for the \code{state} argument, then the output would be a U.S.-standardized index. #' -#' The continuous *NDI* (Messer) values are z-transformed, i.e., 'standardized,' and the categorical *NDI* (Messer) values are quartiles of the standardized continuous *NDI* (Messer) values. +#' The continuous \emph{NDI} (Messer) values are z-transformed, i.e., 'standardized,' and the categorical \emph{NDI} (Messer) values are quartiles of the standardized continuous \emph{NDI} (Messer) values. #' #' Check if the proportion of variance explained by the first principal component is high (more than 0.5). #' @@ -36,9 +36,9 @@ #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{ndi}}{An object of class 'tbl' for the GEOID, name, *NDI* (standardized), *NDI* (quartile), and raw census values of specified census geographies.} -#' \item{\code{pca}}{An object of class 'principal', returns the output of \code{\link[psych]{principal}} used to compute the *NDI* values.} -#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute *NDI*.} +#' \item{\code{ndi}}{An object of class 'tbl' for the GEOID, name, \emph{NDI} (standardized), \emph{NDI} (quartile), and raw census values of specified census geographies.} +#' \item{\code{pca}}{An object of class 'principal', returns the output of \code{\link[psych]{principal}} used to compute the \emph{NDI} values.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute \emph{NDI}.} #' } #' #' @import dplyr diff --git a/R/ndi-package.R b/R/ndi-package.R index 65c67f6..b4388c7 100644 --- a/R/ndi-package.R +++ b/R/ndi-package.R @@ -2,37 +2,37 @@ #' #' Computes various metrics of socio-economic deprivation and disparity in the United States based on information available from the U.S. Census Bureau. #' -#' @details The 'ndi' package computes various metrics of socio-economic deprivation and disparity in the United States. Some metrics are considered "spatial" because they consider the values of neighboring (i.e., adjacent) census geographies in their computation, while other metrics are "aspatial" because they only consider the value within each census geography. Two types of aspatial neighborhood deprivation indices (NDI) are available: (1) based on Messer et al. (2006) \doi{10.1007/s11524-006-9094-x} and (2) based on Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} who use variables chosen by Roux and Mair (2010) \doi{10.1111/j.1749-6632.2009.05333.x}. Both are a decomposition of multiple demographic characteristics from the U.S. Census Bureau American Community Survey 5-year estimates (ACS-5; 2006-2010 onward). Using data from the ACS-5 (2005-2009 onward), the package can also compute the (1) spatial Racial Isolation Index (RI) based on Anthopolos et al. (2011) \doi{10.1016/j.sste.2011.06.002}, (2) spatial Educational Isolation Index (EI) based on Bravo et al. (2021) \doi{10.3390/ijerph18179384}, (3) aspatial Index of Concentration at the Extremes (ICE) based on Feldman et al. (2015) \doi{10.1136/jech-2015-205728} and Krieger et al. (2016) \doi{10.2105/AJPH.2015.302955}, (4) aspatial racial/ethnic Dissimilarity Index based on Duncan & Duncan (1955) \doi{10.2307/2088328}, (5) aspatial income or racial/ethnic Atkinson Index based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}, (6) aspatial racial/ethnic Isolation Index (II) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}, (7) aspatial racial/ethnic Correlation Ratio based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}, (8) aspatial racial/ethnic Location Quotient (LQ) based on Merton (1939) \doi{10.2307/2084686} and Sudano et al. (2013) \doi{10.1016/j.healthplace.2012.09.015}, (9) aspatial racial/ethnic Local Exposure and Isolation metric based on Bemanian & Beyer (2017) , and (10) aspatial racial/ethnic Delta based on Hoover (1941) and Duncan et al. (1961; LC:60007089). Also using data from the ACS-5 (2005-2009 onward), the package can retrieve the aspatial Gini Index based on Gini (1921) \doi{10.2307/2223319}. +#' @details The 'ndi' package computes various metrics of socio-economic deprivation and disparity in the United States. Some metrics are considered "spatial" because they consider the values of neighboring (i.e., adjacent) census geographies in their computation, while other metrics are "aspatial" because they only consider the value within each census geography. Two types of aspatial neighborhood deprivation indices (\emph{NDI}) are available: (1) based on Messer et al. (2006) \doi{10.1007/s11524-006-9094-x} and (2) based on Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} who use variables chosen by Roux and Mair (2010) \doi{10.1111/j.1749-6632.2009.05333.x}. Both are a decomposition of multiple demographic characteristics from the U.S. Census Bureau American Community Survey 5-year estimates (ACS-5; 2006-2010 onward). Using data from the ACS-5 (2005-2009 onward), the package can also compute the (1) spatial Racial Isolation Index (\emph{RI}) based on Anthopolos et al. (2011) \doi{10.1016/j.sste.2011.06.002}, (2) spatial Educational Isolation Index (\emph{EI}) based on Bravo et al. (2021) \doi{10.3390/ijerph18179384}, (3) aspatial Index of Concentration at the Extremes (\emph{ICE}) based on Feldman et al. (2015) \doi{10.1136/jech-2015-205728} and Krieger et al. (2016) \doi{10.2105/AJPH.2015.302955}, (4) aspatial racial/ethnic Dissimilarity Index (\emph{DI}) based on Duncan & Duncan (1955) \doi{10.2307/2088328}, (5) aspatial income or racial/ethnic Atkinson Index (\emph{AI}) based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}, (6) aspatial racial/ethnic Isolation Index (\emph{II}) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}, (7) aspatial racial/ethnic Correlation Ratio (\emph{V}) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}, (8) aspatial racial/ethnic 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}, (9) aspatial racial/ethnic Local Exposure and Isolation (\emph{LEx/Is}) metric based on Bemanian & Beyer (2017) , and (10) aspatial racial/ethnic Delta (\emph{DEL}) based on Hoover (1941) and Duncan et al. (1961; LC:60007089). Also using data from the ACS-5 (2005-2009 onward), the package can retrieve the aspatial Gini Index (\emph{G}) based on Gini (1921) \doi{10.2307/2223319}. #' #' Key content of the 'ndi' package include:\cr #' #' \bold{Metrics of Socio-Economic Deprivation and Disparity} #' -#' \code{\link{anthopolos}} Computes the spatial Racial Isolation Index (RI) based on Anthopolos (2011) \doi{10.1016/j.sste.2011.06.002}. +#' \code{\link{anthopolos}} Computes the spatial Racial Isolation Index (\emph{RI}) based on Anthopolos (2011) \doi{10.1016/j.sste.2011.06.002}. #' -#' \code{\link{atkinson}} Computes the aspatial income or racial/ethnic Atkinson Index (AI) based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}. +#' \code{\link{atkinson}} Computes the aspatial income or racial/ethnic Atkinson Index (\emph{AI}) based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}. #' -#' \code{\link{bell}} Computes the aspatial racial/ethnic Isolation Index (II) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}. +#' \code{\link{bell}} Computes the aspatial racial/ethnic Isolation Index (\emph{II}) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}. #' -#' \code{\link{bemanian_beyer}} Computes the aspatial racial/ethnic Local Exposure and Isolation (LEx/Is) metric based on Bemanian & Beyer (2017) \doi{10.1158/1055-9965.EPI-16-0926}. +#' \code{\link{bemanian_beyer}} Computes the aspatial racial/ethnic Local Exposure and Isolation (\emph{LEx/Is}) metric based on Bemanian & Beyer (2017) \doi{10.1158/1055-9965.EPI-16-0926}. #' -#' \code{\link{bravo}} Computes the spatial Educational Isolation Index (EI) based on Bravo (2021) \doi{10.3390/ijerph18179384}. +#' \code{\link{bravo}} Computes the spatial Educational Isolation Index (\emph{EI}) based on Bravo (2021) \doi{10.3390/ijerph18179384}. #' -#' \code{\link{duncan}} Computes the aspatial racial/ethnic Dissimilarity Index (DI) based on Duncan & Duncan (1955) \doi{10.2307/2088328}. +#' \code{\link{duncan}} Computes the aspatial racial/ethnic Dissimilarity Index (\emph{DI}) based on Duncan & Duncan (1955) \doi{10.2307/2088328}. #' -#' \code{\link{gini}} Retrieves the aspatial Gini Index based on Gini (1921) \doi{10.2307/2223319}. +#' \code{\link{gini}} Retrieves the aspatial Gini Index (\emph{G}) based on Gini (1921) \doi{10.2307/2223319}. #' -#' \code{\link{hoover}} Computes the aspatial racial/ethnic Delta (DEL) based on Hoover (1941) \doi{doi:10.1017/S0022050700052980} and Duncan et al. (1961; LC:60007089). +#' \code{\link{hoover}} Computes the aspatial racial/ethnic Delta (\emph{DEL}) based on Hoover (1941) \doi{doi:10.1017/S0022050700052980} and Duncan et al. (1961; LC:60007089). #' #' \code{\link{krieger}} Computes the aspatial Index of Concentration at the Extremes based on Feldman et al. (2015) \doi{10.1136/jech-2015-205728} and Krieger et al. (2016) \doi{10.2105/AJPH.2015.302955}. #' -#' \code{\link{messer}} Computes the aspatial Neighborhood Deprivation Index (NDI) based on Messer et al. (2006) \doi{10.1007/s11524-006-9094-x}. +#' \code{\link{messer}} Computes the aspatial Neighborhood Deprivation Index (\emph{NDI}) based on Messer et al. (2006) \doi{10.1007/s11524-006-9094-x}. #' -#' \code{\link{powell_wiley}} Computes the aspatial Neighborhood Deprivation Index (NDI) based on Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} who use variables chosen by Roux and Mair (2010) \doi{10.1111/j.1749-6632.2009.05333.x}. +#' \code{\link{powell_wiley}} Computes the aspatial Neighborhood Deprivation Index (\emph{NDI}) based on Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} who use variables chosen by Roux and Mair (2010) \doi{10.1111/j.1749-6632.2009.05333.x}. #' -#' \code{\link{sudano}} Computes the aspatial racial/ethnic Location Quotient (LQ) based on Merton (1939) \doi{10.2307/2084686} and Sudano et al. (2013) \doi{10.1016/j.healthplace.2012.09.015}. +#' \code{\link{sudano}} Computes the aspatial racial/ethnic 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{white}} Computes the aspatial racial/ethnic Correlation Ratio (V) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}. +#' \code{\link{white}} Computes the aspatial racial/ethnic Correlation Ratio (\emph{V}) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}. #' #' \bold{Pre-formatted U.S. Census Data} #' @@ -60,6 +60,6 @@ #' @importFrom stringr str_trim #' @importFrom tidycensus get_acs #' @importFrom tidyr pivot_longer separate -#' @importFrom tigris core_based_statistical_areas +#' @importFrom tigris combined_statistical_areas core_based_statistical_areas metro_divisions #' @importFrom utils stack NULL diff --git a/R/powell_wiley.R b/R/powell_wiley.R index 6896c00..3c1fc48 100644 --- a/R/powell_wiley.R +++ b/R/powell_wiley.R @@ -6,32 +6,32 @@ #' @param year Numeric. The year to compute the estimate. The default is 2020, and the years 2010 onward are currently available. #' @param imp Logical. If TRUE, will impute missing census characteristics within the internal \code{\link[psych]{principal}} using median values of variables. If FALSE (the default), will not impute. #' @param quiet Logical. If TRUE, will display messages about potential missing census information, standardized Cronbach's alpha, and proportion of variance explained by principal component analysis. The default is FALSE. -#' @param round_output Logical. If TRUE, will round the output of raw census and *NDI* values from the \code{\link[tidycensus]{get_acs}} at one and four significant digits, respectively. The default is FALSE. +#' @param round_output Logical. If TRUE, will round the output of raw census and \emph{NDI} values from the \code{\link[tidycensus]{get_acs}} at one and four significant digits, respectively. The default is FALSE. #' @param df Optional. Pass a pre-formatted \code{'dataframe'} or \code{'tibble'} with the desired variables through the function. Bypasses the data obtained by \code{\link[tidycensus]{get_acs}}. The default is NULL. See Details below. #' @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 Neighborhood Deprivation Index (*NDI*) of U.S. census tracts or counties for a specified geographical referent (e.g., US-standardized) based on Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002}. +#' @details This function will compute the aspatial Neighborhood Deprivation Index (\emph{NDI}) of U.S. census tracts or counties for a specified geographical referent (e.g., US-standardized) based on Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002}. #' #' The function uses the \code{\link[tidycensus]{get_acs}} function to obtain U.S. Census Bureau 5-year American Community Survey characteristics used for computation involving a factor analysis with the \code{\link[psych]{principal}} function. The yearly estimates are available in 2010 and after when all census characteristics became available. The thirteen characteristics chosen by Roux and Mair (2010) \doi{10.1111/j.1749-6632.2009.05333.x} are: #' \itemize{ -#' \item **MedHHInc (B19013)**: median household income (dollars) -#' \item **PctRecvIDR (B19054)**: percent of households receiving dividends, interest, or rental income -#' \item **PctPubAsst (B19058)**: percent of households receiving public assistance -#' \item **MedHomeVal (B25077)**: median home value (dollars) -#' \item **PctMgmtBusScArti (C24060)**: percent in a management, business, science, or arts occupation -#' \item **PctFemHeadKids (B11005)**: percent of households that are female headed with any children under 18 years -#' \item **PctOwnerOcc (DP04)**: percent of housing units that are owner occupied -#' \item **PctNoPhone (DP04)**: percent of households without a telephone -#' \item **PctNComPlm (DP04)**: percent of households without complete plumbing facilities -#' \item **PctEducHSPlus (S1501)**: percent with a high school degree or higher (population 25 years and over) -#' \item **PctEducBchPlus (S1501)**: percent with a college degree or higher (population 25 years and over) -#' \item **PctFamBelowPov (S1702)**: percent of families with incomes below the poverty level -#' \item **PctUnempl (S2301)**: percent unemployed +#' \item \strong{MedHHInc (B19013)}: median household income (dollars) +#' \item \strong{PctRecvIDR (B19054)}: percent of households receiving dividends, interest, or rental income +#' \item \strong{PctPubAsst (B19058)}: percent of households receiving public assistance +#' \item \strong{MedHomeVal (B25077)}: median home value (dollars) +#' \item \strong{PctMgmtBusScArti (C24060)}: percent in a management, business, science, or arts occupation +#' \item \strong{PctFemHeadKids (B11005)}: percent of households that are female headed with any children under 18 years +#' \item \strong{PctOwnerOcc (DP04)}: percent of housing units that are owner occupied +#' \item \strong{PctNoPhone (DP04)}: percent of households without a telephone +#' \item \strong{PctNComPlm (DP04)}: percent of households without complete plumbing facilities +#' \item \strong{PctEducHSPlus (S1501)}: percent with a high school degree or higher (population 25 years and over) +#' \item \strong{PctEducBchPlus (S1501)}: percent with a college degree or higher (population 25 years and over) +#' \item \strong{PctFamBelowPov (S1702)}: percent of families with incomes below the poverty level +#' \item \strong{PctUnempl (S2301)}: percent unemployed #' } #' -#' Use the internal \code{state} and \code{county} arguments within the \code{\link[tidycensus]{get_acs}} function to specify the referent for standardizing the *NDI* (Powell-Wiley) values. For example, if all U.S. states are specified for the \code{state} argument, then the output would be a U.S.-standardized index. Please note: the *NDI* (Powell-Wiley) values will not exactly match (but will highly correlate with) those found in Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} because the two studies used a different statistical platform (i.e., SPSS and SAS, respectively) that intrinsically calculate the principal component analysis differently from R. +#' Use the internal \code{state} and \code{county} arguments within the \code{\link[tidycensus]{get_acs}} function to specify the referent for standardizing the \emph{NDI} (Powell-Wiley) values. For example, if all U.S. states are specified for the \code{state} argument, then the output would be a U.S.-standardized index. Please note: the \emph{NDI} (Powell-Wiley) values will not exactly match (but will highly correlate with) those found in Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} because the two studies used a different statistical platform (i.e., SPSS and SAS, respectively) that intrinsically calculate the principal component analysis differently from R. #' -#' The categorical *NDI* (Powell-Wiley) values are population-weighted quintiles of the continuous *NDI* (Powell-Wiley) values. +#' The categorical \emph{NDI} (Powell-Wiley) values are population-weighted quintiles of the continuous \emph{NDI} (Powell-Wiley) values. #' #' Check if the proportion of variance explained by the first principal component is high (more than 0.5). #' @@ -40,9 +40,9 @@ #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{ndi}}{An object of class 'tbl' for the GEOID, name, *NDI* continuous, *NDI* quintiles, and raw census values of specified census geographies.} -#' \item{\code{pca}}{An object of class 'principal', returns the output of \code{\link[psych]{principal}} used to compute the *NDI* values.} -#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute *NDI*.} +#' \item{\code{ndi}}{An object of class 'tbl' for the GEOID, name, \emph{NDI} continuous, \emph{NDI} quintiles, and raw census values of specified census geographies.} +#' \item{\code{pca}}{An object of class 'principal', returns the output of \code{\link[psych]{principal}} used to compute the \emph{NDI} values.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute \emph{NDI}.} #' \item{\code{cronbach}}{An object of class 'character' or 'numeric' for the results of the Cronbach's alpha calculation. If only one factor is computed, a message is returned. If more than one factor is computed, Cronbach's alpha is calculated and should check that it is >0.7 for respectable internal consistency between factors.} #' } #' diff --git a/R/sudano.R b/R/sudano.R index 63ccaa6..959fad6 100644 --- a/R/sudano.R +++ b/R/sudano.R @@ -10,44 +10,44 @@ #' @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 Location Quotient (*LQ*) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Merton (1939) \doi{10.2307/2084686} and Sudano et al. (2013) \doi{10.1016/j.healthplace.2012.09.015}. This function provides the computation of *LQ* for any of the U.S. Census Bureau race/ethnicity subgroups (including Hispanic and non-Hispanic individuals). +#' @details This function will compute the aspatial Location Quotient (\emph{LQ}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Merton (1939) \doi{10.2307/2084686} and Sudano et al. (2013) \doi{10.1016/j.healthplace.2012.09.015}. This function provides the computation of \emph{LQ} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +#' 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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: #' \itemize{ -#' \item **B03002_002**: not Hispanic or Latino \code{'NHoL'} -#' \item **B03002_003**: not Hispanic or Latino, white alone \code{'NHoLW'} -#' \item **B03002_004**: not Hispanic or Latino, Black or African American alone \code{'NHoLB'} -#' \item **B03002_005**: not Hispanic or Latino, American Indian and Alaska Native alone \code{'NHoLAIAN'} -#' \item **B03002_006**: not Hispanic or Latino, Asian alone \code{'NHoLA'} -#' \item **B03002_007**: not Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'NHoLNHOPI'} -#' \item **B03002_008**: not Hispanic or Latino, Some other race alone \code{'NHoLSOR'} -#' \item **B03002_009**: not Hispanic or Latino, Two or more races \code{'NHoLTOMR'} -#' \item **B03002_010**: not Hispanic or Latino, Two races including Some other race \code{'NHoLTRiSOR'} -#' \item **B03002_011**: not Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'NHoLTReSOR'} -#' \item **B03002_012**: Hispanic or Latino \code{'HoL'} -#' \item **B03002_013**: Hispanic or Latino, white alone \code{'HoLW'} -#' \item **B03002_014**: Hispanic or Latino, Black or African American alone \code{'HoLB'} -#' \item **B03002_015**: Hispanic or Latino, American Indian and Alaska Native alone \code{'HoLAIAN'} -#' \item **B03002_016**: Hispanic or Latino, Asian alone \code{'HoLA'} -#' \item **B03002_017**: Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'HoLNHOPI'} -#' \item **B03002_018**: Hispanic or Latino, Some other race alone \code{'HoLSOR'} -#' \item **B03002_019**: Hispanic or Latino, Two or more races \code{'HoLTOMR'} -#' \item **B03002_020**: Hispanic or Latino, Two races including Some other race \code{'HoLTRiSOR'} -#' \item **B03002_021**: Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'HoLTReSOR'} +#' \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. #' -#' *LQ* is some measure of relative racial homogeneity of each smaller geography within a larger geography. *LQ* can range in value from 0 to infinity because it is ratio of two proportions in which the numerator is the proportion of subgroup population in a smaller geography and the denominator is the proportion of subgroup population in its larger geography. For example, a smaller geography with an *LQ* of 5 means that the proportion of the subgroup population living in the smaller geography is five times the proportion of the subgroup population in its larger geography. +#' \emph{LQ} is some measure of relative racial homogeneity of each smaller geography within a larger geography. \emph{LQ} can range in value from 0 to infinity because it is ratio of two proportions in which the numerator is the proportion of subgroup population in a smaller geography and the denominator is the proportion of subgroup population in its larger geography. For example, a smaller geography with an \emph{LQ} of 5 means that the proportion of the subgroup population living in the smaller geography is five times the proportion of the subgroup population in its larger geography. #' -#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the *LQ* value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the *LQ* computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the *LQ* computation. +#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{LQ} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{LQ} 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{LQ} computation. #' #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{lq}}{An object of class 'tbl' for the GEOID, name, and *LQ* at specified smaller census geographies.} +#' \item{\code{lq}}{An object of class 'tbl' for the GEOID, name, and \emph{LQ} at specified smaller census geographies.} #' \item{\code{lq_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 *LQ*.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute \emph{LQ}.} #' } #' #' @import dplyr @@ -55,7 +55,7 @@ #' @importFrom stats complete.cases #' @importFrom tidycensus get_acs #' @importFrom tidyr pivot_longer separate -#' @importFrom tigris core_based_statistical_areas +#' @importFrom tigris combined_statistical_areas core_based_statistical_areas metro_divisions #' @importFrom utils stack #' @export #' @@ -86,7 +86,7 @@ sudano <- function(geo_large = 'county', ...) { # Check arguments - match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa')) + match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa', 'csa', 'metro')) match.arg(geo_small, choices = c('county', 'tract', 'block group')) stopifnot(is.numeric(year), year >= 2009) # all variables available 2009 onward match.arg( @@ -212,7 +212,7 @@ sudano <- function(geo_large = 'county', lq_data <- lq_data %>% dplyr::mutate( oid = lapply(win_cbsa, function(x) { - tmp <- dat_cbsa[x, 2] %>% sf::st_drop_geometry() + tmp <- dat_cbsa[x, 3] %>% sf::st_drop_geometry() lapply(tmp, function(x) { if (length(x) == 0) NA else x }) }) %>% unlist(), @@ -224,6 +224,44 @@ sudano <- function(geo_large = 'county', ) %>% sf::st_drop_geometry() } + if (geo_large == 'csa') { + stopifnot(is.numeric(year), year >= 2011) # CSAs only available 2011 onward + dat_csa <- suppressMessages(suppressWarnings(tigris::combined_statistical_areas(year = year))) + win_csa <- sf::st_within(lq_data, dat_csa) + lq_data <- lq_data %>% + dplyr::mutate( + oid = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 2] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + csa = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 3] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } + if (geo_large == 'metro') { + stopifnot(is.numeric(year), year >= 2011) # Metro Divisions only available 2011 onward + dat_metro <- suppressMessages(suppressWarnings(tigris::metro_divisions(year = year))) + win_metro <- sf::st_within(lq_data, dat_metro) + lq_data <- lq_data %>% + dplyr::mutate( + oid = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 4] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + metro = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 5] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } # Count of racial/ethnic subgroup populations ## Count of racial/ethnic comparison subgroup population @@ -296,6 +334,18 @@ sudano <- function(geo_large = 'county', dplyr::left_join(lq, ., by = dplyr::join_by(GEOID)) %>% dplyr::relocate(cbsa, .after = county) } + if (geo_large == 'csa') { + lq <- lq_data %>% + dplyr::select(GEOID, csa) %>% + dplyr::left_join(lq, ., by = dplyr::join_by(GEOID)) %>% + dplyr::relocate(csa, .after = county) + } + if (geo_large == 'metro') { + lq <- lq_data %>% + dplyr::select(GEOID, metro) %>% + dplyr::left_join(lq, ., by = dplyr::join_by(GEOID)) %>% + dplyr::relocate(metro, .after = county) + } lq <- lq %>% unique(.) %>% diff --git a/R/white.R b/R/white.R index 94b0e3b..0754d62 100644 --- a/R/white.R +++ b/R/white.R @@ -10,44 +10,44 @@ #' @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 Correlation Ratio (*V* or \eqn{Eta^{2}}{Eta^2}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}. This function provides the computation of *V* for any of the U.S. Census Bureau race/ethnicity subgroups (including Hispanic and non-Hispanic individuals). +#' @details This function will compute the aspatial Correlation Ratio (\emph{V} or \eqn{Eta^{2}}{Eta^2}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}. This function provides the computation of \emph{V} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +#' 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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: #' \itemize{ -#' \item **B03002_002**: not Hispanic or Latino \code{'NHoL'} -#' \item **B03002_003**: not Hispanic or Latino, white alone \code{'NHoLW'} -#' \item **B03002_004**: not Hispanic or Latino, Black or African American alone \code{'NHoLB'} -#' \item **B03002_005**: not Hispanic or Latino, American Indian and Alaska Native alone \code{'NHoLAIAN'} -#' \item **B03002_006**: not Hispanic or Latino, Asian alone \code{'NHoLA'} -#' \item **B03002_007**: not Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'NHoLNHOPI'} -#' \item **B03002_008**: not Hispanic or Latino, Some other race alone \code{'NHoLSOR'} -#' \item **B03002_009**: not Hispanic or Latino, Two or more races \code{'NHoLTOMR'} -#' \item **B03002_010**: not Hispanic or Latino, Two races including Some other race \code{'NHoLTRiSOR'} -#' \item **B03002_011**: not Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'NHoLTReSOR'} -#' \item **B03002_012**: Hispanic or Latino \code{'HoL'} -#' \item **B03002_013**: Hispanic or Latino, white alone \code{'HoLW'} -#' \item **B03002_014**: Hispanic or Latino, Black or African American alone \code{'HoLB'} -#' \item **B03002_015**: Hispanic or Latino, American Indian and Alaska Native alone \code{'HoLAIAN'} -#' \item **B03002_016**: Hispanic or Latino, Asian alone \code{'HoLA'} -#' \item **B03002_017**: Hispanic or Latino, Native Hawaiian and Other Pacific Islander alone \code{'HoLNHOPI'} -#' \item **B03002_018**: Hispanic or Latino, Some other race alone \code{'HoLSOR'} -#' \item **B03002_019**: Hispanic or Latino, Two or more races \code{'HoLTOMR'} -#' \item **B03002_020**: Hispanic or Latino, Two races including Some other race \code{'HoLTRiSOR'} -#' \item **B03002_021**: Hispanic or Latino, Two races excluding Some other race, and three or more races \code{'HoLTReSOR'} +#' \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. #' -#' *V* removes the asymmetry from the Isolation Index (Bell) by controlling for the effect of population composition. The Isolation Index (Bell) 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). *V* can range in value from -Inf to Inf. +#' \emph{V} removes the asymmetry from the Isolation Index (Bell) by controlling for the effect of population composition. The Isolation Index (Bell) 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). \emph{V} can range in value from -Inf to Inf. #' -#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the *V* value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the *V* computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the *V* computation. +#' Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{V} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, 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{V} computation. #' #' @return An object of class 'list'. This is a named list with the following components: #' #' \describe{ -#' \item{\code{v}}{An object of class 'tbl' for the GEOID, name, and *V* at specified larger census geographies.} +#' \item{\code{v}}{An object of class 'tbl' for the GEOID, name, and \emph{V} at specified larger census geographies.} #' \item{\code{v_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 *V*.} +#' \item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute \emph{V}.} #' } #' #' @import dplyr @@ -55,7 +55,7 @@ #' @importFrom stats complete.cases #' @importFrom tidycensus get_acs #' @importFrom tidyr pivot_longer separate -#' @importFrom tigris core_based_statistical_areas +#' @importFrom tigris combined_statistical_areas core_based_statistical_areas metro_divisions #' @importFrom utils stack #' @export #' @@ -86,7 +86,7 @@ white <- function(geo_large = 'county', ...) { # Check arguments - match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa')) + match.arg(geo_large, choices = c('state', 'county', 'tract', 'cbsa', 'csa', 'metro')) match.arg(geo_small, choices = c('county', 'tract', 'block group')) stopifnot(is.numeric(year), year >= 2009) # all variables available 2009 onward match.arg( @@ -208,7 +208,7 @@ white <- function(geo_large = 'county', v_data <- v_data %>% dplyr::mutate( oid = lapply(win_cbsa, function(x) { - tmp <- dat_cbsa[x, 2] %>% sf::st_drop_geometry() + tmp <- dat_cbsa[x, 3] %>% sf::st_drop_geometry() lapply(tmp, function(x) { if (length(x) == 0) NA else x }) }) %>% unlist(), @@ -220,6 +220,44 @@ white <- function(geo_large = 'county', ) %>% sf::st_drop_geometry() } + if (geo_large == 'csa') { + stopifnot(is.numeric(year), year >= 2011) # CSAs only available 2011 onward + dat_csa <- suppressMessages(suppressWarnings(tigris::combined_statistical_areas(year = year))) + win_csa <- sf::st_within(v_data, dat_csa) + v_data <- v_data %>% + dplyr::mutate( + oid = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 2] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + csa = lapply(win_csa, function(x) { + tmp <- dat_csa[x, 3] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } + if (geo_large == 'metro') { + stopifnot(is.numeric(year), year >= 2011) # Metro Divisions only available 2011 onward + dat_metro <- suppressMessages(suppressWarnings(tigris::metro_divisions(year = year))) + win_metro <- sf::st_within(v_data, dat_metro) + v_data <- v_data %>% + dplyr::mutate( + oid = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 4] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist(), + metro = lapply(win_metro, function(x) { + tmp <- dat_metro[x, 5] %>% sf::st_drop_geometry() + lapply(tmp, function(x) { if (length(x) == 0) NA else x }) + }) %>% + unlist() + ) %>% + sf::st_drop_geometry() + } # Count of racial/ethnic subgroup populations ## Count of racial/ethnic comparison subgroup population @@ -307,6 +345,26 @@ white <- function(geo_large = 'county', .[.$GEOID != 'NANA', ] %>% dplyr::distinct(GEOID, .keep_all = TRUE) } + if (geo_large == 'csa') { + v <- v_data %>% + dplyr::left_join(Vtmp, by = dplyr::join_by(oid)) %>% + dplyr::select(oid, csa, V) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, csa, V) %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::distinct(GEOID, .keep_all = TRUE) + } + if (geo_large == 'metro') { + v <- v_data %>% + dplyr::left_join(Vtmp, by = dplyr::join_by(oid)) %>% + dplyr::select(oid, metro, V) %>% + unique(.) %>% + dplyr::mutate(GEOID = oid) %>% + dplyr::select(GEOID, metro, V) %>% + .[.$GEOID != 'NANA', ] %>% + dplyr::distinct(GEOID, .keep_all = TRUE) + } v <- v %>% dplyr::arrange(GEOID) %>% diff --git a/README.md b/README.md index b52fa88..91bdda7 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,11 @@ [![DOI](https://zenodo.org/badge/521439746.svg)](https://zenodo.org/badge/latestdoi/521439746) -**Date repository last updated**: 2024-08-18 +**Date repository last updated**: 2024-08-19 ### Overview -The *ndi* package is a suite of [**R**](https://cran.r-project.org/) functions to compute various metrics of socio-economic deprivation and disparity in the United States. Some metrics are considered 'spatial' because they consider the values of neighboring (i.e., adjacent) census geographies in their computation, while other metrics are 'aspatial' because they only consider the value within each census geography. Two types of aspatial NDI are available: (1) based on [Messer et al. (2006)](https://doi.org/10.1007/s11524-006-9094-x) and (2) based on [Andrews et al. (2020)](https://doi.org/10.1080/17445647.2020.1750066) and [Slotman et al. (2022)](https://doi.org/10.1016/j.dib.2022.108002) who use variables chosen by [Roux and Mair (2010)](https://doi.org/10.1111/j.1749-6632.2009.05333.x). Both are a decomposition of various demographic characteristics from the U.S. Census Bureau American Community Survey 5-year estimates (ACS-5; 2006-2010 onward) pulled by the [tidycensus](https://CRAN.R-project.org/package=tidycensus) package. Using data from the ACS-5 (2005-2009 onward), the `ndi` package can also compute the (1) spatial Racial Isolation Index (RI) based on [Anthopolos et al. (2011)](https://doi.org/10.1016/j.sste.2011.06.002), (2) spatial Educational Isolation Index (EI) based on [Bravo et al. (2021)](https://doi.org/10.3390/ijerph18179384), (3) aspatial Index of Concentration at the Extremes (ICE) based on [Feldman et al. (2015)](https://doi.org/10.1136/jech-2015-205728) and [Krieger et al. (2016)](https://doi.org/10.2105/AJPH.2015.302955), (4) aspatial racial/ethnic Dissimilarity Index (DI) based on [Duncan & Duncan (1955)](https://doi.org/10.2307/2088328), (5) aspatial income or racial/ethnic Atkinson Index (DI) based on [Atkinson (1970)](https://doi.org/10.1016/0022-0531(70)90039-6), (6) aspatial racial/ethnic Isolation Index (II) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and [Bell (1954)](https://doi.org/10.2307/2574118), (7) aspatial racial/ethnic Correlation Ratio based on [Bell (1954)](https://doi.org/10.2307/2574118) and [White (1986)](https://doi.org/10.2307/3644339), (8) aspatial racial/ethnic Location Quotient based on [Merton (1939)](https://doi.org/10.2307/2084686) and [Sudano et al. (2013)](https://doi.org/10.1016/j.healthplace.2012.09.015), (9) aspatial racial/ethnic Local Exposure and Isolation metric based on [Bemanian & Beyer (2017)](https://doi.org/10.1158/1055-9965.EPI-16-0926), and (10) aspatial racial/ethnic Delta based on [Hoover (1941)](https://doi.org/10.1017/S0022050700052980) and Duncan et al. (1961; LC:60007089). Also using data from the ACS-5 (2005-2009 onward), the *ndi* package can retrieve the aspatial Gini Index based on [Gini (1921)](https://doi.org/10.2307/2223319). +The *ndi* package is a suite of [**R**](https://cran.r-project.org/) functions to compute various metrics of socio-economic deprivation and disparity in the United States. Some metrics are considered 'spatial' because they consider the values of neighboring (i.e., adjacent) census geographies in their computation, while other metrics are 'aspatial' because they only consider the value within each census geography. Two types of aspatial neighborhood deprivation index (*NDI*) are available: (1) based on [Messer et al. (2006)](https://doi.org/10.1007/s11524-006-9094-x) and (2) based on [Andrews et al. (2020)](https://doi.org/10.1080/17445647.2020.1750066) and [Slotman et al. (2022)](https://doi.org/10.1016/j.dib.2022.108002) who use variables chosen by [Roux and Mair (2010)](https://doi.org/10.1111/j.1749-6632.2009.05333.x). Both are a decomposition of various demographic characteristics from the U.S. Census Bureau American Community Survey 5-year estimates (ACS-5; 2006-2010 onward) pulled by the [tidycensus](https://CRAN.R-project.org/package=tidycensus) package. Using data from the ACS-5 (2005-2009 onward), the *ndi* package can also compute the (1) spatial Racial Isolation Index (*RI*) based on [Anthopolos et al. (2011)](https://doi.org/10.1016/j.sste.2011.06.002), (2) spatial Educational Isolation Index (*EI*) based on [Bravo et al. (2021)](https://doi.org/10.3390/ijerph18179384), (3) aspatial Index of Concentration at the Extremes (*ICE*) based on [Feldman et al. (2015)](https://doi.org/10.1136/jech-2015-205728) and [Krieger et al. (2016)](https://doi.org/10.2105/AJPH.2015.302955), (4) aspatial racial/ethnic Dissimilarity Index (*DI*) based on [Duncan & Duncan (1955)](https://doi.org/10.2307/2088328), (5) aspatial income or racial/ethnic Atkinson Index (*DI*) based on [Atkinson (1970)](https://doi.org/10.1016/0022-0531(70)90039-6), (6) aspatial racial/ethnic Isolation Index (*II*) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and [Bell (1954)](https://doi.org/10.2307/2574118), (7) aspatial racial/ethnic Correlation Ratio (*V*) based on [Bell (1954)](https://doi.org/10.2307/2574118) and [White (1986)](https://doi.org/10.2307/3644339), (8) aspatial racial/ethnic Location Quotient (*LQ*) based on [Merton (1939)](https://doi.org/10.2307/2084686) and [Sudano et al. (2013)](https://doi.org/10.1016/j.healthplace.2012.09.015), (9) aspatial racial/ethnic Local Exposure and Isolation (*LEx/Is*) metric based on [Bemanian & Beyer (2017)](https://doi.org/10.1158/1055-9965.EPI-16-0926), and (10) aspatial racial/ethnic Delta (*DEL*) based on [Hoover (1941)](https://doi.org/10.1017/S0022050700052980) and Duncan et al. (1961; LC:60007089). Also using data from the ACS-5 (2005-2009 onward), the *ndi* package can retrieve the aspatial Gini Index (*G*) based on [Gini (1921)](https://doi.org/10.2307/2223319). ### Installation @@ -44,54 +44,54 @@ To install the development version from GitHub: anthopolos -Compute the spatial Racial Isolation Index (RI) based on Anthopolos et al. (2011) +Compute the spatial Racial Isolation Index (RI) based on Anthopolos et al. (2011) atkinson -Compute the aspatial Atkinson Index (AI) based on Atkinson (1970) +Compute the aspatial Atkinson Index (AI) based on Atkinson (1970) bell -Compute the aspatial racial/ethnic Isolation Index (II) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) +Compute the aspatial racial/ethnic Isolation Index (II) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) bemanian_beyer -Compute the aspatial racial/ethnic Local Exposure and Isolation (LEx/Is) metric based on Bemanian & Beyer (2017) +Compute the aspatial racial/ethnic Local Exposure and Isolation (LEx/Is) metric based on Bemanian & Beyer (2017) bravo -Compute the spatial Educational Isolation Index (EI) based on Bravo et al. (2021) +Compute the spatial Educational Isolation Index (EI) based on Bravo et al. (2021) duncan -Compute the aspatial racial/ethnic Dissimilarity Index (DI) based on Duncan & Duncan (1955) +Compute the aspatial racial/ethnic Dissimilarity Index (DI) based on Duncan & Duncan (1955) gini -Retrieve the aspatial Gini Index based on Gini (1921) +Retrieve the aspatial Gini Index (G) based on Gini (1921) hoover -Compute the aspatial racial/ethnic Delta (DEL) based on Hoover (1941) and Duncan et al. (1961; LC:60007089). +Compute the aspatial racial/ethnic Delta (DEL) based on Hoover (1941) and Duncan et al. (1961; LC:60007089). krieger -Compute the aspatial Index of Concentration at the Extremes (ICE) based on Feldman et al. (2015) and Krieger et al. (2016) +Compute the aspatial Index of Concentration at the Extremes (ICE) based on Feldman et al. (2015) and Krieger et al. (2016) messer -Compute the aspatial Neighborhood Deprivation Index (NDI) based on Messer et al. (2006) +Compute the aspatial Neighborhood Deprivation Index (NDI) based on Messer et al. (2006) 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) +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) sudano -Compute the aspatial racial/ethnic Location Quotient (LQ) based on Merton (1938) and Sudano et al. (2013) +Compute the aspatial racial/ethnic Location Quotient (LQ) based on Merton (1938) and Sudano et al. (2013) white -Compute the aspatial racial/ethnic Correlation Ratio (V) based on Bell (1954) and White (1986) +Compute the aspatial racial/ethnic Correlation Ratio (V) based on Bell (1954) and White (1986) diff --git a/cran-comments.md b/cran-comments.md index 23392bf..9713195 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -2,7 +2,7 @@ * Actions taken since previous submission: * Added `hoover()` function to compute the aspatial racial/ethnic Delta (*DEL*) based on [Hoover (1941)](https://doi.org/10.1017/S0022050700052980) and Duncan et al. (1961; LC:60007089) - * Added `geo_large = 'cbsa'` option for computing Core Based Statistical Areas as the larger geographical unit in `atkinson()`, `bell()`, `bemanian_beyer()`, `duncan()`, `hoover()`, `sudano()`, and `white()` functions. + * Added `geo_large = 'cbsa'` for computing 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()`, `duncan()`, `hoover()`, `sudano()`, and `white()` functions. * Thank you for the feature suggestions, [Symielle Gaston](https://orcid.org/0000-0001-9495-1592) * Fixed bug in `bell()`, `bemanian_beyer()`, `duncan()`, `sudano()`, and `white()` when a smaller geography contains n=0 total population, will assign a value of zero (0) in the internal calculation instead of NA * `tigris` is now Imports diff --git a/man/atkinson.Rd b/man/atkinson.Rd index da948e9..e6b94a7 100644 --- a/man/atkinson.Rd +++ b/man/atkinson.Rd @@ -47,7 +47,7 @@ Compute the aspatial Atkinson Index of income or selected racial/ethnic subgroup \details{ This function will compute the aspatial Atkinson Index (\emph{AI}) of income or selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}. This function provides the computation of \emph{AI} for median household income and any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. When \code{subgroup = 'MedHHInc'}, the metric will be computed for median household income ('B19013_001'). The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. When \code{subgroup = 'MedHHInc'}, the metric will be computed for median household income ('B19013_001'). The twenty racial/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'} @@ -77,7 +77,7 @@ Use the internal \code{state} and \code{county} arguments within the \code{\link The \code{epsilon} argument that determines how to weight the increments to inequality contributed by different proportions of the Lorenz curve. A user must explicitly decide how heavily to weight smaller geographical units at different points on the Lorenz curve (i.e., whether the index should take greater account of differences among areas of over- or under-representation). The \code{epsilon} argument must have values between 0 and 1.0. For \code{0 <= epsilon < 0.5} or less 'inequality-averse,' smaller geographical units with a subgroup proportion smaller than the subgroup proportion of the larger geographical unit contribute more to inequality ('over-representation'). For \code{0.5 < epsilon <= 1.0} or more 'inequality-averse,' smaller geographical units with a subgroup proportion larger than the subgroup proportion of the larger geographical unit contribute more to inequality ('under-representation'). If \code{epsilon = 0.5} (the default), units of over- and under-representation contribute equally to the index. See Section 2.3 of Saint-Jacques et al. (2020) \doi{10.48550/arXiv.2002.05819} for one method to select \code{epsilon}. -Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{AI} value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the \emph{AI} computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the \emph{AI} computation. +Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{AI} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{AI} 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{AI} computation. } \examples{ \dontrun{ diff --git a/man/bell.Rd b/man/bell.Rd index 27b285b..b505124 100644 --- a/man/bell.Rd +++ b/man/bell.Rd @@ -47,7 +47,7 @@ Compute the aspatial Isolation Index (Bell) of a selected racial/ethnic subgroup \details{ This function will compute the aspatial Isolation Index (\emph{II}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}. This function provides the computation of \emph{II} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/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'} @@ -75,7 +75,7 @@ Use the internal \code{state} and \code{county} arguments within the \code{\link \emph{II} 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). \emph{II} can range in value from 0 to 1. -Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{II} value returned is NA. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{II} value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the \emph{II} computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the \emph{II} computation. +Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{II} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{II} 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{II} computation. } \examples{ \dontrun{ diff --git a/man/bemanian_beyer.Rd b/man/bemanian_beyer.Rd index 1dd2ae1..83e32db 100644 --- a/man/bemanian_beyer.Rd +++ b/man/bemanian_beyer.Rd @@ -47,7 +47,7 @@ Compute the aspatial Local Exposure and Isolation (Bemanian & Beyer) metric of a \details{ This function will compute the aspatial Local Exposure and Isolation (\emph{LEx/Is}) metric of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Bemanian & Beyer (2017) \doi{10.1158/1055-9965.EPI-16-0926}. This function provides the computation of \emph{LEx/Is} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/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'} @@ -77,7 +77,7 @@ Use the internal \code{state} and \code{county} arguments within the \code{\link \emph{LEx/Is} can range from negative infinity to infinity. If \emph{LEx/Is} is zero then the estimated probability of the interaction between two people of the given subgroup(s) within a smaller geography is equal to the expected probability if the subgroup(s) were perfectly mixed in the larger geography. If \emph{LEx/Is} is greater than zero then the interaction is more likely to occur within the smaller geography than in the larger geography, and if \emph{LEx/Is} is less than zero then the interaction is less likely to occur within the smaller geography than in the larger geography. Note: the exponentiation of each \emph{LEx/Is} metric results in the odds ratio of the specific exposure or isolation of interest in a smaller geography relative to the larger geography. -Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{LEx/Is} value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the \emph{LEx/Is} computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the \emph{LEx/Is} computation. +Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{LEx/Is} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{LEx/Is} 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{LEx/Is} computation. } \examples{ \dontrun{ diff --git a/man/duncan.Rd b/man/duncan.Rd index eb8677e..eaae01b 100644 --- a/man/duncan.Rd +++ b/man/duncan.Rd @@ -47,7 +47,7 @@ Compute the aspatial Dissimilarity Index (Duncan & Duncan) of selected racial/et \details{ This function will compute the aspatial Dissimilarity Index (\emph{DI}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Duncan & Duncan (1955) \doi{10.2307/2088328}. This function provides the computation of \emph{DI} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/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'} @@ -75,7 +75,7 @@ Use the internal \code{state} and \code{county} arguments within the \code{\link \emph{DI} is a measure of the evenness of racial/ethnic residential segregation when comparing smaller geographical areas to larger ones within which the smaller geographical areas are located. \emph{DI} can range in value from 0 to 1 and represents the proportion of racial/ethnic subgroup members that would have to change their area of residence to achieve an even distribution within the larger geographical area under conditions of maximum segregation. -Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{DI} value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the \emph{DI} computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the \emph{DI} computation. +Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{DI} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{DI} 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{DI} computation. } \examples{ \dontrun{ diff --git a/man/gini.Rd b/man/gini.Rd index 0a83558..7e10e99 100644 --- a/man/gini.Rd +++ b/man/gini.Rd @@ -19,17 +19,17 @@ gini(geo = "tract", year = 2020, quiet = FALSE, ...) An object of class 'list'. This is a named list with the following components: \describe{ -\item{\code{gini}}{An object of class 'tbl' for the GEOID, name, and Gini index of specified census geographies.} -\item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for the Gini index.} +\item{\code{gini}}{An object of class 'tbl' for the GEOID, name, and \emph{G} of specified census geographies.} +\item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for \emph{G}.} } } \description{ Retrieve the aspatial Gini Index of income inequality. } \details{ -This function will retrieve the aspatial Gini Index of U.S. census tracts or counties for a specified geographical extent (e.g., the entire U.S. or a single state) based on Gini (1921) \doi{10.2307/2223319}. +This function will retrieve the aspatial Gini Index (\emph{G}) of U.S. census tracts or counties for a specified geographical extent (e.g., the entire U.S. or a single state) based on Gini (1921) \doi{10.2307/2223319}. -The function uses the \code{\link[tidycensus]{get_acs}} function to obtain U.S. Census Bureau 5-year American Community Survey estimates of the Gini Index for income inequality (ACS: B19083). The estimates are available for 2009 onward when ACS-5 data are available but are available from other U.S. Census Bureau surveys. +The function uses the \code{\link[tidycensus]{get_acs}} function to obtain U.S. Census Bureau 5-year American Community Survey estimates of \emph{G} for income inequality (ACS: B19083). The estimates are available for 2009 onward when ACS-5 data are available but are available from other U.S. Census Bureau surveys. 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. diff --git a/man/hoover.Rd b/man/hoover.Rd index 9e4dde5..1989485 100644 --- a/man/hoover.Rd +++ b/man/hoover.Rd @@ -44,7 +44,7 @@ Compute the aspatial Delta (Hoover) of a selected racial/ethnic subgroup(s) and \details{ This function will compute the aspatial Delta (\emph{DEL}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Hoover (1941) \doi{10.1017/S0022050700052980} and Duncan, Cuzzort, and Duncan (1961; LC:60007089). This function provides the computation of \emph{DEL} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/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'} @@ -72,7 +72,7 @@ Use the internal \code{state} and \code{county} arguments within the \code{\link \emph{DEL} is a measure of the proportion of members of one subgroup(s) residing in geographic units with above average density of members of the subgroup(s). The index provides the proportion of a subgroup population that would have to move across geographic units to achieve a uniform density. \emph{DEL} can range in value from 0 to 1. -Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{DEL} value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the \emph{DEL} computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the \emph{DEL} computation. +Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{DEL} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{DEL} 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{DEL} computation. } \examples{ \dontrun{ diff --git a/man/krieger.Rd b/man/krieger.Rd index 064b490..808937d 100644 --- a/man/krieger.Rd +++ b/man/krieger.Rd @@ -20,7 +20,7 @@ An object of class 'list'. This is a named list with the following components: \describe{ \item{\code{ice}}{An object of class 'tbl' for the GEOID, name, \emph{ICE} metrics, and raw census values of specified census geographies.} -\item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute the \emph{ICE}s.} +\item{\code{missing}}{An object of class 'tbl' of the count and proportion of missingness for each census variable used to compute the \emph{ICE} metrics.} } } \description{ diff --git a/man/ndi-package.Rd b/man/ndi-package.Rd index 7efa8dc..2503449 100644 --- a/man/ndi-package.Rd +++ b/man/ndi-package.Rd @@ -9,37 +9,37 @@ Computes various metrics of socio-economic deprivation and disparity in the United States based on information available from the U.S. Census Bureau. } \details{ -The 'ndi' package computes various metrics of socio-economic deprivation and disparity in the United States. Some metrics are considered "spatial" because they consider the values of neighboring (i.e., adjacent) census geographies in their computation, while other metrics are "aspatial" because they only consider the value within each census geography. Two types of aspatial neighborhood deprivation indices (NDI) are available: (1) based on Messer et al. (2006) \doi{10.1007/s11524-006-9094-x} and (2) based on Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} who use variables chosen by Roux and Mair (2010) \doi{10.1111/j.1749-6632.2009.05333.x}. Both are a decomposition of multiple demographic characteristics from the U.S. Census Bureau American Community Survey 5-year estimates (ACS-5; 2006-2010 onward). Using data from the ACS-5 (2005-2009 onward), the package can also compute the (1) spatial Racial Isolation Index (RI) based on Anthopolos et al. (2011) \doi{10.1016/j.sste.2011.06.002}, (2) spatial Educational Isolation Index (EI) based on Bravo et al. (2021) \doi{10.3390/ijerph18179384}, (3) aspatial Index of Concentration at the Extremes (ICE) based on Feldman et al. (2015) \doi{10.1136/jech-2015-205728} and Krieger et al. (2016) \doi{10.2105/AJPH.2015.302955}, (4) aspatial racial/ethnic Dissimilarity Index based on Duncan & Duncan (1955) \doi{10.2307/2088328}, (5) aspatial income or racial/ethnic Atkinson Index based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}, (6) aspatial racial/ethnic Isolation Index (II) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}, (7) aspatial racial/ethnic Correlation Ratio based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}, (8) aspatial racial/ethnic Location Quotient (LQ) based on Merton (1939) \doi{10.2307/2084686} and Sudano et al. (2013) \doi{10.1016/j.healthplace.2012.09.015}, (9) aspatial racial/ethnic Local Exposure and Isolation metric based on Bemanian & Beyer (2017) \url{doi:10.1158/1055-9965.EPI-16-0926}, and (10) aspatial racial/ethnic Delta based on Hoover (1941) \url{doi:10.1017/S0022050700052980} and Duncan et al. (1961; LC:60007089). Also using data from the ACS-5 (2005-2009 onward), the package can retrieve the aspatial Gini Index based on Gini (1921) \doi{10.2307/2223319}. +The 'ndi' package computes various metrics of socio-economic deprivation and disparity in the United States. Some metrics are considered "spatial" because they consider the values of neighboring (i.e., adjacent) census geographies in their computation, while other metrics are "aspatial" because they only consider the value within each census geography. Two types of aspatial neighborhood deprivation indices (\emph{NDI}) are available: (1) based on Messer et al. (2006) \doi{10.1007/s11524-006-9094-x} and (2) based on Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} who use variables chosen by Roux and Mair (2010) \doi{10.1111/j.1749-6632.2009.05333.x}. Both are a decomposition of multiple demographic characteristics from the U.S. Census Bureau American Community Survey 5-year estimates (ACS-5; 2006-2010 onward). Using data from the ACS-5 (2005-2009 onward), the package can also compute the (1) spatial Racial Isolation Index (\emph{RI}) based on Anthopolos et al. (2011) \doi{10.1016/j.sste.2011.06.002}, (2) spatial Educational Isolation Index (\emph{EI}) based on Bravo et al. (2021) \doi{10.3390/ijerph18179384}, (3) aspatial Index of Concentration at the Extremes (\emph{ICE}) based on Feldman et al. (2015) \doi{10.1136/jech-2015-205728} and Krieger et al. (2016) \doi{10.2105/AJPH.2015.302955}, (4) aspatial racial/ethnic Dissimilarity Index (\emph{DI}) based on Duncan & Duncan (1955) \doi{10.2307/2088328}, (5) aspatial income or racial/ethnic Atkinson Index (\emph{AI}) based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}, (6) aspatial racial/ethnic Isolation Index (\emph{II}) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}, (7) aspatial racial/ethnic Correlation Ratio (\emph{V}) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}, (8) aspatial racial/ethnic 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}, (9) aspatial racial/ethnic Local Exposure and Isolation (\emph{LEx/Is}) metric based on Bemanian & Beyer (2017) \url{doi:10.1158/1055-9965.EPI-16-0926}, and (10) aspatial racial/ethnic Delta (\emph{DEL}) based on Hoover (1941) \url{doi:10.1017/S0022050700052980} and Duncan et al. (1961; LC:60007089). Also using data from the ACS-5 (2005-2009 onward), the package can retrieve the aspatial Gini Index (\emph{G}) based on Gini (1921) \doi{10.2307/2223319}. Key content of the 'ndi' package include:\cr \bold{Metrics of Socio-Economic Deprivation and Disparity} -\code{\link{anthopolos}} Computes the spatial Racial Isolation Index (RI) based on Anthopolos (2011) \doi{10.1016/j.sste.2011.06.002}. +\code{\link{anthopolos}} Computes the spatial Racial Isolation Index (\emph{RI}) based on Anthopolos (2011) \doi{10.1016/j.sste.2011.06.002}. -\code{\link{atkinson}} Computes the aspatial income or racial/ethnic Atkinson Index (AI) based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}. +\code{\link{atkinson}} Computes the aspatial income or racial/ethnic Atkinson Index (\emph{AI}) based on Atkinson (1970) \doi{10.1016/0022-0531(70)90039-6}. -\code{\link{bell}} Computes the aspatial racial/ethnic Isolation Index (II) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}. +\code{\link{bell}} Computes the aspatial racial/ethnic Isolation Index (\emph{II}) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954) \doi{10.2307/2574118}. -\code{\link{bemanian_beyer}} Computes the aspatial racial/ethnic Local Exposure and Isolation (LEx/Is) metric based on Bemanian & Beyer (2017) \doi{10.1158/1055-9965.EPI-16-0926}. +\code{\link{bemanian_beyer}} Computes the aspatial racial/ethnic Local Exposure and Isolation (\emph{LEx/Is}) metric based on Bemanian & Beyer (2017) \doi{10.1158/1055-9965.EPI-16-0926}. -\code{\link{bravo}} Computes the spatial Educational Isolation Index (EI) based on Bravo (2021) \doi{10.3390/ijerph18179384}. +\code{\link{bravo}} Computes the spatial Educational Isolation Index (\emph{EI}) based on Bravo (2021) \doi{10.3390/ijerph18179384}. -\code{\link{duncan}} Computes the aspatial racial/ethnic Dissimilarity Index (DI) based on Duncan & Duncan (1955) \doi{10.2307/2088328}. +\code{\link{duncan}} Computes the aspatial racial/ethnic Dissimilarity Index (\emph{DI}) based on Duncan & Duncan (1955) \doi{10.2307/2088328}. -\code{\link{gini}} Retrieves the aspatial Gini Index based on Gini (1921) \doi{10.2307/2223319}. +\code{\link{gini}} Retrieves the aspatial Gini Index (\emph{G}) based on Gini (1921) \doi{10.2307/2223319}. -\code{\link{hoover}} Computes the aspatial racial/ethnic Delta (DEL) based on Hoover (1941) \doi{doi:10.1017/S0022050700052980} and Duncan et al. (1961; LC:60007089). +\code{\link{hoover}} Computes the aspatial racial/ethnic Delta (\emph{DEL}) based on Hoover (1941) \doi{doi:10.1017/S0022050700052980} and Duncan et al. (1961; LC:60007089). \code{\link{krieger}} Computes the aspatial Index of Concentration at the Extremes based on Feldman et al. (2015) \doi{10.1136/jech-2015-205728} and Krieger et al. (2016) \doi{10.2105/AJPH.2015.302955}. -\code{\link{messer}} Computes the aspatial Neighborhood Deprivation Index (NDI) based on Messer et al. (2006) \doi{10.1007/s11524-006-9094-x}. +\code{\link{messer}} Computes the aspatial Neighborhood Deprivation Index (\emph{NDI}) based on Messer et al. (2006) \doi{10.1007/s11524-006-9094-x}. -\code{\link{powell_wiley}} Computes the aspatial Neighborhood Deprivation Index (NDI) based on Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} who use variables chosen by Roux and Mair (2010) \doi{10.1111/j.1749-6632.2009.05333.x}. +\code{\link{powell_wiley}} Computes the aspatial Neighborhood Deprivation Index (\emph{NDI}) based on Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} and Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} who use variables chosen by Roux and Mair (2010) \doi{10.1111/j.1749-6632.2009.05333.x}. -\code{\link{sudano}} Computes the aspatial racial/ethnic Location Quotient (LQ) based on Merton (1939) \doi{10.2307/2084686} and Sudano et al. (2013) \doi{10.1016/j.healthplace.2012.09.015}. +\code{\link{sudano}} Computes the aspatial racial/ethnic 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{white}} Computes the aspatial racial/ethnic Correlation Ratio (V) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}. +\code{\link{white}} Computes the aspatial racial/ethnic Correlation Ratio (\emph{V}) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}. \bold{Pre-formatted U.S. Census Data} diff --git a/man/sudano.Rd b/man/sudano.Rd index bca30ec..3b78894 100644 --- a/man/sudano.Rd +++ b/man/sudano.Rd @@ -44,7 +44,7 @@ Compute the aspatial Location Quotient (Sudano) of a selected racial/ethnic subg \details{ This function will compute the aspatial Location Quotient (\emph{LQ}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Merton (1939) \doi{10.2307/2084686} and Sudano et al. (2013) \doi{10.1016/j.healthplace.2012.09.015}. This function provides the computation of \emph{LQ} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/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'} @@ -72,7 +72,7 @@ Use the internal \code{state} and \code{county} arguments within the \code{\link \emph{LQ} is some measure of relative racial homogeneity of each smaller geography within a larger geography. \emph{LQ} can range in value from 0 to infinity because it is ratio of two proportions in which the numerator is the proportion of subgroup population in a smaller geography and the denominator is the proportion of subgroup population in its larger geography. For example, a smaller geography with an \emph{LQ} of 5 means that the proportion of the subgroup population living in the smaller geography is five times the proportion of the subgroup population in its larger geography. -Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{LQ} value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area are considered in the \emph{LQ} computation (see internal \code{\link[sf]{st_within}} function for more information) and recommend specifying all states within which the interested Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the \emph{LQ} computation. +Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{LQ} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a larger geographical unit are considered in the \emph{LQ} 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{LQ} computation. } \examples{ \dontrun{ diff --git a/man/white.Rd b/man/white.Rd index a72e270..28708ee 100644 --- a/man/white.Rd +++ b/man/white.Rd @@ -44,7 +44,7 @@ Compute the aspatial Correlation Ratio (White) of a selected racial/ethnic subgr \details{ This function will compute the aspatial Correlation Ratio (\emph{V} or \eqn{Eta^{2}}{Eta^2}) of selected racial/ethnic subgroups and U.S. geographies for a specified geographical extent (e.g., the entire U.S. or a single state) based on Bell (1954) \doi{10.2307/2574118} and White (1986) \doi{10.2307/3644339}. This function provides the computation of \emph{V} for any of the U.S. Census Bureau race/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 aspatial computation. The yearly estimates are available for 2009 onward when ACS-5 data are available (2010 onward for \code{geo_large = 'cbsa'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/ethnic subgroups (U.S. Census Bureau definitions) are: +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 aspatial 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 = 'csa'} or \code{geo_large = 'metro'}) but may be available from other U.S. Census Bureau surveys. The twenty racial/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'} @@ -72,7 +72,7 @@ Use the internal \code{state} and \code{county} arguments within the \code{\link \emph{V} removes the asymmetry from the Isolation Index (Bell) by controlling for the effect of population composition. The Isolation Index (Bell) 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). \emph{V} can range in value from -Inf to Inf. -Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, and census tract \code{geo_large = 'tract'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{V} value returned is NA. If the larger geographical unit is Core Based Statistical Areas \code{geo_large = 'cbsa'}, only the smaller geographical units completely within a Core Based Statistical Area 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 Core Based Statistical Areas are located using the internal \code{state} argument to ensure all appropriate smaller geographical units are included in the \emph{V} computation. +Larger geographies available include state \code{geo_large = 'state'}, county \code{geo_large = 'county'}, census tract \code{geo_large = 'tract'}, Core Based Statistical Area \code{geo_large = 'cbsa'}, Combined Statistical Area \code{geo_large = 'csa'}, and Metropolitan Division \code{geo_large = 'metro'} levels. Smaller geographies available include, county \code{geo_small = 'county'}, census tract \code{geo_small = 'tract'}, and census block group \code{geo_small = 'block group'} levels. If a larger geographical area is comprised of only one smaller geographical area (e.g., a U.S county contains only one census tract), then the \emph{V} value returned is NA. If the larger geographical unit is Combined Based Statistical Areas \code{geo_large = 'csa'} or Core Based Statistical Areas \code{geo_large = 'cbsa'}, 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{V} computation. } \examples{ \dontrun{