Skip to contents

track_intersection() calculates the number of unique intersections between trajectories. The function also supports testing with simulations and different permutation procedures for the coordinates of the simulated trajectories' origins to compute p-values. This allows for a robust assessment of the intersection metrics, enabling users to evaluate the significance of the observed intersections in relation to simulated trajectories.

Usage

track_intersection(
  data,
  test = NULL,
  H1 = NULL,
  sim = NULL,
  origin.permutation = NULL,
  custom.coord = NULL
)

Arguments

data

A track R object, which is a list consisting of two elements:

  • Trajectories: A list of interpolated trajectories, where each trajectory is a series of midpoints between consecutive footprints.

  • Footprints: A list of data frames containing footprint coordinates, metadata (e.g., image reference, ID), and a marker indicating whether the footprint is actual or inferred.

test

Logical; if TRUE, the function compares the observed intersection metrics against. Default is FALSE.

H1

A character string specifying the alternative hypothesis to be tested. Options are "Lower" for testing whether the observed intersections are significantly lower than the simulated ones (e.g., coordinated or gregarious movement), or "Higher" for testing whether the observed intersections are significantly higher than the simulated ones (e.g., predatory or chasing events).

sim

A track simulation R object consisting of a list of simulated trajectories to use for comparison when test = TRUE.

origin.permutation

A character string specifying the method for permutation of the coordinates of the simulated trajectories' origins. Options include "None", "Min.Box", "Conv.Hull", or "Custom". Default is "None".

custom.coord

A matrix of custom coordinates that define the vertices of an area for permutation of the coordinates of the simulated trajectories' origins.

Value

A track intersection R object consisting of a list containing the following elements:

Intersection_metric

A matrix of unique intersection counts between trajectories. Each entry represents the number of unique intersection points between the corresponding pair of trajectories.

Intersection_metric_p_values

(If test = TRUE) A matrix of p-values associated with the intersection metrics, calculated through permutations of simulated trajectory origins. Each entry reflects the probability of observing an intersection count as extreme as the observed one, given the null hypothesis of no difference.

Intersection_metric_p_values_combined

(If test = TRUE) A numeric value representing the combined p-value for all intersections, indicating the overall significance of the intersection metrics across all pairs of trajectories.

Intersection_metric_simulations

(If test = TRUE) A list containing matrices of intersection counts for each simulation iteration, allowing for further inspection of the distribution of intersections across multiple randomized scenarios.

Details

The track_intersection() function is designed to calculate the number of unique intersections between trajectories and to evaluate their statistical significance through hypothesis testing based on simulated tracks. This process provides a robust framework for comparing observed intersections against those expected under random conditions, allowing users to test specific behavioral hypotheses related to the movement patterns of trackmakers.

Hypothesis testing is controlled by the H1 argument, which defines the alternative hypothesis to be evaluated. This argument is crucial for interpreting the statistical results, as it determines whether the function will test for reduced or increased intersection counts compared to simulated trajectories.

The H1 argument accepts two possible values:

  • "Lower": This option tests whether the observed intersections are significantly lower than those generated by simulations. This scenario corresponds to hypotheses involving coordinated or gregarious movement, where animals moving in parallel or in a group (e.g., hunting packs or social gatherings) would produce fewer intersections than expected under random conditions.

  • "Higher": This option tests whether the observed intersections are significantly higher than those generated by simulations. It applies to scenarios where predatory or chasing interactions are likely, such as when one trackmaker follows or crosses the path of another. This behavior results in more intersections than what would occur randomly.

The selection of the H1 argument must be consistent with the behavioral hypothesis being tested. For example, use "Lower" when investigating group movement or cooperative behavior, and "Higher" when analyzing predatory or competitive interactions. The function will automatically adjust the calculation of p-values to reflect the selected H1. If the argument is left NULL, an error will be triggered, indicating that users must explicitly specify the hypothesis to be tested.

The interpretation of the combined p-value returned by the function is directly influenced by the choice of H1, as it determines whether the statistical comparison aims to detect a reduction or an increase in intersection counts compared to the simulated dataset.

In addition to hypothesis testing, the track_intersection() function offers several options for altering the initial positions of simulated tracks through the origin.permutation argument. The available options include:

  • "None": Simulated trajectories are not shifted and are compared based on their original starting positions.

  • "Min.Box": Trajectories are randomly placed within the minimum bounding box surrounding the original starting points.

  • "Conv.Hull": Trajectories are placed within the convex hull that encompasses all original starting points, providing a more precise representation of the area occupied by the tracks.

  • "Custom": Allows users to define a specific region of interest by providing a matrix of coordinates (custom.coord) that specifies the vertices of the desired area. This option is particularly useful when certain spatial features or environmental conditions are known to constrain movement.

