- fn
the function to be maximized.
It must have the parameter vector as the first argument and
it must return either a single number, or a numeric vector (this is
is summed internally).
If the BHHH method is used and argument gradient
is not given,
fn
must return a numeric vector of observation-specific
log-likelihood values.
If the parameters are out of range, fn
should
return NA
. See details for constant parameters.
fn
may also return attributes "gradient" and/or "hessian".
If these attributes are set, the algorithm uses the corresponding
values as
gradient and Hessian.
- grad
gradient of the objective function.
It must have the parameter vector as the first argument and
it must return either a gradient vector of the objective function,
or a matrix, where columns correspond to individual parameters.
The column sums are treated as gradient components.
If NULL
, finite-difference gradients are computed.
If BHHH method is used, grad
must return a matrix,
where rows corresponds to the gradient vectors for individual
observations and the columns to the individual parameters.
If fn
returns an object with attribute gradient
,
this argument is ignored.
- hess
Hessian matrix of the function.
It must have the parameter vector as the first argument and
it must return the Hessian matrix of the objective function.
If missing, finite-difference Hessian, based on gradient
,
is computed.
Hessian is used by the Newton-Raphson method only, and eventually by
the other methods if finalHessian
is requested.
- start
initial parameter values. If start values
are named, those names are also carried over to the results.
- constraints
either NULL
for unconstrained optimization
or a list with two components. The components may be either
eqA
and eqB
for equality-constrained optimization
\(A \theta + B = 0\); or ineqA
and
ineqB
for inequality constraints \(A \theta + B > 0\). More
than one
row in ineqA
and ineqB
corresponds to more than
one linear constraint, in that case all these must be zero
(equality) or positive (inequality constraints).
The equality-constrained problem is forwarded
to sumt
, the inequality-constrained case to
constrOptim2
.
- finalHessian
how (and if) to calculate the final Hessian. Either
FALSE
(do not calculate), TRUE
(use analytic/finite-difference
Hessian) or "bhhh"
/"BHHH"
for the information equality
approach. The latter approach is only suitable for maximizing
log-likelihood functions. It requires the gradient/log-likelihood to
be supplied by individual observations.
Note that computing the (actual, not BHHH) final Hessian
does not carry any extra penalty for the NR method,
but does for the other methods.
- bhhhHessian
logical. Indicating whether to use the information
equality approximation (Bernd, Hall, Hall, and Hausman, 1974) for
the Hessian. This effectively transforms maxNR
into
maxBHHH
and is mainly designed for internal use.
- fixed
parameters to be treated as constants at their
start
values. If present, it is treated as an index vector of
start
parameters.
- activePar
this argument is retained for backward compatibility only;
please use argument fixed
instead.
- control
list of control parameters. The control parameters
used by these optimizers are
- tol
\(10^{-8}\),
stopping condition. Stop if the absolute difference
between successive iterations is less than tol
. Return
code=2
.
If set to a negative value, the criterion is never fulfilled,
and hence disabled.
- reltol
sqrt(.Machine$double.eps), stopping
condition. Relative convergence
tolerance: the algorithm stops if the relative improvement
between iterations is less than ‘reltol’. Return code
8. Negative value disables condition.
- gradtol
stopping condition. Stop if norm of the gradient is
less than gradtol
. Return code 1. Negative value
disables condition.
- steptol
1e-10, stopping/error condition.
If qac == "stephalving"
and the quadratic
approximation leads to a worse, instead of a better value, or to
NA
, the step length
is halved and a new attempt is made. If necessary, this procedure is repeated
until step < steptol
, thereafter code 3 is returned.
- lambdatol
\(10^{-6}\),
controls whether Hessian is treated as negative
definite. If the
largest of the eigenvalues of the Hessian is larger than
-lambdatol
(Hessian is not negative definite),
a suitable diagonal matrix is subtracted from the
Hessian (quadratic hill-climbing) in order to enforce negative
definiteness.
- qrtol
\(10^{-10}\),
QR-decomposition tolerance for the Hessian inversion.
- qac
"stephalving", Quadratic Approximation Correction. When the new
guess is worse than the initial one, the algorithm attemts to correct it:
"stephalving" decreases the
step but keeps the direction,
"marquardt" uses
Marquardt (1963) method by decreasing the step length while also
moving closer to the pure gradient direction. It may be faster and
more robust choice in areas where quadratic approximation
behaves poorly. maxNR
and maxBHHH
only.
- marquardt_lambda0
\(10^{-2}\),
positive numeric, initial correction term for Marquardt (1963)
correction.
- marquardt_lambdaStep
2, how much the Marquardt
(1963)
correction term is
decreased/increased at each
successful/unsuccesful step.
maxNR
and maxBHHH
only.
- marquardt_maxLambda
\(10^{12}\),
maximum allowed Marquardt (1963) correction term. If exceeded, the
algorithm exits with return code 3.
maxNR
and maxBHHH
only.
- iterlim
stopping condition. Stop if more than iterlim
iterations, return code=4
.
- printLevel
this argument determines the level of
printing which is done during the optimization process. The default
value 0 means that no printing occurs, 1 prints the
initial and final details, 2 prints all the
main tracing information for every iteration. Higher
values will result in even more output.