Bayesian State-Space Models for Animal Movement

Tools to fit Bayesian state-space models to animal tracking data. Models are provided for location filtering, location filtering and behavioural state estimation, and their hierarchical versions. The models are primarily intended for fitting to ARGOS satellite tracking data but options exist to fit to other tracking data types. For Global Positioning System data, consider the 'moveHMM' package. Simplified Markov Chain Monte Carlo convergence diagnostic plotting is provided but users are encouraged to explore tools available in packages such as 'coda' and 'boa'.

Project Status: Active - The project has reached a stable, usable state and is being actively developed. Build Status CRAN_Status_Badge CRAN_Downloads CRAN_Downloads

bsam - Bayesian State-space models for Animal Movement.

bsam is an R package that fits Bayesian state-space models via JAGS to Argos satellite tracking data. The models filter error-prone Argos locations and estimate behavioural states associated with two fundamentally different movement patterns (directed, fast movements and relatively undirected, slow movements). The models can be fit to individual animal tracks or simultaneously to a group of individuals. Plotting functions are provided to help assess lack of MCMC convergence, map estimated tracks and visualise fit to the observations.

Read ?bsam for more details on functionality and ?fit_ssm for details and examples of how to use the package.


First ensure that you have a working copy of JAGS (>= 4.2.0) for the rjags package, see instructions below.


Get the released version of bsam from CRAN:


Or download the current development version from GitHub:

# install.packages("devtools")  

JAGS installation

Install JAGS:


bsam 1.1.2

  • fixed indexing on priors for initial location state. A sufficiently short time step could cause the hierarchical models to crash on compilation.

bsam 1.1.1

  • fixed the mis-ordering of animal id's in the summary and data output data.frames caused when a hierarchical model was fit to a dataset with >= 10 individuals


  • changed diag_ssm plot so that diagnostic panels for psi parameters are split into multiple pages of 5 rows/page when fitting a hierarchical model. Previous version packed all the psi diagnostic plots into a single page

bsam 1.1.0

  • major bug fix - data indexing when fitting hierarchical models was causing improper fits to multi-individual datasets with > 2 individuals. Indexing now works as intended
  • Added simulate function
  • Prevented individual animal tracks from being re-ordered by split function so output track order now matches input track order


  • added list of initial values to the output list object. Making these available can aid diagnosing lack of convergence and inform choice of span argument value for generating location state initial values


  • added get_summary function to extract summary data_frame from fit_ssm output objects. The data_frame can optionally be written to a .csv file


  • added sp and rworldxtra back to Imports list in DESCRIPTION. Ensures all required packages are installed, otherwise map_ssm will return an error when attempting to load countriesHigh data if sp and/or rworldxtra are not installed


  • removed sp and rworldxtra from Imports

  • added BugReports URL to DESCRIPTION

bsam 1.0.0

  • Simplified movement models by removing the mean turn angle parameter. This tends to improve convergence for the behavioural switching models

  • Simplified the regularisation / interpolation in the observation models

  • Simplified data preparation code

  • Diagnostic plots (renamed from diagSSM to diag_ssm) now include the Gelman-Rubin-Brooks shrink factor plots for each parameter

  • New mapping function (map_ssm) uses coastline data from rworldxtra and ggplot2 for core plotting functions

  • New plot function (plot_fit) to inspect fit to location data

  • Renamed core function fitSSM to fit_ssm

  • Improved selection of random initial values for MCMC sampling

  • Initial values for location states are now based on a loess smooth through the observed locations. Users can control the degree of smoothing via the span argument to fit_ssm

bsam 0.43.1 (pre-CRAN release)

  • ported from source 2016-05-27 [email protected]

  • converted to use roxygen2

  • Added a file to track changes to the package.

f <- ""
download.file(f, basename(f), mode = "wb")
system(sprintf("tar zxvf %s", basename(f)))

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.1.3 by Ian Jonsen, a year ago


Report a bug at

Browse source code at

Authors: Ian Jonsen [aut, cre] , Sophie Bestley [ctb] , Simon Wotherspoon [ctb] , Michael Sumner [ctb] , Joanna Mills Flemming [ctb]

Documentation:   PDF Manual  

Task views: Handling and Analyzing Spatio-Temporal Data, Processing and Analysis of Tracking Data

GPL-2 license

Imports coda, dplyr, ggplot2, gridExtra, msm, mvtnorm, rworldxtra, sp, tibble, lubridate

Depends on rjags

System requirements: JAGS (>= 4.3.0)

See at CRAN