View source: R/threshold_rates.R
| threshold_rates | R Documentation |
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)
threshold_rates(datasim, threshold)
datasim |
A data.frame with columns |
threshold |
Numeric. The LR threshold value for which to compute error rates. Cases with LR > threshold are classified as matches. |
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
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
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.
decision_threshold for finding optimal threshold,
plot_decision_curve for visualizing the FPR/FNR trade-off.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.