find_best_split: find_best_split

View source: R/find_best_split.R

find_best_splitR Documentation

find_best_split

Description

Find the optimal point in time to split a migration interval

Usage

find_best_split(locs, times, movement, from, to)

Arguments

locs

character, A vector of the locations of occurrences.

times

POSIXct, A vector of the occurrences corresponding timestamps.

movement

A lubridate interval for which the best split is to be found.

from

character, the name of the location the movement ends at. Must match an element in locs.

to

character, the name of the location the movement ends at. Must match an element in locs.

Details

The function checks which occurrences by locs and times fall within the interval given by movement. It then tries to find the optimal point in time to split the interval, using the following two criteria:

  • The point which minimizes the number of misclassified days, i.e., the number of days when the migrant appears at to before the migration date and days when the migrant appears at from after the migration date.

  • In cases where multiple days yield the same number of misclassifications, we select the last timestamp as the migration date

Value

A tibble of 2 fields:

  • split_time, a lubridate date time which indicates the time of the optimal split found

  • split_correctness, a numeric date time which indicates the split's ratio of the wrongly assigned days to the correctly assigned days

Author(s)

Johannes Mast Johannes.Mast@dlr.de, based on the algorithm by Guanghua Chi guanghua@berkeley.edu

References

Chi, Guanghua, Fengyang Lin, Guangqing Chi, and Joshua Blumenstock. 2020. “A General Approach to Detecting Migration Events in Digital Trace Data.” Edited by Song Gao. PLOS ONE 15 (10): e0239408. https://doi.org/10.1371/journal.pone.0239408.


MigrationDetectR documentation built on Nov. 11, 2023, 5:07 p.m.