npv_parity: Negative Predictive Value parity

Description Usage Arguments Details Value Examples

View source: R/npv_parity.R

Description

This function computes the Negative Predictive Value (NPV) parity metric

Formula: TN / (TN + FN)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
npv_parity(
  data,
  outcome,
  group,
  probs = NULL,
  preds = NULL,
  outcome_base = NULL,
  cutoff = 0.5,
  base = NULL,
  group_breaks = NULL
)

Arguments

data

Data.frame that contains the necessary columns.

outcome

Column name indicating the binary outcome variable (character).

group

Column name indicating the sensitive group (character).

probs

Column name or vector with the predicted probabilities (numeric between 0 - 1). Either probs or preds need to be supplied.

preds

Column name or vector with the predicted binary outcome (0 or 1). Either probs or preds need to be supplied.

outcome_base

Base level of the outcome variable (i.e., negative class). Default is the first level of the outcome variable.

cutoff

Cutoff to generate predicted outcomes from predicted probabilities. Default set to 0.5.

base

Base level of the sensitive group (character).

group_breaks

If group is continuous (e.g., age): either a numeric vector of two or more unique cut points or a single number >= 2 giving the number of intervals into which group feature is to be cut.

Details

This function computes the Negative Predictive Value (NPV) parity metric as described by the Aequitas bias toolkit. Negative Predictive Values are calculated by the division of true negatives with all predicted negatives. In the returned named vector, the reference group will be assigned 1, while all other groups will be assigned values according to whether their negative predictive values are lower or higher compared to the reference group. Lower negative predictive values will be reflected in numbers lower than 1 in the returned named vector, thus numbers lower than 1 mean WORSE prediction for the subgroup.

Value

Metric

Raw negative predictive values for all groups and metrics standardized for the base group (negative predictive value parity metric). Lower values compared to the reference group mean lower negative predictive values in the selected subgroups

Metric_plot

Bar plot of Negative Predictive Value metric

Probability_plot

Density plot of predicted probabilities per subgroup. Only plotted if probabilities are defined

Examples

1
2
3
4
5
6
data(compas)
compas$Two_yr_Recidivism_01 <- ifelse(compas$Two_yr_Recidivism == 'yes', 1, 0) 
npv_parity(data = compas, outcome = 'Two_yr_Recidivism_01', group = 'ethnicity',
probs = 'probability', cutoff = 0.4, base = 'Caucasian')
npv_parity(data = compas, outcome = 'Two_yr_Recidivism_01', group = 'ethnicity',
preds = 'predicted', cutoff = 0.5, base = 'Hispanic')

fairness documentation built on April 14, 2021, 5:09 p.m.