\Header{nlsModel}{Create an nlsModel Object}
\methalias{nlsModel.plinear}{nlsModel}
\keyword{nonlinear}{nlsModel}
\keyword{models}{nlsModel}
\begin{Description}\relax
This is the constructor for \code{nlsModel} objects, which are
function closures for several functions in a list.  The closure
includes a nonlinear model formula, data values for the formula, as
well as parameters and their values.\end{Description}
\begin{Usage}
\begin{verbatim}
nlsModel(form, data, start)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{form}] a nonlinear model formula
\item[\code{data}] a data frame or a list in which to evaluate the variables
from the model formula
\item[\code{start}] a named list or named numeric vector of starting
estimates for the parameters in the model
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
An \code{nlsModel} object is primarily used within the \code{nls}
function.  It encapsulates the model, the data, and the parameters in
an environment and provides several methods to access characteristics
of the model.  It forms an important component of the object returned
by the \code{nls} function.\end{Details}
\begin{Value}
The value is a list of functions that share a common environment.
\begin{ldescription}
\item[\code{resid}] returns the residual vector evaluated at the current
parameter values
\item[\code{fitted}] returns the fitted responses and their gradient at the
current parameter values
\item[\code{formula}] returns the model formula
\item[\code{deviance}] returns the residual sum-of-squares at the current
parameter values
\item[\code{gradient}] returns the gradient of the model function at the
current parameter values
\item[\code{conv}] returns the relative-offset convergence criterion
evaluated at the current parmeter values
\item[\code{incr}] returns the parameter increment calculated according to
the Gauss-Newton formula
\item[\code{setPars}] a function with one argument, \code{pars}.  It sets the
parameter values for the \code{nlsModel} object and returns a
logical value denoting a singular gradient array.
\item[\code{getPars}] returns the current value of the model parameters as a
numeric vector
\item[\code{getAllPars}] returns the current value of the model parameters as a
numeric vector
\item[\code{getEnv}] returns the environment shared by these functions
\item[\code{trace}] the function that is called at each iteration if
tracing is enabled
\item[\code{Rmat}] the upper triangular factor of the gradient array at the
current parameter values
\item[\code{predict}] takes as argument \code{newdata},a \code{data.frame} and
returns the predicted response for \code{newdata}.
\end{ldescription}
\end{Value}
\begin{Author}\relax
Douglas M. Bates and Saikat DebRoy\end{Author}
\begin{References}\relax
Bates, D.M. and Watts, D.G. (1988), \emph{Nonlinear Regression Analysis
and Its Applications}, Wiley\end{References}
\begin{SeeAlso}\relax
\code{\Link{nls}}\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
library( nls )
data( DNase )
DNase1 <- DNase[ DNase$Run == 1, ]
mod <-
 nlsModel(density ~ SSlogis( log(conc), Asym, xmid, scal ),
          DNase1, list( Asym = 3, xmid = 0, scal = 1 ))
mod$getPars()     # returns the parameters as a list
mod$deviance()    # returns the residual sum-of-squares
mod$resid()       # returns the residual vector and the gradient
mod$incr()        # returns the suggested increment
mod$setPars( unlist(mod$getPars()) + mod$incr() )  # set new parameter values
mod$getPars()     # check the parameters have changed
mod$deviance()    # see if the parameter increment was successful
mod$trace()       # check the tracing
mod$Rmat()        # R matrix from the QR decomposition of the gradient
\end{ExampleCode}
\end{Examples}

