Skip to contents

The history of the empirical route: a detection is reliable when its confidence reaches the threshold of its site x species cell, from review_support() or suggest_thresholds(), with no calibration model. The result has the columns that community_matrices() and summarise_history() read, as the history of detection_history().

Usage

threshold_history(
  detections,
  thresholds,
  min_confidence = 0.1,
  dawn_hour = 12,
  min_detections_night = 1
)

Arguments

detections

A data frame (or tibble) of predictions, from read_selection_tables(), with site, species_code, confidence and begin_path. One row per prediction. Use every prediction, not only those of the cells with a threshold.

thresholds

A data frame (or tibble) with site, species_folder and threshold, one row per cell, such as the output of review_support(). Cells with a missing threshold or without a row have no threshold. The conservative threshold of threshold_bootstrap() is the one to apply: pass it as dplyr::mutate(boot, threshold = threshold_conservative).

min_confidence

Numeric scalar. Predictions below this confidence are left out, as in score_detections(). This also sets which nights count as recorded.

dawn_hour

Numeric scalar, an hour of the day. Recordings that start before this hour belong to the night before.

min_detections_night

Integer scalar >= 1. Repetition rule: minimum number of reliable detections for a night with detection.

Value

A tibble (class tbl_df) with site, species (the short code, as in species_folder), night, n_detections, n_reliable, confidence_max, detection_k1, detection_k2, detection_k3 and detection.

Details

Every night with a detection stays in the history, also those of cells without a threshold, because community_matrices() takes the effort from the distinct nights of the history. Leaving those cells out would lower the nights recorded and raise the frequency of the other species. In those cells n_reliable and the detection columns are NA: nothing is known about them. community_matrices() does not count NA as a detection, so such a cell shows as 0 in the matrices, which does not mean that the species is absent.

The threshold holds for the set of detections kept, not for each one; see suggest_thresholds().

Examples

detections <- data.frame(
  site = "A", species_code = "Boana raniceps_boa-ran",
  confidence = c(0.9, 0.8, 0.3),
  begin_path = c("A_20240110_200000.wav", "A_20240110_210000.wav",
                 "A_20240111_200000.wav"))
thresholds <- data.frame(site = "A", species_folder = "boa_ran",
                         threshold = 0.7)
threshold_history(detections, thresholds)
#> # A tibble: 2 × 10
#>   site  species night    n_detections n_reliable confidence_max detection_k1
#>   <chr> <chr>   <chr>           <int>      <int>          <dbl>        <int>
#> 1 A     boa_ran 20240110            2          2            0.9            1
#> 2 A     boa_ran 20240111            1          0            0.3            0
#> # ℹ 3 more variables: detection_k2 <int>, detection_k3 <int>, detection <int>