Computes the point- or vector-wise dissimilarity between each pair of trajectories.
mt_distmat( data, use = "sp_trajectories", save_as = "distmat", dimensions = c("xpos", "ypos"), weights = rep(1, length(dimensions)), pointwise = TRUE, minkowski_p = 2, na_rm = FALSE )
a mousetrap data object created using one of the mt_import
functions (see mt_example for details). Alternatively, a trajectory
array can be provided directly (in this case
a character string specifying which trajectory data should be used.
a character string specifying where the resulting data should be stored.
a character vector specifying which trajectory variables should be used. Can be of length 2 or 3 for two-dimensional or three-dimensional trajectories respectively.
numeric vector specifying the relative importance of the
variables specified in
boolean specifying the way dissimilarity between the
trajectories is measured (see Details). If
an integer specifying the distance metric.
logical specifying whether trajectory points containing NAs should be removed. Removal is done column-wise. That is, if any trajectory has a missing value at, e.g., the 10th recorded position, the 10th position is removed for all trajectories. This is necessary to compute distance between trajectories.
A mousetrap data object (see mt_example) with an additional
object added (by default called
distmat) containing the distance
matrix. If a trajectory array was provided directly as
the distance matrix will be returned.
mt_distmat computes point- or vector-wise dissimilarities between
pairs of trajectories. Point-wise dissimilarity refers to computing the
distance metric defined by
minkowski_p for every point of the
trajectory and then summing the results. That is, if
minkowski_p = 2
the point-wise dissimilarity between two trajectories, each defined by a set
of x and y coordinates, is calculated as
sum(sqrt((x_i-x_j)^2 + (y_i-y_j)^2)).
Vector-wise dissimilarity, on the other hand refers to computing the distance
metric once for the entire trajectory. That is, vector-wise dissimilarity is
sqrt(sum((x_i-x_j)^2 + (y_i-y_j)^2)).
# Spatialize trajectories mt_example <- mt_spatialize(mt_example) # Compute distance matrix mt_example <- mt_distmat(mt_example, use="sp_trajectories")