nlregb(nres, start, residuals, jacobian=NULL, scale=NULL, control=NULL, lower=-Inf, upper=Inf, ...)
x
is the vector of parameters
over which the minimization takes place.
Users can accumulate information through attributes of the value of
residuals
.
If the attributes include any additional arguments of
residuals
or
jacobian
,
the next call to
residuals
or
jacobian
will use the new values
of those arguments.
The order of the residual functions must be preserved
throughout the computation.
x
is the vector of parameters over
which the optimization takes place.
As for
residuals
, users can accumulate
information through attributes of the value of
jacobian
.
It cannot be assumed that the value of
x
on a given call to
jacobian
is the same as
the value of
x
used in the previous call
to
residuals
.
If
jacobian
is not supplied,
the Jacobian matrix is estimated by finite differences.
scale
is initialized automatically
within
nlregb
.
Although
scale
can have a great effect
on the performance of the algorithm, it is not known how to choose it optimally.
Automatic updating of the
scale
vector is the
default,
although other options can be selected
through
control
.
nlregb.control
.
-Inf
and
Inf
. The default is unconstrained minimization :
lower = -Inf, upper = Inf
.
residuals
and/or
jacobian
.
successive parameter values are within a specified tolerance of each other.
nlregb
.
nlregb
is intended for functions that have at least two continuous
derivatives on all of the feasible region, including the boundary.
For best results, the Jacobian matrix of the residuals should be supplied
whenever possible.
Function and derivative values should be computed in C or Fortran within
the outer S-PLUS function for greater efficiency.
nlregb
is based on the Fortran functions
dn2fb
, and
dn2gb
(Dennis et al. (1981), Gay (1984), A T & T (1984)) from NETLIB
(Dongarra and Grosse (1987).
A. T. & T. Bell Laboratories (1984).
PORT Mathematical Subroutine Library Manual.
Dongarra, J. J. and Grosse, E. (1987).
Distribution of mathematical software via electronic mail,
Communications of the ACM,
30
, pp. 403-407.
Dennis, J. E., Gay, D. M., and Welsch, R. E. (1981).
An Adaptive Nonlinear Least-Squares Algorithm
ACM Transactions on Mathematical Software,
7
, pp. 348-368.
Dennis, J. E., Gay, D. M., and Welsch, R. E. (1981).
Algorithm 573. NL2SOL - An Adaptive Nonlinear Least-Squares Algorithm.
ACM Transactions on Mathematical Software,
7
, pp. 369-383.
Gay, D. M. (1984).
A trust region approach to linearly constrained optimization.
in
Numerical Analysis. Proceedings, Dundee 1983,
F. A Lootsma (ed.), Springer, Berlin, pp. 171-189.
# This example uses nlregb to solve a linear least-squares problem n <- 20; p <- 5 A <- matrix(rnorm(n*p), nrow=n, ncol=p) x <- rep(1, p) y <- A%*%x x0 <- rnorm(length(x)) lin.res <- function(x, y, A) {A%*%x-y} nlregb(nres=n, start=x0, res=lin.res, y=y, A=A) # Now try it with bounds with a solution partially outside the bounds x <- c(0, -2, 0, 2, 0) nlregb(nres=n, st=x0, res=lin.res, lo=-1, up=1, y=y, A=A) # Now use the Jacobian matrix lin.jac <- function(x, y, A) {A} nlregb(nres=n, st=x0, res=lin.res, jac=lin.jac, lo=-1, up=1, y=y, A=A) # An example fitting a nonlinear function (a variogram) using # data stored in a data frame. # First simulate the data: d <- runif(40, 0, 10) vg <- 0.3 + 1.2 * (1 - exp(- d / 2)) + rnorm(40, 0, .05) dvg <- data.frame(d=d, vg=vg) # Define the residual function: resid.func <- function(x, data) { data$vg - (x[1] + x[2] * (1.0 - exp(-data$d / x[3]))) } # Call nlregb: fit <- nlregb(nres=nrow(dvg), start=c(.2, 1, 5), residuals=resid.func, lower=rep(0, 3), upper=rep(Inf, 3), data=dvg) fit$parameters