simil_Frechet_metric {QuAnTeTrack} | R Documentation |
Similarity metric using Fréchet distance
Description
simil_Frechet_metric()
computes similarity metrics between two or more trajectories using
the Fréchet distance. It allows for different superposition methods
to align trajectories before calculating the Fréchet distance metrics. The function also supports
testing with simulations to calculate p-values for the Fréchet distance metrics.
Usage
simil_Frechet_metric(data, test = FALSE, sim = NULL, superposition = "None")
Arguments
data |
A
|
test |
Logical; if |
sim |
A |
superposition |
A character string indicating the method used to align trajectories.
Options are |
Details
The simil_Frechet_metric()
function calculates the similarity between trajectories using
the Frechet()
function from the SimilarityMeasures package.
The Fréchet distance is a measure of similarity between two curves or continuous trajectories, which takes into account both the order and location of points within the trajectories (Besse et al. 2015). The distance can be described by the analogy of a person walking a dog on an extendable leash (Aronov et al. 2006). Both the person and the dog move along their respective trajectories, with each able to adjust their speed but not retrace their steps. The Fréchet distance is the minimum leash length required to keep the dog connected to the person throughout the walk (Cleasby et al., 2019).
Unlike other trajectory comparison techniques, such as Dynamic Time Warping, the Fréchet distance focuses on the overall shape of the trajectories rather than matching specific points. As a result, it is sensitive to noise because all points of the compared trajectories are considered in its calculation. However, it can still be a powerful tool for trajectory clustering and comparison, particularly when shape is the primary concern (Cleasby et al., 2019).
Note that when comparing real trajectories that are very disparate or those simulated under an unconstrained method, the resulting trajectories may not be suitable for Fréchet distance calculations. In such cases, the Fréchet distance is returned as -1 to indicate an invalid measurement.
The function offers three different superposition methods to align the trajectories
before Frechet()
is applied:
-
"None"
: No superposition is applied. -
"Centroid"
: Trajectories are shifted to align based on their centroids. -
"Origin"
: Trajectories are shifted to align based on their starting point.
If test = TRUE
, the function can compute p-values by comparing the observed Fréchet
distances with those generated from a set of simulated trajectories. The p-values
are calculated for both individual trajectory pairs and for the entire set of trajectories.
Value
A track similarity
R object consisting ofa list containing the following elements:
Frechet_distance_metric |
A matrix containing the pairwise Frechet distances between trajectories. |
Frechet_distance_metric_p_values |
(If |
Frechet_metric_p_values_combined |
(If |
Frechet_distance_metric_simulations |
(If |
Logo
Author(s)
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
References
Cleasby, I. R., Wakefield, E. D., Morrissey, B. J., Bodey, T. W., Votier, S. C., Bearhop, S., & Hamer, K. C. (2019). Using time-series similarity measures to compare animal movement trajectories in ecology. Behavioral Ecology and Sociobiology, 73, 1-19.
See Also
tps_to_track
, simulate_track
, Frechet
Examples
# Example 1: Simulating tracks using the "Directed" model and comparing Frechet distance
# in the PaluxyRiver dataset
s1 <- simulate_track(PaluxyRiver, nsim = 3, model = "Directed")
simil_Frechet_metric(PaluxyRiver, test = TRUE, sim = s1, superposition = "None")
# Example 2: Simulating tracks using the "Constrained" model and comparing Frechet distance
# in the PaluxyRiver dataset using the "Centroid" superposition method
s2 <- simulate_track(PaluxyRiver, nsim = 3, model = "Constrained")
simil_Frechet_metric(PaluxyRiver, test = TRUE, sim = s2, superposition = "Centroid")
# Example 3: Simulating tracks using the "Unconstrained" model and comparing Frechet distance
# in the PaluxyRiver dataset using the "Origin" superposition method
s3 <- simulate_track(PaluxyRiver, nsim = 3, model = "Unconstrained")
simil_Frechet_metric(PaluxyRiver, test = TRUE, sim = s3, superposition = "Origin")