The choice of origin.permutation should reflect the nature of the behavioral hypothesis being tested. For example, using "None" is most appropriate when testing how intersections compare under scenarios where trackmakers originate from specific locations. In contrast, options like "Min.Box", "Conv.Hull", or "Custom" are suitable when evaluating how intersections would differ if the tracks originated from a broader or predefined area.

The track_intersection() function also allows for integration with similarity metrics computed using simil_DTW_metric() and simil_Frechet_metric(). This combination of intersection counts and similarity metrics can provide a more comprehensive analysis of how trackmakers interacted, whether their movements were coordinated or independent, and whether their interactions were consistent with the hypothesized behavioral patterns.

Overall, the selection of H1 and origin.permutation should be carefully considered in light of the specific hypotheses being tested. By combining intersection metrics with similarity measures, users can obtain a deeper understanding of the behavioral dynamics underlying the observed trackways.

Author

Humberto G. Ferrón

humberto.ferron@uv.es

Macroevolution and Functional Morphology Research Group (www.macrofun.es)

Cavanilles Institute of Biodiversity and Evolutionary Biology

Calle Catedrático José Beltrán Martínez, nº 2

46980 Paterna - Valencia - Spain

Phone: +34 (9635) 44477

Examples

# Example 1: Intersection metrics in the PaluxyRiver dataset.
s1 <- simulate_track(PaluxyRiver, nsim = 5, model = "Directed")
int1 <- track_intersection(PaluxyRiver, test = TRUE, H1 = "Lower", sim = s1,
  origin.permutation = "None")
#> 2025-05-19 14:34:19.455412 Iteration 1
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:19.467861 Iteration 2
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:19.479413 Iteration 3
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:19.490553 Iteration 4
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:19.501415 Iteration 5
#>  
#> Intersect metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>  
print(int1)
#> $Intersection_metric
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> $Intersection_metric_p_values
#>         Track_1 Track_2
#> Track_1      NA     0.8
#> Track_2      NA      NA
#> 
#> $Intersection_metric_p_values_combined
#> [1] 0.8
#> 
#> $Intersection_metric_simulations
#> $Intersection_metric_simulations[[1]]
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[2]]
#>         Track_1 Track_2
#> Track_1      NA       4
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[3]]
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[4]]
#>         Track_1 Track_2
#> Track_1      NA       0
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[5]]
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> 

# Example 2: Using "Min.Box" origin permutation in PaluxyRiver dataset.
s2 <- simulate_track(PaluxyRiver, nsim = 5, model = "Constrained")
int2 <- track_intersection(PaluxyRiver, test = TRUE, H1 = "Lower", sim = s2,
  origin.permutation = "Min.Box")
#> 2025-05-19 14:34:19.910479 Permutation 1
#>  
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> 2025-05-19 14:34:20.058048 Permutation 2
#>  
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> 2025-05-19 14:34:20.184755 Permutation 3
#>  
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> 2025-05-19 14:34:20.716362 Permutation 4
#>  
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> 2025-05-19 14:34:20.913501 Permutation 5
#>  
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> PERMUTATION COMPLETED
#> ------------------------------------
#>  
#> 2025-05-19 14:34:20.925659 Iteration 1
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:20.936419 Iteration 2
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:20.947185 Iteration 3
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:20.957803 Iteration 4
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:20.968478 Iteration 5
#>  
#> Intersect metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>  
print(int2)
#> $Intersection_metric
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> $Intersection_metric_p_values
#>         Track_1 Track_2
#> Track_1      NA     0.6
#> Track_2      NA      NA
#> 
#> $Intersection_metric_p_values_combined
#> [1] 0.6
#> 
#> $Intersection_metric_simulations
#> $Intersection_metric_simulations[[1]]
#>         Track_1 Track_2
#> Track_1      NA       0
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[2]]
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[3]]
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[4]]
#>         Track_1 Track_2
#> Track_1      NA       0
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[5]]
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> 

# Example 3: Using "Conv.Hull" origin permutation in PaluxyRiver dataset.
s3 <- simulate_track(PaluxyRiver, nsim = 5, model = "Unconstrained")
int3 <- track_intersection(PaluxyRiver, test = TRUE, H1 = "Lower", sim = s3,
  origin.permutation = "Conv.Hull")
