Learn R Programming

moveHMM (version 1.0)

simData: Simulation tool

Description

Simulates movement data from an HMM.

Usage

simData(nbAnimals, nbStates, stepDist = c("gamma", "weibull", "lnorm", "exp"),
  angleDist = c("vm", "wrpcauchy", "none"), stepPar, anglePar = NULL,
  beta = NULL, covs = NULL, nbCovs = 0, zeroInflation = FALSE,
  obsPerAnimal = c(500, 1500), states = FALSE)

Arguments

nbAnimals
Number of observed individuals to simulate.
nbStates
Number of behavioural states to simulate.
stepDist
Name of the distribution of the step lengths (as a character string). Supported distributions are: gamma, weibull, lnorm, exp. Default: gamma.
angleDist
Name of the distribution of the turning angles (as a character string). Supported distributions are: vm, wrpcauchy. Set to "none" if the angle distribution should not be estimated. Default: vm.
stepPar
Parameters of the step length distribution.
anglePar
Parameters of the turning angle distribution.
beta
Matrix of regression parameters for the transition probabilities (more information in "Details").
covs
Covariate values to include in the model, as a dataframe. The number of rows of covs needs to be a multiple of the number of animals, and the same number of observations will be simulated for each animal. Default: NULL. Covariate
nbCovs
Number of covariates to simulate (0 by default). Does not need to be specified of covs is specified.
zeroInflation
TRUE if the step length distribution is inflated in zero. Default: FALSE. If TRUE, values for the zero-mass parameters should be included in stepPar.
obsPerAnimal
Either the number of the number of observations per animal (if single value), or the bounds of the number of observations per animal (if vector of two values). In the latter case, the numbers of obervations generated for each animal are uniformously picke
states
TRUE if the simulated states should be returned, FALSE otherwise (default).

Value

  • An object moveData, i.e. a dataframe of:
  • IDThe ID(s) of the observed animal(s)
  • stepThe step lengths
  • angleThe turning angles (if any)
  • xEither easting or longitude
  • yEither norting or latitude
  • ...Covariates (if any)

Details

The matrix beta of regression coefficients for the transition probabilities has one row for the intercept, plus one row for each covariate, and one column for each non-diagonal element of the transition probability matrix. For example, in a 3-state HMM with 2 covariates, the matrix beta has three rows (intercept + two covariates) and six columns (six non-diagonal elements in the 3x3 transition probability matrix - filled in row-wise). In a covariate-free model (default), beta has one row, for the intercept.

Examples

Run this code
stepPar <- c(1,10,1,5,0.2,0.3) # mean1, mean2, sd1, sd2, z1, z2
anglePar <- c(pi,0,0.5,2) # mean1, mean2, k1, k2
stepDist <- "gamma"
angleDist <- "vm"
obsPerAnimal=c(50,100)
data <- simData(nbAnimals=5,nbStates=2,stepDist=stepDist,angleDist=angleDist,stepPar=stepPar,
               anglePar=anglePar,nbCovs=2,zeroInflation=TRUE,obsPerAnimal=obsPerAnimal)

stepPar <- c(1,10,1,5) # mean1, mean2, sd1, sd2
anglePar <- c(pi,0,0.5,0.7) # mean1, mean2, k1, k2
stepDist <- "weibull"
angleDist <- "wrpcauchy"
data <- simData(nbAnimals=5,nbStates=2,stepDist=stepDist,angleDist=angleDist,stepPar=stepPar,
               anglePar=anglePar,obsPerAnimal=obsPerAnimal)

# step length only and zero-inflation
stepPar <- c(1,10,1,5,0.2,0.3) # mean1, mean2, sd1, sd2, z1, z2
stepDist <- "gamma"
data <- simData(nbAnimals=5,nbStates=2,stepDist=stepDist,angleDist="none",stepPar=stepPar,
               nbCovs=2,zeroInflation=TRUE,obsPerAnimal=obsPerAnimal)

# include covariates
# (note that it is useless to specify "nbCovs" and "obsPerAnimal", which are respectively determined
# by the number of columns and number of rows of "cov")
cov <- data.frame(temp=rnorm(500,20,5))
stepPar <- c(1,10,1,5) # mean1, mean2, sd1, sd2
anglePar <- c(pi,0,0.5,2) # mean1, mean2, k1, k2
stepDist <- "gamma"
angleDist <- "vm"
data <- simData(nbAnimals=5,nbStates=2,stepDist=stepDist,angleDist=angleDist,stepPar=stepPar,
                anglePar=anglePar,covs=cov)

Run the code above in your browser using DataLab