multinomLL: multinomLL is the negative log-likelihood for multinomial...

View source: R/datalow_utils.r

multinomLLR Documentation

multinomLL is the negative log-likelihood for multinomial values

Description

multinomLL calculates the negative log-likelihood for the multinomial distribution. Commonly used with length and age composition data in assessment models. Zero observations in particular categories do not matter as the equation is - Sum(Obs x log(expected-proportion)). Thus zeros in the observations just contribute zero to the sum.

Usage

multinomLL(counts, predprop)

Arguments

counts

the observed counts in each category (age or length) that is to be fitted by the model

predprop

the predicted proportions in each category. One needs a separate function to calculate this.

Value

a single scalar value, the -veLL

Examples

## Not run: 
  obs <- c(0,5,11,19,12,3,0,0)
  expprop <- c(0.018,0.002,0.12,0.4,0.3,0.12,0.03,0.01)
  multinomLL(obs,expprop)  # should be 92.61393

## End(Not run)

haddonm/datalowSA documentation built on Nov. 5, 2023, 6:40 p.m.