Title: | Plot Full ROC Curves using Eyewitness Lineup Data |
---|---|
Description: | Enable researchers to adjust identification rates using the 1/(lineup size) method, generate the full receiver operating characteristic (ROC) curves, and statistically compare the area under the curves (AUC). References: Yueran Yang & Andrew Smith. (2022). "fullROC: An R package for generating and analyzing eyewitness-lineup ROC curves". Behavior Research Methods. <doi:10.3758/s13428-022-01807-6>, Andrew Smith, Yueran Yang, & Gary Wells. (2020). "Distinguishing between investigator discriminability and eyewitness discriminability: A method for creating full receiver operating characteristic curves of lineup identification performance". Perspectives on Psychological Science, 15(3), 589-607. <doi:10.1177/1745691620902426>. |
Authors: | Yueran Yang [aut, cre] |
Maintainer: | Yueran Yang <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.1 |
Built: | 2025-02-26 04:44:50 UTC |
Source: | https://github.com/yuerany/fullroc |
A function to simulate bootstrap samples and calculate AUC.
auc_boot( data, group = NULL, nboot = 1000, byDR = FALSE, ca_adj = FALSE, lsize = 6, csize = 3 )
auc_boot( data, group = NULL, nboot = 1000, byDR = FALSE, ca_adj = FALSE, lsize = 6, csize = 3 )
data |
A data frame or matrix saving both cp and ca frequencies. cp must precede ca. |
group |
A vector indicating group membership. Will calculate AUCs by group. |
nboot |
Number of bootstrap iterations for each group. Defaults to 1,000. |
byDR |
Whether to order ids by diagnosticity ratios. Defaults to FALSE. |
ca_adj |
Whether to adjust id rates for ca lineups after simulating a sample from the unadjusted rates. |
lsize |
Size of lineup (used to adjust id rates). Defaults to 6. |
csize |
Number of confidence levels (used to adjust id rates). Defaults to 3. |
A list with simulated AUCs.
cpf <- c(100, 90, 80, 20, 10, 5) caf <- c(6, 7, 15, 50, 75, 120) auc_boot(cbind(cpf, caf), nboot = 100)
cpf <- c(100, 90, 80, 20, 10, 5) caf <- c(6, 7, 15, 50, 75, 120) auc_boot(cbind(cpf, caf), nboot = 100)
A function to simulate bootstrap samples and calculate CIs for AUC and differences.
auc_ci(cpf, caf, group = NULL, nboot = 1000, alpha = 0.05, ...)
auc_ci(cpf, caf, group = NULL, nboot = 1000, alpha = 0.05, ...)
cpf |
A vector of cp frequencies. |
caf |
A vector of ca frequencies. |
group |
A vector indicating group membership. Will calculate AUC by group. |
nboot |
Number of bootstrap iterations. Defaults to 1,000. |
alpha |
Alpha level for the CIs. Defaults to 0.05. |
... |
Additional arguments in auc_boot. Will allow users to adjust ca id rates in each simulation. |
A data frame of CIs for each group and group differences.
Yueran Yang & Andrew Smith. (2020). "fullROC: An R package for generating and analyzing eyewitness-lineup ROC curves" doi:10.13140/RG.2.2.20415.94885/1
Andrew Smith, Yueran Yang, & Gary Wells. (2020). "Distinguishing between investigator discriminability and eyewitness discriminability: A method for creating full receiver operating characteristic curves of lineup identification performance". Perspectives on Psychological Science, 15(3), 589-607. doi:10.1177/1745691620902426
cpf1 <- c(100, 90, 80, 20, 10, 5) caf1 <- c(6, 7, 15, 50, 75, 120) auc_ci(cpf1, caf1, nboot = 50) cpf2 <- c(90, 40, 20) caf2 <- c(10, 70, 80) auc_ci(cpf2, caf2, nboot = 100) ## compare two groups cpf <- c(cpf1, cpf2) caf <- c(caf1, caf2) group <- rep(letters[1:2], times = c(length(cpf1), length(cpf2) ) ) auc_ci(cpf, caf, group = group)
cpf1 <- c(100, 90, 80, 20, 10, 5) caf1 <- c(6, 7, 15, 50, 75, 120) auc_ci(cpf1, caf1, nboot = 50) cpf2 <- c(90, 40, 20) caf2 <- c(10, 70, 80) auc_ci(cpf2, caf2, nboot = 100) ## compare two groups cpf <- c(cpf1, cpf2) caf <- c(caf1, caf2) group <- rep(letters[1:2], times = c(length(cpf1), length(cpf2) ) ) auc_ci(cpf, caf, group = group)
A function to generate cumulative id rates for both cp and ca lineups
data_cum(data, byDR = FALSE)
data_cum(data, byDR = FALSE)
data |
A matrix with both cp and ca id rates. |
byDR |
Whether to order ids by diagnosticity ratios. Defaults to FALSE. |
A data matrix with cumulative cp and ca id rates.
A function to adjust the id rates for ca lineups using the 1/(lineup size) method; is applicable to ordered id rates with the same confidence levels for all responses.
id_adj(rate, lsize = 6, csize = 3)
id_adj(rate, lsize = 6, csize = 3)
rate |
ID rate vector. |
lsize |
Lineup size. Defaults to 6. |
csize |
Number of confidence levels. Defaults to 3. |
Adjusted ID vector.
ca_id <- c(rep(0,3), rep(c(0.1, 0.15, 0.25), 2)) id_adj(ca_id) ## change line size to 5 id_adj(ca_id, lsize = 5) ## For multiple groups ca_id2 <- c(c(rep(0,3), rep(c(0.1, 0.15, 0.25), 2)), c(rep(0,3), rep(c(0.1, 0.2, 0.3), 2)) ) group <- rep(c("a", "b"), each = 9) ## Adjust id rates by groups by(ca_id2, group, id_adj)
ca_id <- c(rep(0,3), rep(c(0.1, 0.15, 0.25), 2)) id_adj(ca_id) ## change line size to 5 id_adj(ca_id, lsize = 5) ## For multiple groups ca_id2 <- c(c(rep(0,3), rep(c(0.1, 0.15, 0.25), 2)), c(rep(0,3), rep(c(0.1, 0.2, 0.3), 2)) ) group <- rep(c("a", "b"), each = 9) ## Adjust id rates by groups by(ca_id2, group, id_adj)
A function to adjust the id rates for ca lineups using the 1/(lineup size) method; match and adjust id rates by names of confidence levels for both filler and suspect ids.
id_adj_name(rate, conf = NULL, fid, sid, lsize = 6)
id_adj_name(rate, conf = NULL, fid, sid, lsize = 6)
rate |
ID rate vector. |
conf |
Confidence levels for the id rate vector. Default to be NULL. |
fid |
Mapping confidence levels from filler id. |
sid |
To-be-matched confidence levels for suspect id. Must have equal length as fid. |
lsize |
Lineup size. Defaults to 6. |
Adjusted ID vector.
ca_id <- c(rep(0,3), rep(c(0.1, 0.15, 0.25), 2)) names(ca_id) <- paste0(rep(c("IDS", "IDF", "REJ"), each = 3), c("high", "medium", "low")) fid_conf <- paste0("IDF", c("high", "medium", "low")) sid_conf <- paste0("IDS", c("high", "medium", "low")) id_adj_name(ca_id, fid = fid_conf, sid = sid_conf)
ca_id <- c(rep(0,3), rep(c(0.1, 0.15, 0.25), 2)) names(ca_id) <- paste0(rep(c("IDS", "IDF", "REJ"), each = 3), c("high", "medium", "low")) fid_conf <- paste0("IDF", c("high", "medium", "low")) sid_conf <- paste0("IDS", c("high", "medium", "low")) id_adj_name(ca_id, fid = fid_conf, sid = sid_conf)
A function to adjust the id rates for ca lineups using the 1/(lineup size) method; match and adjust id rates by positions of filler and suspect ids.
id_adj_pos(rate, fid, sid, lsize = 6)
id_adj_pos(rate, fid, sid, lsize = 6)
rate |
ID rate vector. |
fid |
Mapping positions from filler id. |
sid |
To-be-matched positions for suspect id. Must have equal length as fid. |
lsize |
Lineup size. Defaults to 6. |
Adjusted ID vector.
ca_id <- c(rep(0,3), rep(c(0.1, 0.15, 0.25), 2)) id_adj_pos(ca_id, fid = 4:6, sid = 1:3, lsize = 5)
ca_id <- c(rep(0,3), rep(c(0.1, 0.15, 0.25), 2)) id_adj_pos(ca_id, fid = 4:6, sid = 1:3, lsize = 5)
A function to calculate responses from simulated memory distribution
response_calculate(memory, criterion, id_criterion = NULL, suspect = TRUE)
response_calculate(memory, criterion, id_criterion = NULL, suspect = TRUE)
memory |
A simulated data matrix with suspect (column 1) and filler memory. |
criterion |
A vector of judgment criterion. Must have odd number of elements if id_criterion is not specified. |
id_criterion |
A number to define the criterion for id or rejection. Use the middle element of criterion if not specified. |
suspect |
Whether there is a designated suspect. Defaults to TRUE. |
A data matrix of id responses (IDS, IDF, or REJ) and confidence levels.
A function to simulate both CP and CA responses
response_simu( guilt_diff, inno_diff = 0, n_sim = 1000, size = 6, inno_suspect = FALSE, criterion, id_criterion = NULL )
response_simu( guilt_diff, inno_diff = 0, n_sim = 1000, size = 6, inno_suspect = FALSE, criterion, id_criterion = NULL )
guilt_diff |
Mean difference between guilty suspect and filler distributions. |
inno_diff |
Mean difference between innocent suspect and filler distributions. Defaults to 0. |
n_sim |
Number of simulations per condition. Defaults to 1,000. |
size |
Number of lineup members. Defaults to 6. |
inno_suspect |
Whether there is a designated innocent suspect. Defaults to FALSE. |
criterion |
A vector of response criteria. Must have odd number of elements if id_criterion is not specified. |
id_criterion |
A number to define the criterion for id or rejection. Use the middle element of criterion if not specified. |
A data frame including both CP and CA ID responses and confidence levels.
## Set up response criteria rc1 <- seq(-1, 3, length.out = 5) ## no designated innocent suspect response_simu(guilt_diff = 2, criterion = rc1) ## with a designated innocent suspect response_simu(guilt_diff = 2, inno_diff = 0.2, inno_suspect = TRUE, criterion = rc1) ## define a criterion for id/rejection instead of using the middle criterion response_simu(guilt_diff = 2, criterion = 0:3, id_criterion = 1)
## Set up response criteria rc1 <- seq(-1, 3, length.out = 5) ## no designated innocent suspect response_simu(guilt_diff = 2, criterion = rc1) ## with a designated innocent suspect response_simu(guilt_diff = 2, inno_diff = 0.2, inno_suspect = TRUE, criterion = rc1) ## define a criterion for id/rejection instead of using the middle criterion response_simu(guilt_diff = 2, criterion = 0:3, id_criterion = 1)
A function to calculate AUC using non-cumulative response rates.
roc_auc(cpr, car, group = NULL, byDR = FALSE)
roc_auc(cpr, car, group = NULL, byDR = FALSE)
cpr |
A vector of cp id rates. |
car |
A vector of ca id rates. |
group |
A vector indicating group membership. If specified, will calculate AUC by group. |
byDR |
Whether to order ids by diagnosticity ratios. Defaults to FALSE. |
Area under the curve.
A function to add an ROC curve to an existing ROC plot.
roc_line(cp, ca, byDR = FALSE, cumdata = FALSE, ...)
roc_line(cp, ca, byDR = FALSE, cumdata = FALSE, ...)
cp |
A vector of cp id rates or frequencies. |
ca |
A vector of ca id rates or frequencies. |
byDR |
Whether to order ids by diagnosticity ratios. Defaults to FALSE. |
cumdata |
Whether to output the cumulative data that are used to create the ROC curves. Default to FALSE. |
... |
Additional plotting parameters.
For example, users can change x-axis and y-axis labels using |
Plot ROC curves and calculate AUCs as side effects.
A function to plot ROC curves. Note that the NA values in the data will be replaced with zero.
roc_plot( cp, ca, group = NULL, byDR = FALSE, cumdata = FALSE, grayscale = FALSE, ... )
roc_plot( cp, ca, group = NULL, byDR = FALSE, cumdata = FALSE, grayscale = FALSE, ... )
cp |
A vector of cp id rates or frequencies. |
ca |
A vector of ca id rates or frequencies. |
group |
Grouping variable to indicate group membership. Will create an ROC curve and calculate AUC for each group. |
byDR |
Whether to order ids by diagnosticity ratios. Defaults to FALSE. |
cumdata |
Whether to output the cumulative data that are used to create the ROC curves. Default to FALSE. |
grayscale |
Whether to produce the plot in grayscale. Defaults to FALSE. |
... |
Additional plotting parameters.
For example, users can change x-axis and y-axis labels using |
Plot ROC curves and calculate AUCs as side effects.
Yueran Yang & Andrew Smith. (2022). "fullROC: An R package for generating and analyzing eyewitness-lineup ROC curves." Behavior Research Methods. doi:10.3758/s13428-022-01807-6
Andrew Smith, Yueran Yang, & Gary Wells. (2020). "Distinguishing between investigator discriminability and eyewitness discriminability: A method for creating full receiver operating characteristic curves of lineup identification performance". Perspectives on Psychological Science, 15(3), 589-607. doi:10.1177/1745691620902426
cpf1 <- c(100, 90, 80, 20, 10, 5) caf1 <- c(6, 7, 15, 50, 75, 120) roc_plot(cpf1, caf1) cpf2 <- c(90, 40, 20) caf2 <- c(10, 70, 80) roc_plot(cpf2, caf2) ## plot two ROC curves cpf <- c(cpf1, cpf2) caf <- c(caf1, caf2) group <- rep(letters[1:2], times = c(length(cpf1), length(cpf2) ) ) roc_plot(cpf, caf, group = group)
cpf1 <- c(100, 90, 80, 20, 10, 5) caf1 <- c(6, 7, 15, 50, 75, 120) roc_plot(cpf1, caf1) cpf2 <- c(90, 40, 20) caf2 <- c(10, 70, 80) roc_plot(cpf2, caf2) ## plot two ROC curves cpf <- c(cpf1, cpf2) caf <- c(caf1, caf2) group <- rep(letters[1:2], times = c(length(cpf1), length(cpf2) ) ) roc_plot(cpf, caf, group = group)
A function to plot z-ROC curves. Note that the NA values in the data will be replaced with zero.
zroc_plot(cp, ca, group = NULL, byDR = FALSE, grayscale = FALSE, ...)
zroc_plot(cp, ca, group = NULL, byDR = FALSE, grayscale = FALSE, ...)
cp |
A vector of cp id rates or frequencies. |
ca |
A vector of ca id rates or frequencies. |
group |
Grouping variable to indicate group membership. Will create an ROC curve and calculate AUC for each group. |
byDR |
Whether to order ids by diagnosticity ratios. Defaults to FALSE. |
grayscale |
Whether to produce the plot in grayscale. Defaults to FALSE. |
... |
Additional plotting parameters.
For example, users can change x-axis and y-axis labels using |
Plot z-ROC curves.
cpf1 <- c(100, 90, 80, 20, 10, 5) caf1 <- c(6, 7, 15, 50, 75, 120) zroc_plot(cpf1, caf1) cpf2 <- c(90, 40, 20) caf2 <- c(10, 70, 80) zroc_plot(cpf2, caf2) ## plot two ROC curves cpf <- c(cpf1, cpf2) caf <- c(caf1, caf2) group <- rep(letters[1:2], times = c(length(cpf1), length(cpf2) ) ) zroc_plot(cpf, caf, group = group)
cpf1 <- c(100, 90, 80, 20, 10, 5) caf1 <- c(6, 7, 15, 50, 75, 120) zroc_plot(cpf1, caf1) cpf2 <- c(90, 40, 20) caf2 <- c(10, 70, 80) zroc_plot(cpf2, caf2) ## plot two ROC curves cpf <- c(cpf1, cpf2) caf <- c(caf1, caf2) group <- rep(letters[1:2], times = c(length(cpf1), length(cpf2) ) ) zroc_plot(cpf, caf, group = group)