Calculate combined probabilities of similarity or intersection metrics of tracks
Source:R/combined_prob.R
combined_prob.Rd
combined_prob()
calculates the combined probabilities of similarity and intersection metrics
derived from different models. The function uses simulation data to extract p-values, providing insight into
the significance of combined metrics across various similarity assessments.
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.
- metrics
A list of
track similarity
and/ortrack intersection
R objects derived from different tests. All tests must be based on the same number of simulations.
Value
A list containing:
- P_values (model names)
A matrix of p-values for the combined metrics across all trajectories. Each entry represents the probability of observing the combined metrics between the corresponding pair of trajectories.
- P_values_combined (model names)
A numeric value representing the overall probability of observing the combined metrics, across all pairs of trajectories.
Details
The combined_prob()
function combines p-values derived from multiple similarity metric tests and intersection tests.
It calculates the combined p-values by assessing the probability of observing the combined metrics across simulated datasets.
This function is particularly useful for comparing multiple models and evaluating their collective performance in terms of p-values.
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: "Directed" model and similarity metrics.
s1 <- simulate_track(PaluxyRiver, nsim = 3, model = "Directed")
DTW1 <- simil_DTW_metric(PaluxyRiver, test = TRUE, sim = s1, superposition = "None")
#> 2025-05-19 14:33:58.187112 Iteration 1
#>
#> DTW metric
#> ------------------------------------
#> 2025-05-19 14:33:58.189322 Iteration 2
#>
#> DTW metric
#> ------------------------------------
#> 2025-05-19 14:33:58.191425 Iteration 3
#>
#> DTW metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>
Frechet1 <- simil_Frechet_metric(PaluxyRiver, test = TRUE, sim = s1, superposition = "None")
#> 2025-05-19 14:33:58.544359 Iteration 1
#>
#> Frechet metric
#> ------------------------------------
#> 2025-05-19 14:33:58.907232 Iteration 2
#>
#> Frechet metric
#> ------------------------------------
#> 2025-05-19 14:33:59.075673 Iteration 3
#>
#> Frechet metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>
int1 <- track_intersection(PaluxyRiver, test = TRUE, H1 = "Lower", sim = s1,
origin.permutation = "None")
#> 2025-05-19 14:33:59.09823 Iteration 1
#>
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:33:59.109442 Iteration 2
#>
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:33:59.120657 Iteration 3
#>
#> Intersect metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>
combined_prob(PaluxyRiver, metrics = list(DTW1, Frechet1, int1))
#> $`P_values (DTW_distance_metric, Frechet_distance_metric, Intersection_metric)`
#> Track_1 Track_2
#> Track_1 NA 0
#> Track_2 NA NA
#>
#> $`P_values_combined (DTW_distance_metric, Frechet_distance_metric, Intersection_metric)`
#> [1] 0
#>
# Example 2: "Constrained" model and similarity metrics.
s2 <- simulate_track(PaluxyRiver, nsim = 3, model = "Constrained")
DTW2 <- simil_DTW_metric(PaluxyRiver, test = TRUE, sim = s2,
superposition = "None")
#> 2025-05-19 14:33:59.136117 Iteration 1
#>
#> DTW metric
#> ------------------------------------
#> 2025-05-19 14:33:59.138359 Iteration 2
#>
#> DTW metric
#> ------------------------------------
#> 2025-05-19 14:33:59.140595 Iteration 3
#>
#> DTW metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>
Frechet2 <- simil_Frechet_metric(PaluxyRiver, test = TRUE, sim = s2,
superposition = "None")
#> 2025-05-19 14:33:59.477753 Iteration 1
#>
#> Frechet metric
#> ------------------------------------
#> 2025-05-19 14:33:59.636993 Iteration 2
#>
#> Frechet metric
#> ------------------------------------
#> 2025-05-19 14:33:59.794886 Iteration 3
#>
#> Frechet metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>
int2 <- track_intersection(PaluxyRiver, test = TRUE, H1 = "Lower", sim = s2,
origin.permutation = "Min.Box")
#> 2025-05-19 14:34:00.315392 Permutation 1
#>
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> 2025-05-19 14:34:00.435416 Permutation 2
#>
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> 2025-05-19 14:34:00.767926 Permutation 3
#>
#> Permutation of coordinates at origin using Min.Box
#> ------------------------------------
#> PERMUTATION COMPLETED
#> ------------------------------------
#>
#> 2025-05-19 14:34:00.779659 Iteration 1
#>
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:00.790548 Iteration 2
#>
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:00.801305 Iteration 3
#>
#> Intersect metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>
combined_prob(PaluxyRiver, metrics = list(DTW2, Frechet2, int2))
#> $`P_values (DTW_distance_metric, Frechet_distance_metric, Intersection_metric)`
#> Track_1 Track_2
#> Track_1 NA 0
#> Track_2 NA NA
#>
#> $`P_values_combined (DTW_distance_metric, Frechet_distance_metric, Intersection_metric)`
#> [1] 0
#>
# Example 3: "Unconstrained" model and similarity metrics.
s3 <- simulate_track(PaluxyRiver, nsim = 3, model = "Unconstrained")
DTW3 <- simil_DTW_metric(PaluxyRiver, test = TRUE, sim = s3,
superposition = "None")
#> 2025-05-19 14:34:00.81593 Iteration 1
#>
#> DTW metric
#> ------------------------------------
#> 2025-05-19 14:34:00.818066 Iteration 2
#>
#> DTW metric
#> ------------------------------------
#> 2025-05-19 14:34:00.820179 Iteration 3
#>
#> DTW metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>
Frechet3 <- simil_Frechet_metric(PaluxyRiver, test = TRUE, sim = s3,
superposition = "None")
#> 2025-05-19 14:34:01.019696 Iteration 1
#>
#> Frechet metric
#> ------------------------------------
#> 2025-05-19 14:34:01.1399 Iteration 2
#>
#> Frechet metric
#> ------------------------------------
#> 2025-05-19 14:34:01.159138 Iteration 3
#>
#> Frechet metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>
int3 <- track_intersection(PaluxyRiver, test = TRUE, H1 = "Lower", sim = s3,
origin.permutation = "Conv.Hull")
#> 2025-05-19 14:34:01.558049 Permutation 1
#>
#> Permutation of coordinates at origin using Conv.Hull
#> ------------------------------------
#> 2025-05-19 14:34:01.707789 Permutation 2
#>
#> Permutation of coordinates at origin using Conv.Hull
#> ------------------------------------
#> 2025-05-19 14:34:02.02118 Permutation 3
#>
#> Permutation of coordinates at origin using Conv.Hull
#> ------------------------------------
#> PERMUTATION COMPLETED
#> ------------------------------------
#>
#> 2025-05-19 14:34:02.03278 Iteration 1
#>
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:02.043508 Iteration 2
#>
#> Intersect metric
#> ------------------------------------
#> 2025-05-19 14:34:02.054092 Iteration 3
#>
#> Intersect metric
#> ------------------------------------
#> ANALYSIS COMPLETED
#> ------------------------------------
#>
combined_prob(PaluxyRiver, metrics = list(DTW3, Frechet3, int3))
#> $`P_values (DTW_distance_metric, Frechet_distance_metric, Intersection_metric)`
#> Track_1 Track_2
#> Track_1 NA 0
#> Track_2 NA NA
#>
#> $`P_values_combined (DTW_distance_metric, Frechet_distance_metric, Intersection_metric)`
#> [1] 0
#>