nLogLike: Negative log-likelihood function

View source: R/nLogLike.R

nLogLikeR Documentation

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,
  knownStates = NULL
)

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.

knownStates

Vector of values of the state process which are known prior to fitting the model (if any). Default: NULL (states are not known). This should be a vector with length the number of rows of 'data'; each element should either be an integer (the value of the known states) or NA if the state is not known.

Value

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

Examples

## Not run: 
# 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)

## End(Not run)


TheoMichelot/moveHMM documentation built on March 18, 2024, 2:38 a.m.