Learn R Programming

crawl (version 2.2.0)

crwMLE: Fit Continuous-Time Correlated Random Walk Models to Animal Telemetry Data

Description

The function uses the Kalman filter to estimate movement paramters in a state-space version of the continuous-time movement model. Separate models are specified for movement portion and the location error portion. Each model can depend on time indexed covariates. A “haul out” model where movement is allowed to completely stop, as well as, a random drift model can be fit with this function.

Usage

crwMLE(mov.model = ~1, err.model = NULL, activity = NULL, drift = FALSE,
  data, coord = c("x", "y"), Time.name, time.scale = "hours", theta, fixPar,
  method = "Nelder-Mead", control = NULL, constr = list(lower = -Inf,
  upper = Inf), prior = NULL, need.hess = TRUE, initialSANN = list(maxit =
  200), attempts = 1, ...)

Arguments

mov.model

formula object specifying the time indexed covariates for movement parameters.

err.model

A 2-element list of formula objects specifying the time indexed covariates for location error parameters.

activity

formula object giving the covariate for the activity (i.e., stopped or fully moving) portion of the model.

drift

logical indicating whether or not to include a random drift component. For most data this is usually not necessary. See northernFurSeal for an example using a drift model.

data

data.frame object containg telemetry and covariate data. A 'SpatialPointsDataFrame' object from the package 'sp' or an 'sf' object from the 'sf' package with a geometry column of type sfc_POINT. 'spacetime' objects were previously accepted but no longer valid. Values for coords will be taken from the spatial data set and ignored in the arguments. Spatial data must have a valid proj4string or epsg and must NOT be in longlat.

coord

A 2-vector of character values giving the names of the "X" and "Y" coordinates in data.

Time.name

character indicating name of the location time column

time.scale

character. Scale for conversion of POSIX time to numeric for modeling. Defaults to "hours".

theta

starting values for parameter optimization.

fixPar

Values of parameters which are held fixed to the given value.

method

Optimization method that is passed to optim.

control

Control list which is passed to optim.

constr

Named list with elements lower and upper that are vectors the same length as theta giving the box constraints for the parameters

prior

A function returning the log-density function of the parameter prior distribution. THIS MUST BE A FUNCTION OF ONLY THE FREE PARAMETERS. Any fixed parameters should not be included.

need.hess

A logical value which decides whether or not to evaluate the Hessian for parameter standard errors

initialSANN

Control list for optim when simulated annealing is used for obtaining start values. See details

attempts

The number of times likelihood optimization will be attempted

...

Additional arguments that are ignored.

Value

A list with the following elements:

par

Parameter maximum likelihood estimates (including fixed parameters)

estPar

MLE without fixed parameters

se

Standard error of MLE

ci

95% confidance intervals for parameters

Cmat

Parameter covariance matrix

loglik

Maximized log-likelihood value

aic

Model AIC value

coord

Coordinate names provided for fitting

fixPar

Fixed parameter values provided

convergence

Indicator of convergence (0 = converged)

message

Meesages given by optim during parameter optimization

activity

Model provided for stopping variable

drift

Logical value indicating random drift model

mov.model

Model description for movement component

err.model

Model description for location error component

n.par

number of parameters

nms

parameter names

n.mov

number of movement parameters

n.errX

number or location error parameters for "longitude" error model

n.errY

number or location error parameters for "latitude" error model

stop.mf

covariate for stop indication in stopping models

polar.coord

Logical indicating coordinates are polar latitude and longitude

init

Initial values for parameter optimization

data

Original data.frame used to fit the model

lower

The lower parameter bounds

upper

The upper parameter bounds

need.hess

Logical value

runTime

Time used to fit model

Details

A full model specification involves 4 components: a movement model, a stopping model, 2 location error models, and a drift indication. The movement model (mov.model) specifies how the movement parameters should vary over time. This is a function of specified, time-indexed, covariates. The movement parameters (sigma for velocity variation and beta for velocity autocorrelation) are both modeled with a log link as par = exp(eta), where eta is the linear predictor based on the covariates. The err.model specification is a list of 2 such models, one for “longitude” and one for “latitude” (in that order) location error. If only one location error model is given, it is used for both coordinates (parameter values as well). If drift.model is set to TRUE, then, 2 additional parameters are estimated for the drift process, a drift variance and a beta multiplier. If polar.coord=TRUE then the ad-hoc logitude correction factor described by Johnson et al. (2008) (Ecology 89:1208-1215) is used to adjust the variance scale for the longitude mdoel.

The inital.state is a list with the following elemets (with the exact names):

a A vector with initial state values. It has 4 elemets (x location at time 1, x velocity at time 1, y location at time 1, y velocity at time 1) for non-drift models and 6 elemets for drift models (x location at time 1, x velocity at time 1, x drift velocity at time 1, etc...).

theta and fixPar are vectors with the appropriate number or parameters. theta contains only those paraemters which are to be estimated, while fixPar contains all parameter values with NA for parameters which are to be estimated.

The data set specified by data must contain a numeric or POSIXct column which is used as the time index for analysis. The column name is specified by the Time.name argument. If a POSIXct column is used it is internally converted to a numeric vector with units of hours. If your data are not compatible with these data structures, it is better to convert it yourself prior to analysis with crawl. Also, for stopping models, the stopping covariate must be between 0 and 1 inclusive, with 1 representing complete stop of the animal (no true movement, however, location error can still occur) and 0 represent unhindered movement. The coordinate location should have NA where no location is recorded, but there is a change in the movment covariates.

The CTCRW models can be difficult to provide good initial values for optimization. If initialSANN is specified then simulated annealing is used first to obtain starting values for the specified optimaization method. If simulated annealing is used first, then the returned init list of the crwFit object will be a list with the results of the simulated annealing optimization.