simData: Simulation tool

Description Usage Arguments Details Value Examples

View source: R/simData.R

Description

Simulates movement data from an HMM.

Usage

1
2
3
4
5
simData(nbAnimals = 1, nbStates = 2, stepDist = c("gamma", "weibull",
  "lnorm", "exp"), angleDist = c("vm", "wrpcauchy", "none"), stepPar = NULL,
  anglePar = NULL, beta = NULL, covs = NULL, nbCovs = 0,
  zeroInflation = FALSE, obsPerAnimal = c(500, 1500), model = NULL,
  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. Default: NULL. Covariates can also be simulated according to a standard normal distribution, by setting covs to NULL, and specifying nbCovs>0.

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 picked from this interval. Default: c(500,1500).

model

A moveHMM object. This option can be used to simulate from a fitted model. Default: NULL. Note that, if this argument is specified, most other arguments will be ignored – except for nbAnimals, obsPerAnimal, covs (if covariate values different from those in the data should be specified), and states.

states

TRUE if the simulated states should be returned, FALSE otherwise (default).

Details

Value

An object moveData, i.e. a dataframe of:

ID

The ID(s) of the observed animal(s)

step

The step lengths

angle

The turning angles (if any)

x

Either easting or longitude

y

Either northing or latitude

...

Covariates (if any)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 1. Pass a fitted model to simulate from
# (m is a moveHMM object - as returned by fitHMM - automatically loaded with the package)
# We keep the default nbAnimals=1.
m <- example$m
obsPerAnimal=c(50,100)
data <- simData(model=m,obsPerAnimal=obsPerAnimal)

# 2. Pass the parameters of the model to simulate from
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"
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", which is determined
# by the number of columns 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)

TheoMichelot/moveHMM documentation built on June 5, 2018, 12:15 p.m.