A trajectory is made of successive steps traveled by an organism in the
geographical space. These steps (the line connecting two successive
relocations) can be described by a certain number of descriptive
parameters (relative angles between successive steps, length of the
step, etc.). One aim of the trajectory analysis is to identify
the structure of the trajectory, i.e. the parts of the trajectory where the
steps have homogeneous properties. Indeed, an animal may have a wide
variety of behaviours (feeding, traveling, escape from a predator,
etc.). As a result, partitioning a trajectory occupies a central place in
trajectory analysis.
These functions are to be used to partition a trajectory based on Markov
models of animal movements. For example, one may suppose that a
normal distribution generated the step lengths, with a different mean
for each type of behaviour. These models and the value of their
parameters are supposed a priori by the analyst. These functions
allow, based on these a priori models, to find both the number and the
limits of the segments building up the trajectory (see examples). Any
model can be supposed for any parameter of the steps (the distance,
relative angles, etc.), provided that the model is Markovian.
The rationale behind this algorithm is the following. First, the user
should propose a set of model describing the movements of the animals,
in the different segments of the trajectory. For example, the user may
define two models of normal distribution for the step length, with
means equal to 10 meters (i.e. a trajectory with relatively small steps)
and 100 meters (i.e. a trajectory with longer step lengths). For a
given step of the trajectory, it is possible to compute the probability
density that the step has been generated by each model of the set.
The function modpartltraj
computes the matrix containing the
probability densities associated to each step (rows), under each model
of the set (columns). This matrix is of class modpartltraj
.
Then, the user can estimate the optimal number of segments in the
trajectory, given the set of a priori models, using the function
bestpartmod
, taking as argument the matrix of class
modpartltraj
. If correction = FALSE
, this function
returns the log of the probability (log-likelihood) that the trajectory
is actually made of K
segments, with each one described by one
model. The resulting graph can be used to choose an optimal number of
segment for the partition. Note that Gueguen (2009) noted that this
algorithm tends to overestimate the number of segments in a
trajectory. He proposed to correct this estimation using Monte Carlo
simulations of the independence of the steps within the trajectory. At
each step of the randomization process, the order of the rows of the
matrix is randomized, and the curve of log-likelihood is computed for
each number of segments, for the randomized trajectory. Then, the
observed log-likelihood is corrected by these simulations: for a given
number of segments, the corrected log-likelihood is equal to the
observed log-likelihood minus the simulated log-likelihood. Because
there is a large number of simulations of the independence, a
distribution of corrected log-likelihoods is available for each number
of segments. The "best" number of segments is the one for which the
median of the distribution of corrected log-likelihood is maximum.
Finally, once the optimal number of segments npart
has been
chosen, the function partmod.ltraj
can be used to compute the
partition.
The mathematical rationale underlying these two functions is the
following: given an optimal k-partition of the trajectory, if the ith
step of the trajectory belongs to the segment k predicted by the model d,
then either the relocation (i-1) belongs to the same segment, in which
case the segment containing (i-1) is predicted by d, or the relocation
(i-1) belongs to another segment, and the other (k-1) segments
together constitute an optimal (k-1) partition of the trajectory
1-(i-1). These two probabilities are computed recursively by the
functions from the matrix of class partmodltraj
, observing that
the probability of a 1-partition of the trajectory from 1 to i described
by the model m (i.e. only one segment describing the trajectory) is
simply the product of the probability densities of the steps from 1 to
i under the model m. Further details can be found in Gueguen (2001, 2009).