minimizeme | R Documentation |
minimizeme
is mainly used by an optimizer (e.g. optim
)
to estimate parameters.
minimizeme(theta, data, names, fixed.names = c(), fixed.vals = c(),
isSurvey = FALSE)
minimizemeMultidata(theta, surdata, comdata, names, fixed.names = c(),
fixed.vals = c())
theta |
Numeric vector of *transformed* parameter values |
data |
Numeric vector, or |
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. |
Numeric scalar. The negative log likelihood for the given parameters and observations.
If data is a list containing both sample and df, the data.frame
df will be used.
alko
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.