From 5402c2d85ea687d3adb02b841c6447071d3fc4ae Mon Sep 17 00:00:00 2001 From: Ian D Buller Date: Thu, 22 Aug 2024 17:05:17 -0400 Subject: [PATCH] :memo: Updated vignette for v0.1.6.9002 --- vignettes/vignette.Rmd | 12 +- vignettes/vignette.html | 300 ++++++++++++++++++++++++++++++++-------- 2 files changed, 246 insertions(+), 66 deletions(-) diff --git a/vignettes/vignette.Rmd b/vignettes/vignette.Rmd index ed2daa8..463adf0 100644 --- a/vignettes/vignette.Rmd +++ b/vignettes/vignette.Rmd @@ -1547,7 +1547,7 @@ Compute the aspatial racial/ethnic _xPx\*_ values (2015-2019 5-year ACS) for Del | B03002_020 | Hispanic or Latino, two races including some other race | HoLTRiSOR | | B03002_021 | Hispanic or Latino, two races excluding some other race, and three or more races | HoLTReSOR | -_xPy\*_ is some measure of the probability that a member of one subgroup(s) will meet or interact with a member of another subgroup(s) with higher values signifying higher probability of interaction (less isolation) when comparing smaller geographical areas to larger ones within which the smaller geographical areas are located. _xPy\*_ can range in value from 0 to 1. +_xPx\*_ is some measure of the probability that a member of one subgroup(s) will meet or interact with a member of another subgroup(s) with higher values signifying higher probability of interaction (less isolation) when comparing smaller geographical areas to larger ones within which the smaller geographical areas are located. _xPx\*_ can range in value from 0 to 1. ```{r lieberson_prep, results = 'hide'} lieberson2021DE <- lieberson( @@ -1559,14 +1559,14 @@ lieberson2021DE <- lieberson( ) # Obtain the 2021 census counties from the 'tigris' package -county2021DE <- counties(state = 'DE', year = 2019, cb = TRUE) +tract2021DE <- tracts(state = 'DE', year = 2019, cb = TRUE) # Join the xPx* values to the county geometry -DE2021lieberson <- county2021DE %>% +DE2021lieberson <- tract2021DE %>% left_join(lieberson2021DE$xpx_star, by = 'GEOID') ``` -```{r lieberson_plot, fig.height = 6, fig.width = 7} +```{r lieberson_plot, fig.height = 9, fig.width = 7} # Visualize the xPx* values (2015-2019 5-year ACS) for Delaware, U.S.A., census tracts ggplot() + geom_sf( @@ -1576,7 +1576,7 @@ ggplot() + color = 'white' ) + geom_sf( - data = county2021DE, + data = tract2021DE, fill = 'transparent', color = 'white', size = 0.2 @@ -1585,7 +1585,7 @@ ggplot() + scale_fill_viridis_c(limits = c(0, 1)) + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2015-2019 estimates') + ggtitle( - 'Isolation Index (Lieberson)\nDelaware census tracts to counties', + 'Isolation Index (Lieberson)\nDelaware census block groups to census tracts', subtitle = 'Black non-Hispanic' ) ``` diff --git a/vignettes/vignette.html b/vignettes/vignette.html index eb50ec3..96b983c 100644 --- a/vignettes/vignette.html +++ b/vignettes/vignette.html @@ -12,7 +12,7 @@ - + ndi: Neighborhood Deprivation Indices @@ -340,7 +340,7 @@

ndi: Neighborhood Deprivation Indices

Ian D. Buller (GitHub: @idblr)

-

2024-08-20

+

2024-08-22

@@ -1135,7 +1135,7 @@

Assign the referent (U.S.-Standardized Metric)

)

The process to compute a US-standardized NDI (Powell-Wiley) -took about 2.8 minutes to run on a machine with the features listed at +took about 24.7 minutes to run on a machine with the features listed at the end of the vignette.

@@ -1160,13 +1160,13 @@

Additional metrics socio-economic deprivation and disparity

