Allow the user to set some characteristics
Levenberg-Marquardt nonlinear least squares algorithm implemented
in `nls.lm`

.

```
nls.lm.control(ftol = sqrt(.Machine$double.eps),
ptol = sqrt(.Machine$double.eps), gtol = 0, diag = list(), epsfcn = 0,
factor = 100, maxfev = integer(), maxiter = 50, nprint = 0)
```

ftol

non-negative numeric. Termination occurs when
both the actual and predicted relative reductions in the sum of
squares are at most `ftol`

. Therefore, `ftol`

measures
the relative error desired in the sum of squares.

ptol

non-negative numeric. Termination occurs when
the relative error between two consecutive iterates is at most
`ptol`

. Therefore, `ptol`

measures the relative error
desired in the approximate solution.

gtol

non-negative numeric. Termination occurs when
the cosine of the angle between result of `fn`

evaluation
\(fvec\) and any column of the Jacobian is at most `gtol`

in absolute value. Therefore, `gtol`

measures the
orthogonality desired between the function vector and the
columns of the Jacobian.

diag

a list or numeric vector containing positive
entries that serve as multiplicative scale factors for the
parameters. Length of `diag`

should be equal to that of
`par`

. If not, user-provided `diag`

is ignored and
`diag`

is internally set.

epsfcn

(used if `jac`

is not provided) is a
numeric used in determining a suitable step for the
forward-difference approximation. This approximation assumes
that the relative errors in the functions are of the order of
`epsfcn`

. If `epsfcn`

is less than the machine
precision, it is assumed that the relative errors in the
functions are of the order of the machine precision.

factor

positive numeric, used in determining the
initial step bound. This bound is set to the product of
`factor`

and the \(|\code{diag}*\code{par}|\) if nonzero,
or else to `factor`

itself. In most cases `factor`

should lie in the interval (0.1,100). 100 is a generally
recommended value.

maxfev

integer; termination occurs
when the number of calls to `fn`

has reached `maxfev`

.
Note that `nls.lm`

sets the value of `maxfev`

to
`100*(length(par) + 1)`

if
`maxfev = integer()`

, where `par`

is the list or
vector of parameters to be optimized.

maxiter

positive integer. Termination occurs
when the number of iterations reaches `maxiter`

.

nprint

is an integer; set `nprint`

to be positive
to enable printing of iterates

A `list`

with exactly nine components:

J.J. Mor<U+00E9>, "The Levenberg-Marquardt algorithm: implementation and
theory," in *Lecture Notes in Mathematics*
**630**: Numerical Analysis, G.A. Watson (Ed.),
Springer-Verlag: Berlin, 1978, pp. 105-116.

```
# NOT RUN {
nls.lm.control(maxiter = 4)
# }
```

Run the code above in your browser using DataCamp Workspace