calculate_adi: Calculate ADI and ADI-3 from census data.

View source: R/calculate_adi.R

calculate_adiR Documentation

Calculate ADI and ADI-3 from census data.

Description

Calculate the Area Deprivation Index and Berg Indices (ADI-3) using decennial US census or American Community Survey (ACS) variables.

Usage

calculate_adi(data_raw, keep_indicators = FALSE, seed = NA)

Arguments

data_raw

A data frame, tibble, or sf object ultimately obtained via tidycensus::get_acs() or tidycensus::get_decennial(), having the data necessary to compute the indicators of the ADI and ADI-3.

The columns of his data frame must be named according to the elements of the variable column in acs_vars and/or decennial_vars.

The easiest way to obtain data like this is to run get_adi(raw_data_only = TRUE).

keep_indicators

Logical indicating whether or not to keep the component indicators of the ADI and ADI-3 as well as the original census variables used to calculate them. Defaults to FALSE.

See acs_vars and decennial_vars for basic descriptions of the raw census variables.

seed

Passed to the seed argument of mice::mice() when imputation is needed.

Details

The function get_adi() calls this function by default as its final step, but some users may want to calculate ADI and ADI-3 values for different combinations of areas in a given data set. get_adi(raw_data_only = TRUE) returns the raw census data used to calculate ADI and ADI-3. Users may select subsets of such a data set and pipe them into calculate_adi().

This function discerns what kind of census data that data contains (ACS, or one of the decennial censuses) by checking for the existence of key variables unique to each kind of data set.

Areas listed as having zero households are excluded from ADI and ADI-3 calculation. Their resulting ADIs and ADI-3s will be NA.

If calling this function directly (i.e., not via get_adi()) on a data set that contains median household income (B19013_001) and does not contain median family income (B19113_001), median household income will be used in place of median family income, with a warning(). See the "Missingness and imputation" section of get_adi().

Value

A tibble (or sf) with the same number of rows as data. Columns include GEOID, NAME, ADI, ⁠Financial Strength⁠, Economic_Hardship_and_Inequality, and Educational_Attainment. Further columns containing the indicators and raw values will also be present if keep_indicators = TRUE.

See Also

For more information, see get_adi(), especially the sections titled ADI and ADI-3 factor loadings and Missingness and imputation.

Examples

## Not run: 
# Wrapped in \dontrun{} because these examples require a Census API key.

raw_census <- get_adi("state", year = 2017, raw_data_only = TRUE)

calculate_adi(raw_census)

calculate_adi(raw_census, keep_indicators = TRUE)

## End(Not run)

sociome documentation built on May 29, 2024, 1:16 a.m.