#> 2025-05-19 14:34:21.133341 Permutation 1
#>  
#> Permutation of coordinates at origin using Conv.Hull
#> ------------------------------------
#> 2025-05-19 14:34:21.298014 Permutation 2
#>  
#> Permutation of coordinates at origin using Conv.Hull
#> ------------------------------------
#> 2025-05-19 14:34:21.680701 Permutation 3
#>  
#> Permutation of coordinates at origin using Conv.Hull
#> ------------------------------------
#> 2025-05-19 14:34:21.846152 Permutation 4
#>  
#> Permutation of coordinates at origin using Conv.Hull
#> ------------------------------------
#> 2025-05-19 14:34:22.227976 Permutation 5
#>  
#> Permutation of coordinates at origin using Conv.Hull
#> ------------------------------------
#> PERMUTATION COMPLETED
#> ------------------------------------
#>  
#> 2025-05-19 14:34:22.239727 Iteration 1
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.250446 Iteration 2
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.261284 Iteration 3
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.272226 Iteration 4
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.283188 Iteration 5
#>  
#> Intersect metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>  
print(int3)
#> $Intersection_metric
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> $Intersection_metric_p_values
#>         Track_1 Track_2
#> Track_1      NA     0.4
#> Track_2      NA      NA
#> 
#> $Intersection_metric_p_values_combined
#> [1] 0.4
#> 
#> $Intersection_metric_simulations
#> $Intersection_metric_simulations[[1]]
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[2]]
#>         Track_1 Track_2
#> Track_1      NA       0
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[3]]
#>         Track_1 Track_2
#> Track_1      NA       0
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[4]]
#>         Track_1 Track_2
#> Track_1      NA       1
#> Track_2      NA      NA
#> 
#> $Intersection_metric_simulations[[5]]
#>         Track_1 Track_2
#> Track_1      NA       0
#> Track_2      NA      NA
#> 
#> 

# Example 4: Using "Min.Box" origin permutation in MountTom subset.
sbMountTom <- subset_track(MountTom, tracks = c(1, 2, 3, 4, 7, 8, 9, 13, 15, 16, 18))
s4 <- simulate_track(sbMountTom, nsim = 5)
#> Warning: `model` is NULL. Defaulting to 'Unconstrained'.
int4 <- track_intersection(sbMountTom, test = TRUE, H1 = "Higher", sim = s4,
  origin.permutation = "Min.Box")
#> 2025-05-19 14:34:22.368869 Permutation 1
#>  
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> 2025-05-19 14:34:22.373816 Permutation 2
#>  
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> 2025-05-19 14:34:22.38352 Permutation 3
#>  
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> 2025-05-19 14:34:22.387803 Permutation 4
#>  
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> 2025-05-19 14:34:22.39207 Permutation 5
#>  
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> PERMUTATION COMPLETED
#> ------------------------------------
#>  
#> 2025-05-19 14:34:22.418604 Iteration 1
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.444613 Iteration 2
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.471108 Iteration 3
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.497749 Iteration 4
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.524709 Iteration 5
#>  
#> Intersect metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>  
print(int4)
#> $Intersection_metric
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        0        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        0        0        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        1
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_p_values
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA      0.8      0.8      1.0        1      0.8      1.0
#> Track_02       NA       NA      1.0      1.0        1      1.0      0.8
#> Track_03       NA       NA       NA      0.8        1      1.0      1.0
#> Track_04       NA       NA       NA       NA        1      0.8      1.0
#> Track_07       NA       NA       NA       NA       NA      1.0      1.0
#> Track_08       NA       NA       NA       NA       NA       NA      1.0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        1        1      1.0      1.0
#> Track_02        1        1      1.0      1.0
#> Track_03        1        1      1.0      1.0
#> Track_04        1        1      1.0      1.0
#> Track_07        1        1      0.8      1.0
#> Track_08        1        1      1.0      1.0
#> Track_09        1        1      1.0      1.0
#> Track_13       NA        1      1.0      0.8
#> Track_15       NA       NA      1.0      1.0
#> Track_16       NA       NA       NA      1.0
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_p_values_combined
#> [1] 0.8
#> 
#> $Intersection_metric_simulations
#> $Intersection_metric_simulations[[1]]
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        0        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        0        0        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        0
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        1
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_simulations[[2]]
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        0        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        0        0        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        0
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_simulations[[3]]
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        1        0        0        0        1        0
#> Track_02       NA       NA        0        0        0        0        1
#> Track_03       NA       NA       NA        1        0        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        0
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        1        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_simulations[[4]]
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        0        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        0        0        0        0
#> Track_04       NA       NA       NA       NA        0        1        0
#> Track_07       NA       NA       NA       NA       NA        0        0
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_simulations[[5]]
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        1        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        0        0        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        0
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#> 

