Loading required package: CircStats
Loading required package: MASS
Attaching package: 'MASS'
The following object is masked from 'package:dplyr':
select
Loading required package: boot
library(depmixS4)
Loading required package: nnet
Loading required package: Rsolnp
Attaching package: 'depmixS4'
The following objects are masked from 'package:moveHMM':
stationary, viterbi
library(circular)
Attaching package: 'circular'
The following objects are masked from 'package:CircStats':
A1, A1inv, deg, I.0, I.1, I.p, pp.plot, rad, rose.diag, rstable
The following objects are masked from 'package:stats':
sd, var
The data for this booby are specified in latitude and longitude, which means they are based on angular coordinates on Earth’s surface. Methods described earlier rely on distance metrics (e.g., step lengths). While it’s possible to compute traveled distances using latitude and longitude, this involves formulas specific to spherical movements.
To circumvent this and use Euclidean distance, data are often projected into a local system. This projection must match the region of interest. Here, we use UTM coordinates for Zone 25 South. Geographic data manipulation is made easier in R using the sf package, which we use to project the data for easier distance calculations.
Data here are acquired at high frequency (one point every 10 seconds). Although GPS data have minimal error, the close temporal spacing of observations can add erraticity to trajectories. Such erraticity is particularly visible in movement metrics used to detect different activities.
To correct for these errors, we define a simple Gaussian linear hidden Markov model, as discussed earlier. The hidden dynamics are modeled as a random walk with an unknown innovation matrix, and the observation model assumes a Gaussian distribution centered on the true position with an unknown diagonal variance. The parameters are estimated using the EM algorithm in the MARSS package, and Kalman smoothing is used to estimate the true trajectory.
A smoothed trajectory preview is shown in the figure below, illustrating how smoothing reduces trajectory irregularities. However, note that this transformation involves working with modified data, whose relevance may vary in specific cases.
First, we fit a three-state model. The discussion about choosing the number of states is addressed later.
Defining Metrics
We aim to identify different behavioral types within the trajectory, such as foraging (associated with rapid direction changes) and goal-directed travel (characterized by straighter trajectories). Relevant metrics here are turning angle and step length, as these are biologically meaningful for these birds.
We fit two models differing by the considered movement metrics (and their corresponding emission distributions):
Step Length/Angle: Metrics from Morales et al. (2004), using gamma distribution for step length and von Mises distribution for angles.
Bivariate Velocity: Metrics from Gurarie, Andrews, and Laidre (2009), using two independent normal distributions.
Initializing the Algorithm
These models without covariates have 18 parameters (12 for emission distributions and 6 for transition probabilities). Optimization in such a parameter space is sensitive to initial values. We use a simple k-means classification to find plausible initial parameters for the regimes.
For both packages used, HMM parameters are estimated via maximum likelihood, and the most probable sequence of hidden states is retrieved using the Viterbi algorithm. Hidden states correspond to velocity and turning angle distributions. In trajectory terms, they describe segments between two positions (separated by 10 seconds).
Gurarie, Eliezer, Russel D Andrews, and Kristin L Laidre. 2009. “A Novel Method for Identifying Behavioural Changes in Animal Movement Data.”Ecology Letters 12 (5): 395–408.
Morales, Juan Manuel, Daniel T Haydon, Jacqui Frair, Kent E Holsinger, and John M Fryxell. 2004. “Extracting More Out of Relocation Data: Building Movement Models as Mixtures of Random Walks.”Ecology 85 (9): 2436–45.