Skip to contents

Identifies spatial Area-Restricted Phase (ARP) clusters using DBSCAN based on spatial proximity, duration, and state classification proportions.

Usage

get.arp(
  data,
  ids = "ID",
  epsilon,
  minPts = 3,
  time.col = "time",
  state.col = "state",
  pct.state1 = NULL,
  delta.days = NULL,
  delta.method = "duration",
  group.col = NULL
)

Arguments

data

A data.frame or an object of class disperseR.

ids

Character. Name of the column containing individual identifiers. Default is "ID".

epsilon

Numeric or named list. Spatial distance threshold for DBSCAN. Can be a single value, or a named list per individual or group.

minPts

Integer. Minimum number of points required to form a cluster in DBSCAN. Default is 3.

time.col

Character. Name of the column containing timestamps (must be POSIXct). Default is "time".

state.col

Character. Name of the column containing behavioral or movement state classifications. Default is "state".

pct.state1

Numeric. Maximum proportion threshold of state 1 points allowed in a cluster. If not provided (NULL), this filter is not applied and a warning is triggered.

delta.days

Numeric. Minimum time in days for a cluster to be classified as an ARP, measured as set by delta.method. If not provided (NULL), this filter is not applied and a warning is triggered.

delta.method

Character. How the time of a cluster is measured for delta.days: "duration" (default) or "presence". See Details.

group.col

Character. Optional column name used for grouping when epsilon is provided as a named list.

Value

An object of class disperseR containing the updated dataset with cluster assignments, a list of cluster summaries (with dur_days and presence_days), and a list of filtered ARP clusters.

Details

DBSCAN groups locations by space only, so a cluster can include locations from several visits. Two measures of the time of a cluster are computed:

  • Duration (dur_days): time from the first to the last location of the cluster, including the time spent outside it between visits.

  • Presence (presence_days): time spent inside the cluster, that is, the sum of the intervals between consecutive locations that both belong to the cluster (Damiani et al. 2018). Absences are not counted.

delta.method = "presence" avoids that a place crossed twice, several days apart, becomes an ARP because of its long duration. delta.method = "duration" is more tolerant of locations that fall outside the cluster while the animal is still in the area (for example with coarse sampling or a small epsilon) and of patches used intermittently. Both measures are always returned in cluster_summary and arp_clusters.

References

Damiani ML, Hachem F, Issa H, Ranc N, Moorcroft P, Cagnacci F (2018) Cluster-based trajectory segmentation with local noise. Data Mining and Knowledge Discovery 32: 1017–1055. doi:10.1007/s10618-018-0561-2

Examples

eps <- get.epsilon(sim_states)
#> Computing a global threshold using all data combined.
arp <- get.arp(sim_states, epsilon = eps, delta.days = 2, pct.state1 = 0.2)
arp$arp_clusters
#> $F02
#> # A tibble: 4 × 7
#>   cluster_id start               end                 dur_days presence_days
#>        <int> <dttm>              <dttm>                 <dbl>         <dbl>
#> 1          4 2024-03-03 18:56:18 2024-03-11 19:56:18     8.04          8.04
#> 2          7 2024-03-13 18:56:18 2024-03-16 17:56:18     2.96          2.96
#> 3          9 2024-03-17 18:56:18 2024-03-26 19:56:18     9.04          9.04
#> 4         13 2024-03-29 20:56:18 2024-04-04 20:56:18     6             5.83
#> # ℹ 2 more variables: pct_state1 <dbl>, n <int>
#> 
#> $F04
#> # A tibble: 2 × 7
#>   cluster_id start               end                 dur_days presence_days
#>        <int> <dttm>              <dttm>                 <dbl>         <dbl>
#> 1          4 2024-03-03 19:02:54 2024-03-29 18:02:54     26.0          12.2
#> 2          6 2024-03-07 01:02:54 2024-04-05 05:02:54     29.2          12.8
#> # ℹ 2 more variables: pct_state1 <dbl>, n <int>
#> 
#> $F05
#> # A tibble: 1 × 7
#>   cluster_id start               end                 dur_days presence_days
#>        <int> <dttm>              <dttm>                 <dbl>         <dbl>
#> 1          7 2024-03-08 04:56:34 2024-03-14 18:56:34     6.58          6.58
#> # ℹ 2 more variables: pct_state1 <dbl>, n <int>
#> 
#> $M01
#> # A tibble: 4 × 7
#>   cluster_id start               end                 dur_days presence_days
#>        <int> <dttm>              <dttm>                 <dbl>         <dbl>
#> 1          4 2024-03-04 03:00:52 2024-04-19 22:00:52     46.8         14.2 
#> 2          5 2024-03-07 00:00:52 2024-03-21 22:00:52     14.9          6.75
#> 3         13 2024-03-26 06:00:52 2024-04-10 20:00:52     15.6          0.5 
#> 4         14 2024-03-26 19:00:52 2024-04-10 17:00:52     14.9         11.8 
#> # ℹ 2 more variables: pct_state1 <dbl>, n <int>
#> 
#> $M03
#> # A tibble: 2 × 7
#>   cluster_id start               end                 dur_days presence_days
#>        <int> <dttm>              <dttm>                 <dbl>         <dbl>
#> 1          4 2024-03-03 19:00:38 2024-03-10 21:00:38     7.08          7.08
#> 2          8 2024-03-16 00:00:35 2024-03-24 00:00:35     8             8   
#> # ℹ 2 more variables: pct_state1 <dbl>, n <int>
#> 

# Count only the time spent inside each cluster
arp_p <- get.arp(sim_states, epsilon = eps, delta.days = 2, pct.state1 = 0.2,
                 delta.method = "presence")
arp_p$arp_clusters$M01
#> # A tibble: 3 × 7
#>   cluster_id start               end                 dur_days presence_days
#>        <int> <dttm>              <dttm>                 <dbl>         <dbl>
#> 1          4 2024-03-04 03:00:52 2024-04-19 22:00:52     46.8         14.2 
#> 2          5 2024-03-07 00:00:52 2024-03-21 22:00:52     14.9          6.75
#> 3         14 2024-03-26 19:00:52 2024-04-10 17:00:52     14.9         11.8 
#> # ℹ 2 more variables: pct_state1 <dbl>, n <int>