The purpose of this vignette is to introduce a new argument
interpolation_type = "crawl" for the
anipaths::animate_paths() function. This interpolation type
is based on the correlated random walk model implemented in the
package and offers an alternative to the spline-based general additive
model (GAM) from the
(see also Buderman
et al. (2016)). The primary benefits of the new interpolation type
are (i) an alternative form of temporal dependence that may be more
consistent with real animal movement, and (ii) the potential to simulate
several realizations from the fitted correlated random walk model to
better depict uncertainty for animal trajectories.
New types of plots are also offered when using the
interpolation including points, points with tails, blur
points, and blur points with tails. Blur points are semi-transparent and
vary in diameter according to point-wise uncertainty estimates. For
example, if uncertainty is large, the blur effect will be larger in
In addition to
anipaths, load packages
magrittr to prepare the
vultures dataset is a built in data inside the
anipaths package. We will use
illustrate the functionality of the package. To prepare the data, we
need to create a time stamp variable of class
POSIX. If you wish to specify the interval of predicted
time as a character string (e.g.,
"day"), the class of your
time variable must be
mutate(POSIX = as.POSIXct(timestamp, tz = "UTC"))
vultures_spring11 <- vultures %>%
filter(POSIX > as.POSIXct("2011-04-05", origin = "1970-01-01") &
POSIX < as.POSIXct("2011-05-05", origin = "1970-01-01")
c('Argentina', 'Domingo', 'La Pampa', 'Whitey', 'Young Luro'))
In addition, the data must have an easting/longitude and
northing/latitude variable. You can set the name for your coordinate
coord argument (default is
crawl Interpolation with
This animation will interpolate synchronized paths for each animal in
vultures data. A default value of 5 simulated
trajectories will be generated in addition to a single best-estimate of
the true trajectories. The animation will represent each animal with one
point, and 5 + 1 lines for each simulation and best prediction
The interval of time can also be changed to several hours instead of days. At this finer resolution the simulated trajectories are more visible, although it does take longer to produce the animation because more images are used.
Besides an individual point for each animal, a blur point is also available to depict pointwise uncertainty. The larger the blurred point, the larger the uncertainty.
crawl Interpolation with Tails and
To add a
ggmap background from Google, we first need to
register our API key using the
ggmap package. The function will throw an error if
registration has not been done before hand.
Set the argument
background = TRUE in the
animate_paths() function to get a background from Google
TRUE statement will produce an automatically
chosen background map that attempts to match the extent of the data.
Another way to set a background is to provide information on the center,
zoom, and type of the desired map tiles.
Once a background has been defined, simply run the
animate_paths() function with an additional parameter
background = background.
Sometimes it is useful good to focus on a single animal to see their movement in details with a a zoomed in window. We can focus on one individual in the vultures application by first sub-setting the data to select only one animal. For this example, we isolated Irma in the animation.
Then, run the same
animate_paths function with the same
parameters as specified before.
simulation: change this parameter to
to see only one best estimate of the continuous trajectory of the animal
instead of multiple relations
simulation.iter: change this value to higher or lower
than 5 to see more or fewer predicted realizations
theme_map: add a customized theme for the background of
the animation other than a map background
For more information about each parameters, run