di_calc_dt {DisImpact}R Documentation

Calculates disproportionate impact using multiple methods for data stored in a data.table object.

Description

Calculate disproportionate impact via the percentage point gap (PPG), proportionality index, and 80% index methods for data stored in a data.table object. This is the workhorse function leveraged by the di_iterate_dt function.

Usage

di_calc_dt(
  dt,
  success_var,
  group_var,
  cohort_var = "",
  weight_var = NULL,
  ppg_reference_group = "overall",
  min_moe = 0.03,
  use_prop_in_moe = FALSE,
  prop_sub_0 = 0.5,
  prop_sub_1 = 0.5,
  di_prop_index_cutoff = 0.8,
  di_80_index_cutoff = 0.8,
  di_80_index_reference_group = "hpg",
  filter_subset = ""
)

Arguments

dt

A data frame of class data.table. If the object is not a data table, one could surround the object with as.data.table.

success_var

A character value specifying the success variable name.

group_var

A character value specifying the group (disaggregation) variable name.

cohort_var

(Optional) A character value specifying the cohort variable. If not specified, then a single cohort is assumed (defaults to an empty string, '').

weight_var

(Optional) A character variable specifying the weight variable if the input data set is summarized (i.e., the the success variables specified in success_vars contain count of successes). Weight here corresponds to the denominator when calculating the success rate. Defaults to NULL for an input data set where each row describes an individual.

ppg_reference_group

Either 'overall', 'hpg', 'all but current', or a character value specifying a group from group_var to be used as the reference group for comparison using percentage point gap method.

min_moe

The minimum margin of error to be used in the PPG calculation; see di_ppg.

use_prop_in_moe

(TRUE or FALSE) Whether the estimated proportions should be used in the margin of error calculation by the PPG; see di_ppg.

prop_sub_0

Default is 0.50; see di_ppg.

prop_sub_1

Default is 0.50; see di_ppg.

di_prop_index_cutoff

Threshold used for determining disproportionate impact using the proportionality index; see di_prop_index; defaults to 0.80.

di_80_index_cutoff

Threshold used for determining disproportionate impact using the 80% index; see di_80_index; defaults to 0.80.

di_80_index_reference_group

Either 'overall', 'hpg', 'all but current', or a character value specifying a group from group_var to be used as the reference group for comparison using 80% index.

filter_subset

A character value such as "Ethnicity == 'White' & Gender == 'M'" used in the i argument (filtering rows via dt[i, j, by]) to filter data in dt. The character value is parsed using eval(parse(text=filter_subset)). Defaults to '' for no filtering.

Value

A data.table object with summarized results.


[Package DisImpact version 0.0.21 Index]