threshold_rates: Compute Error Rates at a Specific Threshold

View source: R/threshold_rates.R

threshold_ratesR Documentation

Compute Error Rates at a Specific Threshold

Description

Calculates error rates and performance metrics for a given likelihood ratio (LR) threshold, including:

  • False Positive Rate (FPR)

  • False Negative Rate (FNR)

  • Matthews Correlation Coefficient (MCC)

Usage

threshold_rates(datasim, threshold)

Arguments

datasim

A data.frame with columns Related and Unrelated containing LR values. Can be output from sim_lr_genetic, sim_lr_prelim, lr_to_dataframe, or lr_combine.

threshold

Numeric. The LR threshold value for which to compute error rates. Cases with LR > threshold are classified as matches.

Details

If the input is a list (output from sim_lr_genetic), it is automatically converted to a data.frame using lr_to_dataframe.

Metrics:

  • FPR: Proportion of unrelated cases incorrectly classified as matches (LR > threshold when H2 is true)

  • FNR: Proportion of related cases incorrectly classified as non-matches (LR < threshold when H1 is true)

  • TPR: 1 - FNR (sensitivity, recall)

  • TNR: 1 - FPR (specificity)

  • MCC: Matthews Correlation Coefficient, ranges from -1 to +1:

    • +1: Perfect classification

    • 0: Random classification

    • -1: Completely wrong classification

Value

Prints the error rates and MCC, and invisibly returns a named list with components:

  • FNR: False Negative Rate

  • FPR: False Positive Rate

  • TPR: True Positive Rate

  • TNR: True Negative Rate

  • MCC: Matthews Correlation Coefficient

References

Marsico FL, Vigeland MD, Egeland T, Herrera Pinero F (2021). "Making decisions in missing person identification cases with low statistical power." Forensic Science International: Genetics, 52, 102519. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.fsigen.2021.102519")}

Matthews BW (1975). "Comparison of the predicted and observed secondary structure of T4 phage lysozyme." Biochimica et Biophysica Acta, 405(2), 442-451.

See Also

decision_threshold for finding optimal threshold, plot_decision_curve for visualizing the FPR/FNR trade-off.

Examples

# Simulate LRs
lr_sims <- sim_lr_prelim("sex", numsims = 500, seed = 123)

# Check error rates at threshold = 10
rates <- threshold_rates(lr_sims, threshold = 10)

# Access individual metrics
rates$FPR
rates$MCC

# Compare different thresholds
threshold_rates(lr_sims, threshold = 5)
threshold_rates(lr_sims, threshold = 50)
threshold_rates(lr_sims, threshold = 100)

mispitools documentation built on Aug. 26, 2026, 1:08 a.m.