make_ppv_range: Main Function to Compute and Visualize PPV Range

View source: R/ppv_range_plots.R

make_ppv_rangeR Documentation

Main Function to Compute and Visualize PPV Range

Description

Convenience wrapper that computes PPV range and creates visualizations.

Usage

make_ppv_range(
  data,
  lineup_size = 6,
  confidence_bins = NULL,
  show_plots = TRUE,
  plot_type = "all",
  innocent_suspect = "auto",
  base_rate = NULL
)

Arguments

data

A dataframe with columns: target_present, identification, confidence

lineup_size

Integer. Nominal number of people in lineup (default = 6)

confidence_bins

Numeric vector of bin edges (optional)

show_plots

Logical. Whether to create plots (default = TRUE)

plot_type

Character. Which plots to create: "ppv" (PPV range only), "effective" (effective size only), "all" (all plots, default)

innocent_suspect

How innocent-suspect identifications in target-absent lineups are obtained. "designated": the lineups had a designated innocent suspect, so target-absent "suspect" rows are counted directly, and zero such rows means a false-ID rate of zero. "estimated": there was no designated innocent suspect, so the innocent-suspect count is estimated as filler IDs divided by lineup_size. "auto" (the default) chooses "designated" when any target-absent row is a suspect ID or the data have a non-missing suspect_pos column, and "estimated" otherwise, with a message.

base_rate

Prior probability that the suspect is guilty. NULL (default) computes PPV from counts, as below. A number strictly between 0 and 1 computes it from the guilty-ID rate (per target-present trial) and the innocent-suspect-ID rate (per target-absent trial) at that prior, so the result does not depend on the TP:TA split.

Value

A list of class "lineup_ppv_range" containing:

  • ppv_range_data: Dataframe with all PPV estimates

  • plot_ppv_range: ggplot of PPV range (if requested)

  • plot_effective_size: ggplot of effective size (if requested)

  • plot_error_rate: ggplot of error rates (if requested)

  • ... (additional components from ppv_range_by_confidence)

Examples

data(lineup_example)
# With confidence binning
result <- make_ppv_range(lineup_example, confidence_bins = c(0, 60, 80, 100))

# Access plots
result$plot_ppv_range
result$plot_effective_size


r4lineups documentation built on Nov. 10, 2026, 1:08 a.m.