GEOG 566

         Advanced spatial statistics and GIScience

April 25, 2018

Using a hidden Markov Model tool to identify movement patterns of recreationists

Filed under: 2018,Exercise/Tutorial 1 2018 @ 2:48 pm

Question that you asked

For this exercise, the question that I asked was how to use path segmentation analysis to identify movement patterns of day-user recreationists at String and Leigh Lake in Grand Tetons National Park.

Name of the tool or approach that you used.

To answer this question, Susie and I employed methods derived from the hidden Markov Model (hMM). Hidden Markov Models, a type of path segmentation analysis, are typically used in the field of movement ecology to understand animal behavior. These models relate animal behavior to covariates, i.e. other environmental factors or ‘hidden states’ that may drive and explain animal movement. Often the movement of animals are separated into researcher-defined ‘states’: slow moving states (foraging) or faster moving states (in transit). Understanding the conditions and underlying features that influence the change in movement between these states is at the heart of what makes this analytical tool useful for movement ecologists – and potentially for social scientists.

What makes hMM an appealing tool for our GPS data is the assumptions necessary for this analysis align with the features of our dataset: (1) measurement error is small to negligible, and (2) the sampling units collect data at regular intervals.  The field of recreation science is only beginning to explore more advanced spatial methods to analyze and understand human behavior in outdoor recreation systems. Thus, this exercise is an opportunity to adopt tools and methods employed by other disciplines and test how compatible they are with human movement data.

In July 2017, Michelot, Langrock, & Patterson developed an R package —  ‘moveHMM’ — that provides step-by-step instructions to prep data into appropriate formats for hMM analysis. This package is built with the functions and algorithms necessary for more rigorous statistical testing with multiple variables, but for the purposes of this exercise we used moveHMM package to conduct a univariate analysis of two variables:  step-length and turning angle.

Brief description of steps you followed to complete the analysis.

Step 1: Subset data I chose to use nine tracks that were collected on July 19, 2017.

Step 2: Create unique ID column The moveHMM package requires that each track contain a ID column with a unique numeric value allocated to each individual.

Step 3: Establish temporal parameters To calculate the step lengths and turning angles, we needed to define the temporal parameter for each step segment (i.e. every minute, every five minutes, every 6 hours, etc). The original dataframe had a temporal resolution of 10 seconds. However, that level of precision was not necessary for this analysis as we assumed human movement did not vary significantly every 10 seconds. Thus, we aggregated the points to 1-minute intervals. To do this I used the dplyr package in R to average the coordinates to the minute level for each individual.

Step 4: Choose what type of coordinates to use for analysis The moveHMM package allows the user to use either Latitude/Longitude coordinates or UTM coordinates. My original data contained both. I choose to use UTM coordinates rather than Lat/Long. This is because the output for UTM coordinates is represented in meters which is a little easier to interpret and understand than the Latitude and Longitude units.

Step 5: Calculate step-length and turning angle My prepped dataframe is ready to go. It contains: unique ID number, timestamp (at the minute-level), and x & y projection values.

Move HMM has an easy code that quickly calculates the step-length and turning angle. With this code I created a new dataframe that includes these two additional variables.

Step 6: Plot the data The moveHMM package offers a code that plots histograms of the frequency and distribution of step lengths and turning angles for each individual (see results section).

Step 7: Create additional graphs that represent frequency of step-length and angle in % We noticed that the frequency graphs generated in the moveHMM output represented counts on the y-axis rather than percentages. Because the y-axis wasn’t standardized, it made it difficult to compare step-length and turning angle across the nine individuals. Thus, we created two additional histograms that represented frequency as a percent on the y-axis. Note: the histogram of the turning angles is represented as a rose diagram.

Step 8: Plot the tracks on a graph for a visual bonus The final thing we did was plot each GPS track onto a graph so the viewer can have additional context when interpreting the results.

Brief description of results you obtained.

We were able to successfully calculate the turning angles and step-lengths of each individual at one-minute intervals. We also produced graphs of the frequency and distribution of these values, allowing us to make comparisons between individuals and identify common patterns and trends. See images and pdf links below.

I was surprised to see the variation in movement across the nine individuals. Given that 8 of the 9 individuals were hiking on designated trails, I assumed the behavior would be relatively homogeneous, particularly the turning angles. However, the figures indicated that people who spent a relatively short amount of time in the area (<30 minutes) tended to have shorter step lengths and more variability in turning angles.  This could be explained by the environmental features of the areas near the parking lot. Along the southeastern shoreline of String Lake there are locations that are denuded of vegetation and offer ideal conditions for ‘beaching’, sight-seeing, and/or picnicking. Therefore, people who recreate in these areas may have shorter step lengths and greater variation in turning angles than those people who choose to venture further along the trail.

Figure 1: Example of a water-user track. From the top (going clockwise) : plots describing the change in step lengths and turning angles over time; plot of the track with long and lat coordinates; rose diagram representing the frequency of turning angles; histogram representing frequency of step length (in meters).

Figure 2: Example of a land-user track. From the top (going clockwise) : plots describing the change in step lengths and turning angles over time; plot of the track with long and lat coordinates; rose diagram representing the frequency of turning angles; histogram representing frequency of step length (in meters).

Figure 3: Example of another land-user track. From the top (going clockwise) : plots describing the change in step lengths and turning angles over time; plot of the track with long and lat coordinates; rose diagram representing the frequency of turning angles; histogram representing frequency of step length (in meters).

To see all of the output, click on the pdf links below





Critique of the method – what was useful, what was not?

What was useful:

The moveHMM package was easy to understand and provided an example dataset that guided me throughout the analysis. Once I was able to get my data into the proper format, the moveHMM package took care of the calculations and created the initial figures. Additionally, the vignette included a brief overview of the theory and defined the concepts of the hidden Markov Model.

Some criticisms:

The figures that were generated in the moveHMM package were helpful in representing the distribution and values of each person’s step length and turning angle. However, the y-axis of the histograms represented frequency as a count rather than a percentage. Therefore, the y-axis varied for each individual depending on the number of step segments each user generated while carrying the GPS unit. This variation made it difficult to make comparisons between individuals. Therefore, we chose to create supplemental histograms that represented frequency in percent rather than tallies.


Click here to view the moveHMM documentation

Edelhoff, H., Signer, J., & Balkenhol, N. (2016). Path segmentation for beginners: An overview of current methods for detecting changes in animal movement patterns. Movement Ecology, 4(1).

Michelot, T., Langrock, R., & Patterson, T. (2016). moveHMM An R package for the analysis of animal movement data, 1–24.

Patterson, T. A., Basson, M., Bravington, M. V., & Gunn, J. S. (2009). Classifying movement behaviour in relation to environmental conditions using hidden Markov models. Journal of Animal Ecology, 78(6), 1113–1123.



Print Friendly, PDF & Email

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

© 2019 GEOG 566   Powered by WordPress MU    Hosted by