negLL: negLL -ve log-likelihood for normally distributed variables

View source: R/spm.r

negLLR Documentation

negLL -ve log-likelihood for normally distributed variables

Description

A generalized functions for calculating the negative log-likelihood for normally distributed variables. It uses an input function 'funk' that will calculate predicted values of a dependent variable from a vector of independent values

Usage

negLL(
  inp,
  indat,
  callfun,
  init = inp,
  pickparam = c(1:length(inp)),
  schaefer = TRUE
)

Arguments

inp

a vector containing the parameters being used in funk, plus an extra sigma which is the standard deviation of the normal random likelihoods in dnorm

indat

the data set containing the 'year', 'catch', and 'cpue'

callfun

the function that calculates the predicted values from the input data

init

this defaults to the same as pars - using all parameters

pickparam

a vector identifying the parameters to be fitted; defaults to all parameters. If some need to be kept constant omit their index from pickparam.

schaefer

a boolean that determines whether a Schaefer model (p=1) is used or if FALSE the Fox model (p=1e-08).

Value

the sum of the negative log-likelihoods using a normal PDF appled to the log transformed CPUE.

Examples

## Not run: 
data(dataspm)
fish <- dataspm$fish
fish
colnames(fish) <- tolower(colnames(fish)) 
pars <- c(r=0.2,K=6000,Binit=2800)
negLL(pars,fish,simpspm,schaefer=FALSE)  # should be -0.8884016
negLL(pars,fish,simpspm)  # should be -11.12203

## End(Not run)

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