minimizeme: The negative log likelihood for given parameters and data

View source: R/estimation.R

minimizemeR Documentation

The negative log likelihood for given parameters and data

Description

minimizeme is mainly used by an optimizer (e.g. optim) to estimate parameters.

Usage

minimizeme(theta, data, names, fixed.names = c(), fixed.vals = c(),
  isSurvey = FALSE)

minimizemeMultidata(theta, surdata, comdata, names, fixed.names = c(),
  fixed.vals = c())

Arguments

theta

Numeric vector of *transformed* parameter values

data

Numeric vector, or data.frame with columns named Weight and Freq. The observed values, fished individuals in grams

names

String vector. Contains the names of the parameter vector theta.

fixed.names

String vector. Names of constants.

fixed.vals

Numeric vector. Transformed values of constants.

isSurvey

Logical. If TRUE the observations are assumed to be from a survey.

surdata

Same as data. Survey data.

comdata

Same as data. Commercial data.

Value

Numeric scalar. The negative log likelihood for the given parameters and observations.

Note

If data is a list containing both sample and df, the data.frame df will be used.

Author(s)

alko

Examples

 
## Not run: 
## Simulate some data with default parameter values and fishing mortality Fm = 0.3
sim <- simulateData3(params = parameters("Fm", 0.3, transformed=FALSE))

## Plotting the negative log likelihood for different values of Fm
Fm <- seq(0.1, 1, 0.05) 
Fm.transformed <- log(Fm / 0.25)
nll <- sapply(Fm.transformed, function(x) minimizeme(theta = x, data = sim$sample, names = "Fm"))
plot(Fm, nll, type="l") 

## Using optimise to estimate one parameter
est <- optimise(f = minimizeme, interval=c(0.01, 1), data=sim$sample, names="Fm")
est.Fm <- exp(est$minimum) * 0.25
abline(v=est.Fm)
mtext(paste("Estimated Fm = ", round(est.Fm, 2)), at=est.Fm)

## End(Not run)


alko989/s6model documentation built on Nov. 2, 2023, 10:04 p.m.