# Example 5: Customized origin permutation in MountTom subset.
sbMountTom <- subset_track(MountTom, tracks = c(1, 2, 3, 4, 7, 8, 9, 13, 15, 16, 18))
s5 <- simulate_track(sbMountTom, nsim = 5)
#> Warning: `model` is NULL. Defaulting to 'Unconstrained'.
area_origin <- matrix(c(50, 5, 10, 5, 10, 20, 50, 20), ncol = 2, byrow = TRUE)
int5 <- track_intersection(sbMountTom, test = TRUE, H1 = "Higher", sim = s5,
  origin.permutation = "Custom", custom.coord = area_origin)
#> 2025-05-19 14:34:22.629808 Permutation 1
#>  
#> Permutation of coordinates at origin using Custom
#> ------------------------------------
#> 2025-05-19 14:34:22.633154 Permutation 2
#>  
#> Permutation of coordinates at origin using Custom
#> ------------------------------------
#> 2025-05-19 14:34:22.636397 Permutation 3
#>  
#> Permutation of coordinates at origin using Custom
#> ------------------------------------
#> 2025-05-19 14:34:22.639684 Permutation 4
#>  
#> Permutation of coordinates at origin using Custom
#> ------------------------------------
#> 2025-05-19 14:34:22.642943 Permutation 5
#>  
#> Permutation of coordinates at origin using Custom
#> ------------------------------------
#> PERMUTATION COMPLETED
#> ------------------------------------
#>  
#> 2025-05-19 14:34:22.670292 Iteration 1
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.70093 Iteration 2
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.727554 Iteration 3
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.754093 Iteration 4
#>  
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:22.780361 Iteration 5
#>  
#> Intersect metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>  
print(int5)
#> $Intersection_metric
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        0        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        0        0        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        1
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_p_values
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        1        1      1.0      1.0        1        1
#> Track_02       NA       NA        1      1.0      1.0        1        1
#> Track_03       NA       NA       NA      0.8      0.8        1        1
#> Track_04       NA       NA       NA       NA      1.0        1        1
#> Track_07       NA       NA       NA       NA       NA        1        1
#> Track_08       NA       NA       NA       NA       NA       NA        1
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        1        1        1      1.0
#> Track_02        1        1        1      1.0
#> Track_03        1        1        1      1.0
#> Track_04        1        1        1      1.0
#> Track_07        1        1        1      1.0
#> Track_08        1        1        1      1.0
#> Track_09        1        1        1      1.0
#> Track_13       NA        1        1      1.0
#> Track_15       NA       NA        1      1.0
#> Track_16       NA       NA       NA      0.8
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_p_values_combined
#> [1] 0.8
#> 
#> $Intersection_metric_simulations
#> $Intersection_metric_simulations[[1]]
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        0        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        0        0        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        0
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_simulations[[2]]
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        0        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        1        1        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        0
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_simulations[[3]]
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        0        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        0        0        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        0
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        1
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_simulations[[4]]
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        0        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        0        0        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        0
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#> $Intersection_metric_simulations[[5]]
#>          Track_01 Track_02 Track_03 Track_04 Track_07 Track_08 Track_09
#> Track_01       NA        0        0        0        0        0        0
#> Track_02       NA       NA        0        0        0        0        0
#> Track_03       NA       NA       NA        0        0        0        0
#> Track_04       NA       NA       NA       NA        0        0        0
#> Track_07       NA       NA       NA       NA       NA        0        0
#> Track_08       NA       NA       NA       NA       NA       NA        0
#> Track_09       NA       NA       NA       NA       NA       NA       NA
#> Track_13       NA       NA       NA       NA       NA       NA       NA
#> Track_15       NA       NA       NA       NA       NA       NA       NA
#> Track_16       NA       NA       NA       NA       NA       NA       NA
#> Track_18       NA       NA       NA       NA       NA       NA       NA
#>          Track_13 Track_15 Track_16 Track_18
#> Track_01        0        0        0        0
#> Track_02        0        0        0        0
#> Track_03        0        0        0        0
#> Track_04        0        0        0        0
#> Track_07        0        0        0        0
#> Track_08        0        0        0        0
#> Track_09        0        0        0        0
#> Track_13       NA        0        0        0
#> Track_15       NA       NA        0        0
#> Track_16       NA       NA       NA        0
#> Track_18       NA       NA       NA       NA
#> 
#>