Package 'movetrack'

Title: Model flight paths from radio-telemetry data
Description: movetrack is an R package that provides simple functionality to model flight tracks from telemetry data using a hidden Markov model written in Stan.
Authors: Georg Rüppel [aut, cre] (ORCID: <https://orcid.org/0000-0001-5459-6717>)
Maintainer: Georg Rüppel <[email protected]>
License: MIT + file LICENSE
Version: 1.1.2
Built: 2026-06-03 08:27:35 UTC
Source: https://codeberg.org/g-rppl/movetrack

Help Index


Coerce to a Data Frame

Description

Coerce a movetrack object to a data.frame.

Usage

## S3 method for class 'movetrack'
as.data.frame(x, ...)

Arguments

x

An object of class movetrack.

...

Unused; for compatibility with the generic method.


Extract draws

Description

Extract draws from a movetrack object.

Usage

getDraws(fit, n = 50)

Arguments

fit

An object of class movetrack.

n

The number of draws to extract; defaults to 50.

Value

A data.frame with the draws.


Map model result

Description

Map individual flight trajectories and model uncertainty.

Usage

mapTrack(fit, id = NULL, nsim = 50, lwd = 2, alpha = 0.1)

Arguments

fit

An object of class movetrack.

id

The individuals to plot. Defaults to NULL which plots all individuals.

nsim

The number of posterior draws to plot. Defaults to 50.

lwd

The line width for the median trajectory. Defaults to 2.

alpha

The alpha value for the posterior draws. Defaults to 0.1.

Value

Returns an overview map with the median trajectories and nsim posterior draws per individual.

Examples

## Not run: 
mapTrack(fit)
mapTrack(fit, nsim = 100, alpha = 0.05)

## End(Not run)

Motus test data

Description

Motus test data

Usage

motusData

Format

An object of class tbl_df (inherits from tbl, data.frame) with 4464 rows and 7 columns.

References

https://motus.org/


Plot model results

Description

Plot model results per individual and variable.

Usage

## S3 method for class 'movetrack'
plot(x, vars = c("lon", "lat"), id = NULL, ...)

Arguments

x

An object of class movetrack.

vars

The variables to plot. Defaults to c("lon", "lat").

id

The individuals to plot. Defaults to NULL which plots all individuals.

...

Unused; for compatibility with the generic method.

Value

Returns one or multiple ggplot plots.


Print

Description

Print a summary for a movetrack object.

Usage

## S3 method for class 'movetrack'
print(x, ...)

Arguments

x

An object of class movetrack.

...

Unused; for compatibility with the generic method.


Summary

Description

Create a summary of a movetrack object.

Usage

## S3 method for class 'movetrack'
summary(object, var = c("lon", "lat"), ...)

Arguments

object

An object of class movetrack.

var

The variable(s) to summarise; defaults to c("lon", "lat").

...

Additional arguments passed to posterior::summarise_draws().

Value

A data.frame with the summary statistics.

See Also

'posterior::summarise_draws()

Examples

## Not run: 
summary(fit)
summary(fit, var = "lambda")
summary(fit, var = c("distance", "speed"), "mean", "sd")

## End(Not run)

Model flight paths

Description

Model flight paths from raw telemetry data using a hidden Markov model.

Usage

track(
  data,
  ID = "tagDeployID",
  ts = "ts",
  sig = "sig",
  aLon = "recvDeployLon",
  aLat = "recvDeployLat",
  aType = "antType",
  aBearing = "antBearing",
  aRange = default_aRange(),
  dTime = 2,
  states = 2,
  i_lambda = TRUE,
  model = TRUE,
  ...
)

default_aRange()

Arguments

data

A data.frame containing the telemetry data.

ID

Column containing unique identifier for individuals or tag deployments.

ts

Timestamp column.

sig

Signal strength column.

aLon

Antenna longitude column.

aLat

Antenna latitude column.

aType

Antenna type column, required for antenna-specific detection ranges. Omnidirectional antennas must be named "monopole".

aBearing

Antenna bearing column.

aRange

Theoretical antenna ranges in kilometres. Can be a single numeric value or a named list of values for different antenna types defined in the aType column. Defaults to default_aRange(), which returns values for monopoles and Yagi antennas based on the ranges given in the Motus Docs:

Antenna type Theoretical range
monopole ~1 km
3-element Yagi ~5 km
4-element Yagi ~6 km
5-element Yagi ~8 km
6-element Yagi ~10 km
9-element Yagi ~15 km

Overwrite or add values using utils::modifyList() (see Examples).

dTime

Time interval in minutes for which point estimates are to be calculated.

states

The number of states to use in the model; defaults to 2.

i_lambda

Logical indicating whether to estimate individual correlation parameters; defaults to TRUE.

model

Logical indicating whether to run the model; defaults to TRUE.

...

Additional arguments passed to cmdstanr::sample().

Details

This function first calculates point estimates based on antenna bearing and signal strength as described in Baldwin et al. 2018:

  • Estimate locations for each detection: half of the maximum detection range aRange along the directional beam.

  • Derive oscillating measurement error arising from antenna geometry and orientation.

  • Calculate weighted means and errors (by signal strength) for each time interval dTime.

For omnidirectional antennas, the station’s location is used with a circular measurement error.

The results are then passed to Stan via cmdstanr and individual flights paths are estimated using a hidden Markov model (HMM).

Value

Returns a movetrack object including the posterior distributions for longitude, latitude, distance in m, and speed per time interval in m/s. If model is FALSE, only the results from the first step are returned as a data.frame containing estimated coordinates and measurement errors for each time interval.

References

Auger‐Méthé, M., Newman, K., Cole, D., Empacher, F., Gryba, R., King, A. A., ... & Thomas, L. (2021). A guide to state–space modeling of ecological time series. Ecological Monographs, 91(4), e01470. doi:10.1002/ecm.1470

Baldwin, J. W., Leap, K., Finn, J. T., & Smetzer, J. R. (2018). Bayesian state-space models reveal unobserved off-shore nocturnal migration from Motus data. Ecological Modelling, 386, 38-46. doi:10.1016/j.ecolmodel.2018.08.006

Jonsen, I. D., Flemming, J. M., & Myers, R. A. (2005). Robust state–space modeling of animal movement data. Ecology, 86(11), 2874-2880. doi:10.1890/04-1852

See Also

cmdstanr::sample()

Examples

## Not run: 
# Load data
data(motusData)

# Model flight paths
track(motusData)
track(motusData, aRange = 10, dTime = 5)
track(motusData,
  aRange = modifyList(default_aRange(), list("yagi-4" = 7, "custom-6" = 10))
)
track(motusData, states = 1, i_lambda = FALSE)

# Location estimates only
track(motusData, model = FALSE)
track(motusData, dTime = 1, aRange = 10, model = FALSE)

## End(Not run)