Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ndi
Title: Neighborhood Deprivation Indices
Version: 0.1.6.9015
Date: 2025-05-30
Version: 0.2.0
Date: 2025-08-29
Authors@R:
c(person(given = "Ian D.",
family = "Buller",
Expand Down Expand Up @@ -38,6 +38,7 @@ Depends:
Imports:
car,
dplyr,
Hmisc,
MASS,
Matrix,
psych,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export(theil)
export(white)
export(white_blau)
import(dplyr)
importFrom(Hmisc,wtd.quantile)
importFrom(MASS,ginv)
importFrom(Matrix,sparseMatrix)
importFrom(car,logit)
Expand Down
7 changes: 4 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ndi (development version)

## ndi v0.1.6.9015
## ndi v0.2.0

### New Features

Expand Down Expand Up @@ -31,7 +31,8 @@
### Updates

#### Bug Fixes
* Fixed NOTE in CRAN checks to provide package anchors for Rd \link{} targets not in the package itself and the base packages within 'ndi-package.Rd'
* Fixed NOTE in CRAN checks to provide package anchors for Rd `\link{}` targets not in the package itself and the base packages within 'ndi-package.Rd'
* Updated population-weighted quantile method from `stats::quantile` to `Hmisc::wtd.quantile` in `powell_wiley()` thanks to a contribution (#32) by [Hunter Miller](https://github.com/huntermills707)
* `bell()` function computes the Interaction Index (Bell) not the Isolation Index as previously documented. Updated documentation throughout.
* Fixed bug in `bell()`, `bemanian_beyer()`, `duncan()`, `sudano()`, and `white()` functions when a smaller geography contains n=0 total population, will assign a value of zero (0) in the internal calculation instead of NA
* Fixed bug in `atkinson()` function to properly compute the income Atkinson Index
Expand All @@ -40,7 +41,7 @@
* Output of racial or ethnic residential segregation indices is now rounded to four significant digits

#### New Dependencies
* `tigris` and `units` are now Imports
* `Hmisc`, `tigris`, and `units` are now Imports

#### Updated Documentation
* Split up vignette into three separate vignettes: 'ndi1', 'ndi2', and 'ndi3' for the *NDI*, racial or ethnic residential segregation, and additional socioeconomic disparity indices, respectively
Expand Down
5 changes: 3 additions & 2 deletions R/ndi-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,18 @@
#' @name ndi-package
#' @aliases ndi-package ndi
#'
#' @section Dependencies: The 'ndi' package relies heavily upon \code{\link[tidycensus]{tidycensus}} to retrieve data from the U.S. Census Bureau American Community Survey five-year estimates and the \code{\link[psych]{psych}} for computing the neighborhood deprivation indices. The \code{\link{messer}} function builds upon code developed by Hruska et al. (2022) \doi{10.17605/OSF.IO/M2SAV} by fictionalizing, adding the percent of households earning <$30,000 per year to the \emph{NDI} computation, and providing the option for computing the ACS-5 2006-2010 \emph{NDI} values. There is no code companion to compute \emph{NDI} included in Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} or Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002}, but the package author worked directly with the Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} authors to replicate their SAS code in \strong{R}. The indices of racial or ethnic residential segregation rely heavily on the \code{\link[sf]{sf}} and \code{\link[tigris]{tigris}} packages to assign the smaller geographical units within larger geographical units and, occasionally, perform geospatial projection for distance-based metrics. The computation of \emph{RI} and \emph{EI} also relies on the \code{\link[Matrix]{Matrix}} package to compute the geospatial adjacency matrix between census geographies. Internal function to calculate \emph{AI} using the Hölder mean is based on \code{\link[DescTools]{Atkinson}} function.
#' @section Dependencies: The 'ndi' package relies heavily upon \code{\link[tidycensus]{tidycensus-package}} to retrieve data from the U.S. Census Bureau American Community Survey five-year estimates and the \code{\link[psych]{psych-package}} for computing the neighborhood deprivation indices. The \code{\link{messer}} function builds upon code developed by Hruska et al. (2022) \doi{10.17605/OSF.IO/M2SAV} by fictionalizing, adding the percent of households earning <$30,000 per year to the \emph{NDI} computation, and providing the option for computing the ACS-5 2006-2010 \emph{NDI} values. There is no code companion to compute \emph{NDI} included in Andrews et al. (2020) \doi{10.1080/17445647.2020.1750066} or Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002}, but the package author worked directly with the Slotman et al. (2022) \doi{10.1016/j.dib.2022.108002} authors to replicate their SAS code in \strong{R}. The indices of racial or ethnic residential segregation rely heavily on the \code{\link[sf]{sf-package}} and \code{\link[tigris]{tigris-package}} packages to assign the smaller geographical units within larger geographical units and, occasionally, perform geospatial projection for distance-based metrics. The computation of \emph{RI} and \emph{EI} also relies on the \code{\link[Matrix]{sparseMatrix}} function to compute the geospatial adjacency matrix between census geographies. Internal function to calculate \emph{AI} using the Hölder mean is based on \code{\link[DescTools]{Atkinson}} function.
#'
#' @author Ian D. Buller\cr \emph{DLH, LLC (formerly DLH Corporation and Social & Scientific Systems, Inc.), Bethesda, Maryland, USA (current); Occupational and Environmental Epidemiology Branch, Division of Cancer Epidemiology and Genetics, National Cancer Institute, National Institutes of Health, Rockville, Maryland, USA (original).} \cr
#'
#' Maintainer: I.D.B. \email{ian.buller@@alumni.emory.edu}
#'
#' @keywords internal
'_PACKAGE'
"_PACKAGE"

#' @import dplyr
#' @importFrom car logit
#' @importFrom Hmisc wtd.quantile
#' @importFrom MASS ginv
#' @importFrom Matrix sparseMatrix
#' @importFrom psych alpha principal
Expand Down
12 changes: 7 additions & 5 deletions R/powell_wiley.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#'
#' 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 \emph{NDI} (Powell-Wiley) values are population-weighted quintiles of the continuous \emph{NDI} (Powell-Wiley) values.
#' The categorical \emph{NDI} (Powell-Wiley) values are population-weighted quintiles of the continuous \emph{NDI} (Powell-Wiley) values. NOTE: As of version 0.2.0, population-weighted quintiles are computed using a weighted quantile function \code{\link[Hmisc]{wtd.quantile}} where values are calculated NDI and weights are Total Population instead of previously using \code{\link[stats]{quantile}} of the product of the calculated NDI and natural logarithm transformed total population.
#'
#' Check if the proportion of variance explained by the first principal component is high (more than 0.5).
#'
Expand All @@ -53,9 +53,10 @@
#' @references Slotman, BA, Stinchcomb, DG, Powell-Wiley, TM, Ostendorf, DM, Saelens, BE, Gorin, AA, Zenk, SN, & Berrigan, D (2022) Environmental Data and Methods from the Accumulating Data to Optimally Predict Obesity Treatment (ADOPT) Core Measures Environmental Working Group. \emph{Data in Brief}, 41:108002. \doi{10.1016/j.dib.2022.108002}
#'
#' @import dplyr
#' @importFrom Hmisc wtd.quantile
#' @importFrom MASS ginv
#' @importFrom psych alpha principal
#' @importFrom stats complete.cases cor cov2cor loadings median promax quantile sd
#' @importFrom stats complete.cases cor cov2cor loadings median promax sd
#' @importFrom stringr str_trim
#' @importFrom tidycensus get_acs
#' @importFrom tidyr pivot_longer separate
Expand Down Expand Up @@ -350,9 +351,10 @@ powell_wiley <- function(geo = 'tract',
NDIQuint <- ndi_data_NDI %>%
dplyr::mutate(
NDIQuint = cut(
NDI * log(TotalPop),
breaks = stats::quantile(
NDI * log(TotalPop),
NDI,
breaks = Hmisc::wtd.quantile(
NDI,
weights = TotalPop,
probs = c(0, 0.2, 0.4, 0.6, 0.8, 1),
na.rm = TRUE
),
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
[![CRAN RStudio mirror downloads monthly](https://cranlogs.r-pkg.org/badges/ndi)](https://r-pkg.org:443/pkg/ndi)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/license/apache-2-0)
![GitHub last commit](https://img.shields.io/github/last-commit/idblr/ndi)
[![DOI](https://zenodo.org/badge/521439746.svg)](https://zenodo.org/badge/latestdoi/521439746)
[![](https://img.shields.io/badge/DOI-10.32614/CRAN.package.ndi-1f57b6?style=flat&link=https://doi.org/10.32614/CRAN.package.ndi)](https://doi.org/10.32614/CRAN.package.ndi)
<!-- badges: end -->

**Date repository last updated**: 2025-05-30
**Date repository last updated**: 2025-08-29

### Overview

Expand Down Expand Up @@ -182,6 +182,8 @@ See also the list of [contributors](https://github.com/idblr/ndi/graphs/contribu

* **Jessica Gleason** - *Epidemiology Branch, Division of Population Health Research, Eunice Kennedy Shriver National Institute of Child Health and Human Development, National Institutes of Health, Bethesda, Maryland* - [ORCID](https://orcid.org/0000-0001-9877-7931)

* **Hunter Mills** - [GitHub](https://github.com/huntermills707)

* **Chris Prener** - *Real World Evidence Center of Excellence, Pfizer, Inc.* - [GitHub](https://github.com/chris-prener) - [ORCID](https://orcid.org/0000-0002-4310-9888)

* **Davis Vaughan** - *Posit* - [GitHub](https://github.com/DavisVaughan) - [ORCID](https://orcid.org/0000-0003-4777-038X)
Expand Down
37 changes: 27 additions & 10 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## This is the seventh resubmission

* Actions taken since previous submission:

#### New Functions
* Added `denton()` function to compute the aspatial racial or ethnic Relative Clustering (*RCL*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281)
* Added `denton_cuzzort()` function to compute the aspatial racial or ethnic Relative Concentration (*RCO*) based on [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281) and Duncan, Cuzzort, & Duncan (1961; LC:60007089)
* Added `duncan_cuzzort()` function to compute the aspatial racial or ethnic Absolute Centralization (*ACE*) based on Duncan, Cuzzort, & Duncan (1961; LC:60007089) and [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281)
Expand All @@ -14,19 +16,28 @@
* Added `morgan_massey()` function to compute the aspatial racial or ethnic Distance-Decay Isolation Index (_DPxx\*_) based on [Morgan (1983)](https://www.jstor.org/stable/20001935) and [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281)
* Added `theil()` function the aspatial racial or ethnic Entropy (*H*) based on Theil (1972; ISBN:978-0-444-10378-9) and [Theil & Finizza (1971)](https://doi.org/110.1080/0022250X.1971.9989795)
* Added `white_blau()` function to compute an index of spatial proximity (*SP*) based on [White (1986)](https://doi.org/10.2307/3644339) and Blau (1977; ISBN-13:978-0-029-03660-0)

#### New Function Capabilities
* Added `geo_large = 'place'` for census-designated places, `geo_large = 'cbsa'` for core-based statistical areas, `geo_large = 'csa'` for combined statistical areas, and `geo_large = 'metro'` for metropolitan divisions as the larger geographical unit in `atkinson()`, `bell()`, `bemanian_beyer()`, `denton()`, `denton_cuzzort()`, `duncan()`, `duncan_cuzzort()`, `duncan_duncan()`, `hoover()`, `james_taeuber()`, `lieberson()`, `massey()`, `massey_duncan()`, `morgan_denton()`, `morgan_massey()`, `sudano()`, `theil()`, and `white()`, `white_blau()` functions.
* Added census block group computation for `anthopolos()` by specifying `geo == 'cbg'` or `geo == 'block group'`
* Added `holder` argument to `atkinson()` function to toggle the computation with or without the Hölder mean. The function can now compute *A* without the Hölder mean. The default is `holder = FALSE`.
* Added `crs` argument to `anthopolos()`, `bravo()`, and `white_blau()` functions to provide spatial projection of the distance-based metrics
* The `gini()` function now computes the aspatial racial or ethnic Gini Index (*G*) based on [Gini (1921)](https://doi.org/10.2307/2223319) as the main outcome. Arguments `geo_large`, `geo_small`, `subgroup`, and `omit_NAs` were added and argument `geo` was deprecated. The `gini()` function still retrieves the original output of the aspatial income Gini Index (*G*) at each smaller geography and is moved from the `g` output to `g_data` output.
* Specifying census block groups in `geo` or `geo_small` arguments is now `'block group'` or `'cbg'` to match internal `get_acs()` function from the [tidycensus](https://CRAN.R-project.org/package=tidycensus) package
* Fixed NOTE in CRAN checks to provide package anchors for Rd \link{} targets not in the package itself and the base packages within 'ndi-package.Rd'

#### Bug Fixes
* Fixed NOTE in CRAN checks to provide package anchors for Rd `\link{}` targets not in the package itself and the base packages within 'ndi-package.Rd'
* Updated population-weighted quantile method from `stats::quantile` to `Hmisc::wtd.quantile` in `powell_wiley()`
* `bell()` function computes the Interaction Index (Bell) not the Isolation Index as previously documented. Updated documentation throughout.
* Fixed bug in `bell()`, `bemanian_beyer()`, `duncan()`, `sudano()`, and `white()` functions when a smaller geography contains n=0 total population, will assign a value of zero (0) in the internal calculation instead of NA
* Fixed bug in `atkinson()` function to properly compute the income Atkinson Index
* Renamed *AI* as *A*, *DI* as *D*, *Gini* as *G*, and *II* as _xPy\*_ to align with the definitions from [Massey & Denton (1988)](https://doi.org/10.1093/sf/67.2.281). The output for `atkinson()` now produces `a` instead of `ai`. The output for `duncan()` now produces `d` instead of `ai`. The output for `gini()` now produces `g` instead of `gini`. The output for `bell()` now produces `xPy_star` instead of `II`. The internal functions `ai_fun()`, `di_fun()` and `ii_fun()` were renamed `a_fun()`, `ddd_fun()` and `xpy_star_fun()`, respectively.
* Output of racial or ethnic residential segregation indices is now rounded to four significant digits
* `tigris` and `units` are now Imports

#### New Dependencies
* `Hmisc`, `tigris`, and `units` are now Imports

#### Updated Documentation
* Reformatted functions for consistent internal structure
* 'package.R' deprecated. Replaced with 'ndi-package.R' and reordered the contents
* Consolidated DESCRIPTION
Expand All @@ -52,19 +63,25 @@
* <https://doi.org/10.1080/17445647.2020.1750066>
* <https://doi.org/10.2307/3644339>
* <https://doi.org/10.2307/2084686>
* The win-builder oldrelease throws a NOTE that "Author field differs from that derived from Authors@R". The behavior is OK because ORCID has different formatting but same information

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

## Test environments
* local Windows install, R 4.4.1
* local Windows install, R 4.5.1
* win-builder, (devel, release, oldrelease)
* Rhub
* Fedora Linux, R-devel, clang, gfortran
* Ubuntu Linux 20.04.1 LTS, R-release, GCC
* Windows Server 2022, R-devel, 64 bit
* Windows Server 2008 R2 SP1, R-release, 32⁄64 bit
* Oracle Solaris 10, x86, 32 bit, R-release
* macOS 10.13.6 High Sierra, R-release, CRAN's setup
* R-CMD-check on GitHub
* macos-latest (release)
* windows-latest (release)
* ubuntu-latest (devel)
* ubuntu-latest (release)
* ubuntu-latest (oldrel-1)
* Rhub v2
* macos-15 on GitHub, ASAN + UBSAN on macOS (`m1-san`)
* macos-13 on GitHub(`macos`)
* Fedora Linux 40 (Container Image) (`gcc-asan`)
* Ubuntu 22.04.5 LTS (`ubuntu-clang`)
* Ubuntu 22.04.5 LTS (`ubuntu-gcc12`)

## R CMD check results
0 errors | 0 warnings | 0 notes
Expand Down
4 changes: 2 additions & 2 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ bibentry(bibtype = 'manual',
author = as.person('Ian D. Buller'),
publisher = 'The Comprehensive R Archive Network',
year = '2025',
number = '0.1.6.9015.',
number = '0.2.0.',
doi = '10.32614/CRAN.package.ndi',
url = 'https://cran.r-project.org/package=ndi',

textVersion =
paste('Ian D. Buller (2025)',
'ndi: Neighborhood Deprivation Indices.',
'The Comprehensive R Archive Network.',
'v0.1.6.9015.',
'v0.2.0.',
'DOI:10.32614/CRAN.package.ndi',
'Accessed by: https://cran.r-project.org/package=ndi'),

Expand Down
Loading
Loading