trackLength(x)
duration(x)
speed(x)
displacement(x, from = 1, to = nrow(x))
squareDisplacement(x, from = 1, to = nrow(x))
displacementVector(x)
maxDisplacement(x)
displacementRatio(x)
outreachRatio(x)
straightness(x)
overallAngle(x, from = 1, to = nrow(x), xdiff = diff(x))
meanTurningAngle(x)
overallDot(x, from = 1, to = nrow(x), xdiff = diff(x))
asphericity(x)
hurstExponent(x)
fractalDimension(x)
aggregate.tracks
; for instance,
squareDisplacement
combined with aggregate.tracks
gives a mean
square displacement plot, and overallAngle
combined with
aggregate.tracks
gives a turning angle plot (see the examples for
aggregate.tracks
). To speed up computation of these measures on
subtracks of the same track, the arguments from
, to
and
possibly xdiff
are exploited by aggregate.tracks
.trackLength
sums up the distances between subsequent positsion; in other words,
it estimates the length of the underlying track by linear interpolation (usually
an underestimation). The estimation could be improved in some circumstances by using
interpolateTrack
.
duration
returns the time elapsed between x
's first and last
positions.
speed
simply divides trackLength
by duration
.
displacement
returns the Euclidean distance between the track endpoints
and squareDisplacement
returns the squared Euclidean distance.
displacementVector
returns the vector between the track endpoints.
maxDisplacement
computes the maximal Euclidean distance of any position
on the track from the first position.
displacementRatio
divides the displacement
by the maxDisplacement
;
outreachRatio
divides the maxDisplacement
by the trackLength
(Mokhtari et al, 2013). Both measures return
values between 0 and 1, where 1 means a perfectly straight track.
If the track has trackLength
0, then NaN
is returned.
straightness
divides the displacement
by the trackLength
.
This gives a number between 0 and 1, with 1 meaning a perfectly straight track.
If the track has trackLength
0, then NaN
is returned.
asphericity
is a different appraoch to measure straightness
(Mokhtari et al, 2013): it computes the asphericity of the set of positions on the
track _via_ the length of its principal components. Again this gives a number between 0
and 1, with higher values indicating straighter tracks.
Unlike straightness
, however, asphericity ignores
back-and-forth motion of the object, so something that bounces between two positions
will have low straightness
but high asphericity
. We define the
asphericity of every track with two or fewer positions to be 1. For one-dimensional
tracks with one or more positions, NA
is returned.
overallAngle
Computes the angle (in radians) between the first and the last
segment of the given track. Angles are measured symmetrically, thus the return values
range from 0 to pi; for instance, both a 90 degrees left and right turns yield the
value pi/2. This function is useful to generate autocorrelation plots
(together with aggregate.tracks
).
meanTurningAngle
averages the overallAngle
over all
adjacent segments of a given track; a low meanTurningAngle
indicates high
persistence of orientation, whereas for an uncorrelated random walk we expect
90 degrees. Note that angle measurements will yield NA
values for tracks
in which two subsequent positions are identical.
overallDot
computes the dot product between the first and the last
segment of the given track. This function is useful to generate autocovariance plots
(together with aggregate.tracks
).
hurstExponent
computes the corrected empirical Hurst exponent of the track.
This uses the function hurstexp
from the `pracma` package.
If the track has less than two positions, NA is returned.
fractalDimension
estimates the fractal dimension of a track using the function
fd.estim.boxcount
from the
`fractaldim` package. For self-affine processes in $n$ dimensions,
fractal dimension and Hurst exponent
are related by the formula $H=n+1-D$.
For non-Brownian motion, however, this relationship
need not hold. Intuitively, while the Hurst exponent takes a global approach to the
track's properties, fractal dimension is a local approach to the track's properties
(Gneiting and Schlather, 2004).
Tillmann Gneiting and Martin Schlather (2004), Stochastic Models That Separate Fractal Dimension and the Hurst Effect. SIAM Review 46(2), 269--282. doi:10.1137/S0036144501394387
## show a turning angle plot with error bars for the T cell data.
with( (aggregate(BCells,overallDot,FUN="mean.se",na.rm=TRUE)),{
plot( mean ~ i, xlab="time step",
ylab="turning angle (rad)", type="l" )
segments( i, lower, y1=upper )
} )
Run the code above in your browser using DataLab