al. (2015) and Krieger et al. (2016)
  • duncan() function that computes the Dissimilarity Index -(DI) based on Duncan +(D) based on Duncan & Duncan (1955)
  • atkinson() function that computes the Atkinson Index -(AI) based on Atkinson +(A) based on Atkinson (1970)
  • bell() function that computes the aspatial -racial/ethnic Isolation Index (II) based on Shevky & +racial/ethnic Interaction Index (xPy*) based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and Bell (1954)
  • white() function that computes the aspatial racial/ethnic Correlation Ratio (V) based on Bell (1954) and White (1986)
  • @@ -1183,6 +1183,9 @@

    Additional metrics socio-economic deprivation and disparity

  • white_blau() function that computes an index of spatial proximity (SP) based on White (1986) and Blau (1977; ISBN-13:978-0-029-03660-0)
  • +
  • lieberson() function that computes the aspatial +racial/ethnic Isolation Index (xPx*) based on Lieberson (1981; +ISBN-13:978-1-032-53884-6) and Bell (1954)
  • Compute Racial Isolation Index (RI)

    @@ -1531,14 +1534,14 @@

    Retrieve the Gini Index (G)

    # Obtain the 2010 counties from the 'tigris' package county2010MA <- counties(state = 'MA', year = 2010, cb = TRUE) -# Join the Gini Index values to the census tract geometry +# Join the G (Gini) values to the census tract geometry MA2010gini <- tract2010MA %>% - left_join(gini2010MA$gini, by = 'GEOID')
    -
    # Visualize the Gini Index values (2006-2010 5-year ACS) for Massachusetts, U.S.A., census tracts 
    +  left_join(gini2010MA$g, by = 'GEOID')
    +
    # Visualize the G (Gini) values (2006-2010 5-year ACS) for Massachusetts, U.S.A., census tracts 
     ggplot() +
       geom_sf(
         data = MA2010gini,
    -    aes(fill = gini),
    +    aes(fill = G),
         size = 0.05,
         color = 'transparent'
       ) +
    @@ -1735,9 +1738,9 @@ 

    Index of Concentration at the Extremes (ICE)

    subtitle = 'white non-Hispanic (WNH) in 80th inc pctl vs. WNH in 20th inc pctl' )

    -
    -

    Compute racial/ethnic Dissimilarity Index (DI)

    -

    Compute the aspatial racial/ethnic DI values (2006-2010 +

    +

    Compute racial/ethnic Dissimilarity Index (D)

    +

    Compute the aspatial racial/ethnic D values (2006-2010 5-year ACS) for Pennsylvania, U.S.A., counties from census tracts. This metric is based on Duncan & Duncan (1955) that assessed the racial/ethnic isolation of @@ -1867,9 +1870,9 @@

    Compute racial/ethnic Dissimilarity Index (DI)

    -

    DI is a measure of the evenness of racial/ethnic residential +

    D 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 +within which the smaller geographical areas are located. D 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 @@ -1888,14 +1891,14 @@

    Compute racial/ethnic Dissimilarity Index (DI)

    # Remove first 9 characters from GEOID for compatibility with tigris information county2010PA$GEOID <- substring(county2010PA$GEO_ID, 10) -# Join the DI values to the county geometry +# Join the D values to the county geometry PA2010duncan <- county2010PA %>% - left_join(duncan2010PA$di, by = 'GEOID')
    -
    # Visualize the DI values (2006-2010 5-year ACS) for Pennsylvania, U.S.A., counties 
    +  left_join(duncan2010PA$d, by = 'GEOID')
    +
    # Visualize the D values (2006-2010 5-year ACS) for Pennsylvania, U.S.A., counties 
     ggplot() +
       geom_sf(
         data = PA2010duncan,
    -    aes(fill = DI),
    +    aes(fill = D),
         size = 0.05,
         color = 'white'
       ) +
    @@ -1914,10 +1917,10 @@ 

    Compute racial/ethnic Dissimilarity Index (DI)

    )

    -
    +

    Compute aspatial income or racial/ethnic Atkinson Index -(AI)

    -

    Compute the aspatial income or racial/ethnic AI values +(A) +

    Compute the aspatial income or racial/ethnic A values (2017-2021 5-year ACS) for Kentucky, U.S.A., counties from census block groups. This metric is based on Atkinson (1970) that assessed the distribution of income within 12 counties but has since been adapted @@ -2046,13 +2049,13 @@

    Compute aspatial income or racial/ethnic Atkinson Index -

    AI is a measure of the inequality and, in the context of +

    A is a measure of the inequality and, in the context of residential race/ethnicity, 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 and -smaller values of the index indicate lower levels of inequality (e.g., -less segregation).

    -

    AI is sensitive to the choice of epsilon +areas are located. A can range in value from 0 to 1 and smaller +values of the index indicate lower levels of inequality (e.g., less +segregation).

    +

    A is sensitive to the choice of epsilon argument or the shape parameter that determines how to weight the increments to inequality (segregation) contributed by different proportions of the Lorenz curve. A user must explicitly decide how @@ -2084,14 +2087,14 @@

    Compute aspatial income or racial/ethnic Atkinson Index # Obtain the 2021 census counties from the 'tigris' package county2021KY <- counties(state = 'KY', year = 2021, cb = TRUE) -# Join the AI values to the county geometry +# Join the A values to the county geometry KY2021atkinson <- county2021KY %>% - left_join(atkinson2021KY$ai, by = 'GEOID')

    -
    # Visualize the AI values (2017-2021 5-year ACS) for Kentucky, U.S.A., counties
    +  left_join(atkinson2021KY$a, by = 'GEOID')
    +
    # Visualize the A values (2017-2021 5-year ACS) for Kentucky, U.S.A., counties
     ggplot() +
       geom_sf(
         data = KY2021atkinson,
    -    aes(fill = AI),
    +    aes(fill = A),
         size = 0.05,
         color = 'white'
       ) +
    @@ -2110,14 +2113,14 @@ 

    Compute aspatial income or racial/ethnic Atkinson Index )

    -
    -

    Compute racial/ethnic Isolation Index (II)

    -

    Compute the aspatial racial/ethnic II values (2017-2021 -5-year ACS) for Ohio, U.S.A., counties from census block groups. This -metric is based on Shevky & Williams (1949; -ISBN-13:978-0-837-15637-8) and adapted by Bell (1954). Multiple -racial/ethnic subgroups are available in the bell() -function, including:

    +
    +

    Compute racial/ethnic Interaction Index (xPy*)

    +

    Compute the aspatial racial/ethnic xPy* values (2017-2021 +5-year ACS) for Ohio, U.S.A., counties from census tracts. This metric +is based on Shevky & Williams (1949; ISBN-13:978-0-837-15637-8) and +adapted by Bell (1954). +Multiple racial/ethnic subgroups are available in the +bell() function, including:

    @@ -2128,7 +2131,7 @@

    Compute racial/ethnic Isolation Index (II)

    - @@ -2239,12 +2242,12 @@

    Compute racial/ethnic Isolation Index (II)

    ACS table source racial/ethnic subgroupcharacter for subgroup or or subgroup_ref +character for subgroup or subgroup_ixn argument
    -

    II is some measure of the probability that a member of one +

    xPy* is some measure of the probability that a member of one subgroup(s) will meet or interact with a member of another subgroup(s) with higher values signifying higher probability of interaction (less isolation) when comparing smaller geographical areas to larger ones -within which the smaller geographical areas are located. II can -range in value from 0 to 1.

    +within which the smaller geographical areas are located. xPy* +can range in value from 0 to 1.

    bell2021OH <- bell(
       geo_large = 'county',
       geo_small = 'tract',
    @@ -2257,14 +2260,14 @@ 

    Compute racial/ethnic Isolation Index (II)

    # Obtain the 2021 census counties from the 'tigris' package county2021OH <- counties(state = 'OH', year = 2021, cb = TRUE) -# Join the II values to the county geometry +# Join the xPy* values to the county geometry OH2021bell <- county2021OH %>% - left_join(bell2021OH$ii, by = 'GEOID')
    -
    # Visualize the II values (2017-2021 5-year ACS) for Ohio, U.S.A., counties
    +  left_join(bell2021OH$xpy_star, by = 'GEOID')
    +
    # Visualize the xPy* values (2017-2021 5-year ACS) for Ohio, U.S.A., counties
     ggplot() +
       geom_sf(
         data = OH2021bell,
    -    aes(fill = II),
    +    aes(fill = xPy_star),
         size = 0.05,
         color = 'white'
       ) +
    @@ -2278,10 +2281,10 @@ 

    Compute racial/ethnic Isolation Index (II)

    scale_fill_viridis_c(limits = c(0, 1)) + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2017-2021 estimates') + ggtitle( - 'Isolation Index (Bell)\nOhio census tracts to counties', + 'Interaction Index (Bell)\nOhio census tracts to counties', subtitle = 'Black non-Hispanic vs. white non-Hispanic' )
    -

    +

    Compute Correlation Ratio (V)

    @@ -2418,7 +2421,7 @@

    Compute Correlation Ratio (V)

    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.

    +in value from 0 to Inf.

    white2021SC <- white(
       geo_large = 'county',
       geo_small = 'tract',
    @@ -2448,13 +2451,18 @@ 

    Compute Correlation Ratio (V)

    size = 0.2 ) + theme_minimal() + - scale_fill_viridis_c() + - labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2017-2021 estimates') + - ggtitle( - 'Correlation Ratio (White)\nSouth Carolina census tracts to counties', - subtitle = 'Black non-Hispanic' - )
    -

    + scale_fill_gradient2( + low = '#998ec3', + mid = '#f7f7f7', + high = '#f1a340', + midpoint = 1 + ) + + labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2017-2021 estimates') + + ggtitle( + 'Correlation Ratio (White)\nSouth Carolina census tracts to counties', + subtitle = 'Black non-Hispanic' + )
    +

    Compute Location Quotient (LQ)

    @@ -2649,7 +2657,8 @@

    Compute Local Exposure and Isolation (LEx/Is)

    ACS table source racial/ethnic subgroup -character for subgroup argument +character for subgroup or subgroup_ixn +argument @@ -3202,7 +3211,178 @@

    Compute an index of spatial proximity (SP)

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

    -
    sessionInfo()
    + +
    +

    Compute racial/ethnic Isolation Index (xPx*)

    +

    Compute the aspatial racial/ethnic xPx* values (2015-2019 +5-year ACS) for Delaware, U.S.A., census tracts from census block +groups. This metric is based on Bell (1954) and adapted by +Lieberson (1981; ISBN-13:978-1-032-53884-6). Multiple racial/ethnic +subgroups are available in the lieberson() function, +including:

    + +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    ACS table sourceracial/ethnic subgroupcharacter for subgroup argument
    B03002_002not Hispanic or LatinoNHoL
    B03002_003not Hispanic or Latino, white aloneNHoLW
    B03002_004not Hispanic or Latino, Black or African American aloneNHoLB
    B03002_005not Hispanic or Latino, American Indian and Alaska Native aloneNHoLAIAN
    B03002_006not Hispanic or Latino, Asian aloneNHoLA
    B03002_007not Hispanic or Latino, Native Hawaiian and Other Pacific Islander +aloneNHoLNHOPI
    B03002_008not Hispanic or Latino, some other race aloneNHoLSOR
    B03002_009not Hispanic or Latino, two or more racesNHoLTOMR
    B03002_010not Hispanic or Latino, two races including some other raceNHoLTRiSOR
    B03002_011not Hispanic or Latino, two races excluding some other race, and +three or more racesNHoLTReSOR
    B03002_012Hispanic or LatinoHoL
    B03002_013Hispanic or Latino, white aloneHoLW
    B03002_014Hispanic or Latino, Black or African American aloneHoLB
    B03002_015Hispanic or Latino, American Indian and Alaska Native aloneHoLAIAN
    B03002_016Hispanic or Latino, Asian aloneHoLA
    B03002_017Hispanic or Latino, Native Hawaiian and other Pacific Islander +aloneHoLNHOPI
    B03002_018Hispanic or Latino, some other race aloneHoLSOR
    B03002_019Hispanic or Latino, two or more racesHoLTOMR
    B03002_020Hispanic or Latino, two races including some other raceHoLTRiSOR
    B03002_021Hispanic or Latino, two races excluding some other race, and three +or more racesHoLTReSOR
    +

    xPx* is some measure of the probability that a member of one +subgroup(s) will meet or interact with a member of another subgroup(s) +with higher values signifying higher probability of interaction (less +isolation) when comparing smaller geographical areas to larger ones +within which the smaller geographical areas are located. xPx* +can range in value from 0 to 1.

    +
    lieberson2021DE <- lieberson(
    +  geo_large = 'tract',
    +  geo_small = 'block group',
    +  state = 'DE',
    +  year = 2019,
    +  subgroup = 'NHoLB'
    +)
    +
    +# Obtain the 2021 census counties from the 'tigris' package
    +tract2021DE <- tracts(state = 'DE', year = 2019, cb = TRUE)
    +
    +# Join the xPx* values to the county geometry
    +DE2021lieberson <- tract2021DE %>%
    +  left_join(lieberson2021DE$xpx_star, by = 'GEOID')
    +
    # Visualize the xPx* values (2015-2019 5-year ACS) for Delaware, U.S.A., census tracts
    +ggplot() +
    +  geom_sf(
    +    data = DE2021lieberson,
    +    aes(fill = xPx_star),
    +    size = 0.05,
    +    color = 'white'
    +  ) +
    +  geom_sf(
    +    data = tract2021DE,
    +    fill = 'transparent',
    +    color = 'white',
    +    size = 0.2
    +  ) +
    +  theme_minimal() +
    +  scale_fill_viridis_c(limits = c(0, 1)) +
    +  labs(fill = 'Index (Continuous)', caption = 'Source: U.S. Census ACS 2015-2019 estimates') +
    +  ggtitle(
    +    'Isolation Index (Lieberson)\nDelaware census block groups to census tracts',
    +    subtitle = 'Black non-Hispanic'
    +  )
    +

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

    Compute an index of spatial proximity (SP)

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