Learn R Programming

moveHMM (version 1.0)

nLogLike: Negative log-likelihood function

Description

Negative log-likelihood function

Usage

nLogLike(wpar, nbStates, bounds, parSize, data, stepDist = c("gamma",
  "weibull", "lnorm", "exp"), angleDist = c("vm", "wrpcauchy", "none"),
  angleMean = NULL, zeroInflation = FALSE, stationary = FALSE)

Arguments

wpar
Vector of working parameters.
nbStates
Number of states of the HMM.
bounds
Matrix with 2 columns and as many rows as there are elements in wpar. Each row contains the lower and upper bound for the correponding parameter.
parSize
Vector of two values: number of parameters of the step length distribution, number of parameters of the turning angle distribution.
data
An object moveData.
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.
angleMean
Vector of means of turning angles if not estimated (one for each state). Default: NULL (the angle mean is estimated).
zeroInflation
TRUE if the step length distribution is inflated in zero. Default: FALSE. If TRUE, initial values for the zero-mass parameters should be included in stepPar0.
stationary
FALSE if there are covariates. If TRUE, the initial distribution is considered equal to the stationary distribution. Default: FALSE.

Value

  • The negative log-likelihood of the parameters given the data.

Examples

Run this code
# data is a moveData object (as returned by prepData), automatically loaded with the package
data <- example$data
simPar <- example$simPar
par0 <- example$par0

estAngleMean <- is.null(simPar$angleMean)
bounds <- parDef(simPar$stepDist,simPar$angleDist,simPar$nbStates,
                 estAngleMean,simPar$zeroInflation)$bounds
parSize <- parDef(simPar$stepDist,simPar$angleDist,simPar$nbStates,
                  estAngleMean,simPar$zeroInflation)$parSize

par <- c(par0$stepPar0,par0$anglePar0)
wpar <- n2w(par,bounds,par0$beta0,par0$delta0,simPar$nbStates,FALSE)

l <- nLogLike(wpar=wpar,nbStates=simPar$nbStates,bounds=bounds,parSize=parSize,data=data,
             stepDist=simPar$stepDist,angleDist=simPar$angleDist,angleMean=simPar$angleMean,
             zeroInflation=simPar$zeroInflation)

Run the code above in your browser using DataLab