Learn R Programming

momentuHMM (version 1.2.0)

nLogLike: Negative log-likelihood function

Description

Negative log-likelihood function

Usage

nLogLike(wpar, nbStates, formula, bounds, parSize, data, dist, covs,
  estAngleMean, circularAngleMean, zeroInflation, oneInflation,
  stationary = FALSE, cons, fullDM, DMind, workcons, Bndind, knownStates,
  fixPar, wparIndex, nc, meanind, covsDelta)

Arguments

wpar

Vector of working parameters.

nbStates

Number of states of the HMM.

formula

Regression formula for the transition probability covariates.

bounds

Named list of 2-column matrices specifying bounds on the natural (i.e, real) scale of the probability distribution parameters for each data stream.

parSize

Named list indicating the number of natural parameters of the data stream probability distributions

data

An object momentuHMMData.

dist

Named list indicating the probability distributions of the data streams.

covs

data frame containing the beta model covariates (if any)

estAngleMean

Named list indicating whether or not to estimate the angle mean for data streams with angular distributions ('vm' and 'wrpcauchy').

circularAngleMean

Named list indicating whether to use circular-linear (FALSE) or circular-circular (TRUE) regression on the mean of circular distributions ('vm' and 'wrpcauchy') for turning angles.

zeroInflation

Named list of logicals indicating whether the probability distributions of the data streams are zero-inflated.

oneInflation

Named list of logicals indicating whether the probability distributions of the data streams are one-inflated.

stationary

FALSE if there are covariates. If TRUE, the initial distribution is considered equal to the stationary distribution. Default: FALSE.

cons

Named list of vectors specifying a power to raise parameters corresponding to each column of the design matrix for each data stream.

fullDM

Named list containing the full (i.e. not shorthand) design matrix for each data stream.

DMind

Named list indicating whether fullDM includes individual- and/or temporal-covariates for each data stream specifies (-1,1) bounds for the concentration parameters instead of the default [0,1) bounds.

workcons

Named list of vectors specifying constants to add to the regression coefficients on the working scale for each data stream.

Bndind

Named list indicating whether DM is NULL with default parameter bounds for each data stream.

knownStates

Vector of values of the state process which are known prior to fitting the model (if any).

fixPar

Vector of working parameters which are assumed known prior to fitting the model (NA indicates parameters is to be estimated).

wparIndex

Vector of indices for the elements of fixPar that are not NA.

nc

indicator for zeros in fullDM

meanind

index for circular-circular regression mean angles with at least one non-zero entry in fullDM

covsDelta

data frame containing the delta model covariates (if any)

Value

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

Examples

Run this code
# NOT RUN {
# data is a momentuHMMData object (as returned by prepData), automatically loaded with the package
data <- example$m$data
m<-example$m
Par <- getPar(m)
nbStates <- length(m$stateNames)

inputs <- momentuHMM:::checkInputs(nbStates,m$conditions$dist,Par$Par,m$conditions$estAngleMean,
          m$conditions$circularAngleMean,m$conditions$zeroInflation,m$conditions$oneInflation,
          m$conditions$DM,m$conditions$userBounds,m$conditions$cons,m$conditions$workcons,
          m$stateNames)

wpar <- momentuHMM:::n2w(Par$Par,m$conditions$bounds,Par$beta,log(Par$delta[-1]/Par$delta[1]),
        nbStates,m$conditions$estAngleMean,m$conditions$DM,m$conditions$cons,m$conditions$workcons,
        m$conditions$Bndind)

l <- momentuHMM:::nLogLike(wpar,nbStates,m$conditions$formula,m$conditions$bounds,
     inputs$p$parSize,data,m$conditions$dist,model.matrix(m$conditions$formula,data),
                   m$conditions$estAngleMean,m$conditions$circularAngleMean,
                   m$conditions$zeroInflation,m$conditions$oneInflation,m$conditions$stationary,
                   m$conditions$cons,m$conditions$fullDM,m$conditions$DMind,m$conditions$workcons,
                   m$conditions$Bndind,m$knownStates,unlist(m$conditions$fixPar),
                   m$conditions$wparIndex,covsDelta=m$covsDelta)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab