Learn R Programming

multiSA (version 0.1.0)

like_comp: Likelihood for composition vectors

Description

Returns the log-likelihood for composition data, e.g., length, age, or stock composition, with various statistical distributions supported.

Usage

like_comp(
  obs,
  pred,
  type = c("multinomial", "dirmult1", "dirmult2", "lognormal"),
  N = sum(obs),
  theta,
  stdev
)

Value

Numeric representing the log-likelihood.

Arguments

obs

A vector of observed values. Internally converted to proportions.

pred

A vector of predicted values. Same length as obs. Internally converted to proportions.

type

Character for the desired distribution

N

Numeric, the sample size corresponding to obs for multinomial or Dirichlet multinomial distributions.

theta

Numeric, the linear (type = "dirmult1") or saturating (type = "dirmult2") Dirichlet-multinomial parameter, respectively. See Thorson et al. (2017)

stdev

Numeric or vectorized for obs, the likelihood standard deviation for lognormal distribution.

Details

Observed and predicted vectors are internally converted to proportions.

For type = "lognormal", zero observations are removed from the likelihood calculation.

References

Thorson et al. 2017. Model-based estimates of effective sample size in stock assessment models using the Dirichlet-multinomial distribution. Fish. Res. 192:84-93. tools:::Rd_expr_doi("10.1016/j.fishres.2016.06.005")

Examples

Run this code
M <- 0.1
age <- seq(1:10)
pred <- exp(-M * age)
obs <- pred * rlnorm(10, sd = 0.05)
like_comp(obs, pred, N = 10, type = "multinomial")
like_comp(obs, pred, N = 100, type = "multinomial")
like_comp(obs, pred, N = 10, type = "dirmult1", theta = 1)
like_comp(obs, pred, N = 10, type = "dirmult1", theta = 20)

Run the code above in your browser using DataLab