calcLike: Calculate maximum likelihood estimate and 95\ interval

View source: R/likelihood.R

calcLikeR Documentation

Calculate maximum likelihood estimate and 95\ interval

Description

Calculate maximum likelihood estimate of a parameter and its 95\ interval using the profile log-likelihood method, for a given negative log-likelihood function and its arguments (other parameters and data). Will likely give warnings that can safely be ignored (see suppress.warnings description below).

Usage

calcLike(
  negLL.fn,
  p,
  vecDiff = 0.5,
  vecInc = 0.001,
  suppress.warnings = FALSE,
  ...
)

Arguments

negLL.fn

negative log-likelihood function that take arguments (parameters and data) in ... and returns a negative log-likelihood value.

p

starting point to calculate the maximum likelihood estimate

vecDiff

the range over which to test the negative log-likelihood to construct the confidence interval. Default is 0.5 and a symmetric range is tested for fitting size spectra, since for movement data sets in Table 2 of Edwards (2011; 92(6):1247-1257) the intervals were symmetric, so symmetric seems a good start.

vecInc

increments to try, the accuracy of the resulting bounds will depend on this. Note that a resulting interval of, say, (-2.123, -1.987) means that that interval is contained within the true 95\ The true bounds lie between the stated lower bounds and between the stated upper bounds. So reduce vecInc if further accuracy is needed.

suppress.warnings

If TRUE then suppress warnings from the nlm() calculations; for the MEPS_IBTS_MLEbins vignette these occur a lot, and are always: ⁠Warning in nlm(f = negLL.fn, p = p, ...) : NA/Inf replaced by maximum positive value⁠. The same warning often happens in other situations also. It is due to the likelihood function blowing up, presumably when searching some very very very unlikely region of paramater space.

...

further arguments (including parameters and data) to negLL.fn()

Value

  list containing:
  • MLE: the maximum likelihood estimate

  • conf: the 95\

Author(s)

Andrew Edwards


andrew-edwards/sizeSpectra documentation built on June 28, 2023, 7:09 p.m.