Usage
maxNR(fn, grad = NULL, hess = NULL, start, print.level = 0,
tol = 1e-08, reltol=sqrt(.Machine$double.eps), gradtol = 1e-06,
steptol = 1e-10, lambdatol = 1e-06, qrtol = 1e-10,
iterlim = 150,
constPar = NULL, activePar=rep(TRUE, nParam), ...)
Arguments
fn
function to be maximized. It must return either a single
number or a numeric vector, which is summed (this is useful for BHHH
method). If the parameters are out of range, fn
should
return NA
. See details for consta
grad
gradient of the function. If NULL
, numeric
gradient is used. It must return a gradient vector, or matrix where
columns correspond to individual parameters. The column sums
are treated as gradient components (this is us
hess
Hessian matrix of the function. If missing, numeric
Hessian, based on gradient, is used.
start
initial value for the parameter vector
print.level
this argument determines the level of
printing which is done during the minimization process. The default
value of 0 means that no printing occurs, a value of 1 means that
initial and final details are printed and a value of 2 means that
f
tol
stopping condition. Stop if the absolute difference
between successive iterations less than tol
, return
code=2
.
reltol
Relative convergence tolerance. The algorithm stops if
it is unable to increase the value by a factor of 'reltol *
(abs(val) + reltol)' at a step. Defaults to
'sqrt(.Machine$double.eps)', typically about '1e-8'.
gradtol
stopping condition. Stop if the norm of the gradient
less than gradtol
, return code=1
.
steptol
stopping/error condition. If the quadratic
approximation leads to lower function value instead of higher, or
NA
, the step length
is halved and a new attempt is made. This procedure is repeated
until step < steptol
lambdatol
control whether the Hessian is treated as negative
definite. If the
largest of the eigenvalues of the Hessian is larger than
-lambdatol
, a suitable diagonal matrix is subtracted from the
Hessian (quadratic hill-climbing) in o
qrtol
QR-decomposition tolerance
iterlim
stopping condition. Stop if more than iterlim
iterations, return code=4
.
constPar
index vector. Which of the parameters must be treated
as constants.
activePar
logical vector, which parameters are treated as free
(resp constant)
...
further arguments to fn
, grad
and
hess
.