negLL | R Documentation |
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
negLL(
inp,
indat,
callfun,
init = inp,
pickparam = c(1:length(inp)),
schaefer = TRUE
)
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). |
the sum of the negative log-likelihoods using a normal PDF appled to the log transformed CPUE.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.