ej.indexes: Calculate environmental justice (EJ) index for each place

View source: R/ej.indexes.R

ej.indexesR Documentation

Calculate environmental justice (EJ) index for each place

Description

Create an index that combines environmental and demographic indicators for each Census unit (e.g., block group).

Usage

ej.indexes(
  env.df,
  demog,
  weights,
  us.demog,
  universe.us.demog,
  as.df = TRUE,
  prefix = "EJ.DISPARITY.",
  type = 1,
  na.rm = FALSE
)

Arguments

env.df

Environmental indicators vector or numeric data.frame, one column per environmental factor, one row per place (e.g., block group).

demog

Demographic indicator(s) vector or data.frame, numeric fractions of population that is in specified demographic group (e.g., fraction below poverty line), one per place.

weights

Optional, and default is equal weighting. If us.demog and universe.us.demog are not specified, weights are used to find weighted mean of demog to use as area-wide overall average (e.g., population-weighted average percent Hispanic, for all block groups in USA). One weight per place.

us.demog

Optional overall area-wide value for demog percentage share of population as fraction 0 to 1 (e.g., US Demographic Indicator). The correct value to use for EJScreen 2.0, for example, is with(ejscreen::bg21, ( sum(mins)/sum(pop) + sum(lowinc)/sum(povknownratio) ) / 2) Default is to approximate it as weighted mean of demog, where the weights are universe.us.demog if specified, or else just 'weights'. If the weights are population counts and demog is percent Hispanic, for example, us.demog is the percent of US population that is Hispanic.

universe.us.demog

Optional numeric vector. If specified and us.demog not specified, used instead of weights to get weighted mean of demog to find area-wide demog. This should be the actual denominator, or universe, that was used to create percent demog – universe.us.demog if specified should be a vector that has the count, for each place, of the denominator for finding the US overall percent and this may be slightly different than total population. For example if demog=places$pctlowinc then true universe.us.demog=places$povknownratio which is the count for whom poverty ratio is known in each place, which is <= pop.

as.df

Default is TRUE.

prefix

Optional character string used as first part of each colname in results. Default is "EJ.DISPARITY."

type

Specifies type of EJ Index. Default is type=1. Several formulas are available:

  • For type=1, ej.indexes = weights * env.df * (demog - us.demog) ## This is the EJ Index in EJScreen from 2015-2022. Note: us.demog could also be called d.avg.all, and note that na.rm is currently ignored for type=1

  • For type=1.5, ej.indexes = weights * env.df * (demog - d.avg.all.elsewhere) # for a place that is one of many this can be almost identical to type 1

  • For type=2.1, ej.indexes = weights * demog * (env.df - e.avg.all) # like type 1 but env and demog roles are swapped

  • For type=2, ej.indexes = weights * demog * (env.df - e.avg.nond)

  • For type=2.5, ej.indexes = weights * demog * (env.df - e.avg.nond.elsewhere )

  • For type=3, ej.indexes = weights * ((demog * env.df) - (d.avg.all * e.avg.nond ) )

  • For type=3.5, ej.indexes = weights * ((demog * env.df) - (d.avg.all.elsewhere * e.avg.nond.elsewhere) )

  • For type 4 , ej.indexes = weights * ((demog - d.avg.all ) * (env.df - e.avg.nond ) )

  • For type=4.5, ej.indexes = weights * ((demog - d.avg.all.elsewhere) * (env.df - e.avg.nond.elsewhere) )

  • For type=5 , ej.indexes = weights * env.df * demog ## A "Population Risk" or "Burden" index = Number of cases among D group if e is individual risk, or just "people-points among D" if e is "points"

  • For type=6, ej.indexes = env.df * demog ## A "unweighted" simple product of Envt x percent_D. A "percent-based" indicator = percent in group D times envt indicator

  • For type=7, ej.indexes = env.df * (demog - us.demog) # Like type 1 or EJScreen 2.0, but without the pop count in the formula

where

  • us.demog = overall demog where avg person lives (pop wtd mean of demog). This may be almost exactly the same as d.avg.all.elsewhere

  • d.avg.all = overall value for d as fraction of entire population (including the one place being analyzed).

  • d.avg.all.elsewhere = overall value for d as fraction of entire population other than the one place being analyzed.

  • e.avg.all = avg environmental indicator value for average person

  • e.avg.nond = avg environmental indicator value for average person who is not in the D-group, among all (including the one place being analyzed). This is typically the expected as opposed to observed value of e within group D, in the context of EJ analysis of disparity in e.

  • e.avg.nond.elsewhere = avg environmental indicator value for average person who is not in the D-group, among all except in the one place being analyzed.

na.rm

Default is FALSE. NOTE: This is complicated but important. See notes in source code about handling NA values in various formulas here.

Details

Creates one EJ index column for each environmental indicator column, or if given a vector or single column of environmental indicators instead of data.frame, returns a vector or column. Each "place" can be a Census unit such as a State, County, zip code, tract, block group, block, for example (or even by individual if person-level data are available).

Note: For 1.5, 3.5, 4.5 need vector d.avg.all.elsewhere. calculated in each of those.

  • But does not properly handle cases where us.demog or universe.us.demog specified because denominator is not same as pop

  • and need to fix for when is.na(p) | is.na(demog)
    Type 2 however does handle NA values appropriately, meaning a result for a given col of env.df is set to NA for a given row
    (assuming na.rm=FALSE) if and only if NA is found in that row, in demog or weights or that one col of env.df.

Value

Returns a numeric data.frame (or matrix if as.df=FALSE) of EJ indexes, one per place per environmental indicator.

Examples

 statedat <- data.frame(state.x77)
 hist(myej <- ej.indexes(env.df=statedat[ , c('Life.Exp', 'Frost')],
  demog=statedat$HS.Grad/100, weights=statedat$Population, prefix='EJtype1.', type=1 ))
 set.seed(999)
 myej <- ej.indexes(env.df=rnorm(1000, 10, 3), demog=runif(1000, 0, 1),
  weights=runif(1000, 500, 5000))
 myej

ejanalysis/ejanalysis documentation built on April 2, 2024, 10:12 a.m.