nls                   package:nls                   R Documentation

_N_o_n_l_i_n_e_a_r _L_e_a_s_t _S_q_u_a_r_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Determine the nonlinear least squares estimates of the nonlinear
     model parameters and return a class `nls' object.

_U_s_a_g_e:

     nls(formula, data, start, control = nls.control(),
         algorithm = "default", trace = FALSE, subset,
         weights, na.action)

_A_r_g_u_m_e_n_t_s:

 formula: a nonlinear model formula including variables and parameters

    data: an optional data frame in which to evaluate the variables in
          `formula'

   start: a named list or named numeric vector of starting estimates

 control: an optional list of control settings.  See `nls.control' for
          the names of the settable control values and their effect.

algorithm: character string specifying the algorithm to use. The
          default algorithm is a Gauss-Newton algorithm. The other 
          alternative is "plinear", the Golub-Pereyra algorithm for
          partially linear least-squares models.

   trace: logical value indicating if a trace of the iteration progress
          should be printed.  Default is `FALSE'.  If `TRUE' the
          residual sum-of-squares and the parameter values are printed
          at the conclusion of each iteration.  When the `"plinear"'
          algorithm is used, the conditional estimates of the linear
          parameters are printed after the nonlinear parameters.

  subset: an optional vector specifying a subset of observations to be
          used in the fitting process.

 weights: an optional numeric vector of (fixed) weights.  When present,
          the objective function is weighted least squares. not yet
          implemented

na.action: a function which indicates what should happen when the data
          contain `NA's.

_D_e_t_a_i_l_s:

     An `nls' object is a type of fitted model object.  It has methods
     for the generic functions `coef', `formula', `resid', `print',
     `summary', `AIC', and `fitted'.

_V_a_l_u_e:

     A list of 

       m: an `nlsModel' object incorporating the model

    data: the expression that was passed to `nls' as the data argument.
           The actual data values are present in the environment of the
          `m' component.

_A_u_t_h_o_r(_s):

     Douglas M. Bates and Saikat DebRoy

_R_e_f_e_r_e_n_c_e_s:

     Bates, D.M. and Watts, D.G. (1988) Nonlinear Regression Analysis
     and Its Applications, Wiley

_S_e_e _A_l_s_o:

     `nlsModel'

_E_x_a_m_p_l_e_s:

     data( DNase )
     DNase1 <- DNase[ DNase$Run == 1, ]
     ## using a selfStart model
     fm1DNase1 <- nls( density ~ SSlogis( log(conc), Asym, xmid, scal ), DNase1 )
     summary( fm1DNase1 )
     ## using conditional linearity
     fm2DNase1 <- nls( density ~ 1/(1 + exp(( xmid - log(conc) )/scal ) ),
                       data = DNase1,
                       start = list( xmid = 0, scal = 1 ),
                       alg = "plinear", trace = TRUE )
     summary( fm2DNase1 )
     ## without conditional linearity
     fm3DNase1 <- nls( density ~ Asym/(1 + exp(( xmid - log(conc) )/scal ) ),
                       data = DNase1,
                       start = list( Asym = 3, xmid = 0, scal = 1 ),
                       trace = TRUE )
     summary( fm3DNase1 )
     ## weighted nonlinear regression
     data(Puromycin)
     Treated <- Puromycin[Puromycin$state == "treated", ]
     weighted.MM <- function(resp, conc, Vm, K)
     {
         ## Purpose: exactly as white book p.451 -- RHS for nls()
         ##  Weighted version of Michaelis-Menten model
         ## -------------------------------------------------------------------------
         ## Arguments: `y', `x' and the two parameters (see book)
         ## -------------------------------------------------------------------------
         ## Author: Martin Maechler, Date: 23 Mar 2001, 18:48

         pred <- (Vm * conc)/(K + conc)
         (resp - pred) / sqrt(pred)
     }

     Pur.wt <- nls( ~ weighted.MM(rate, conc, Vm, K), data = Treated,
                   start = list(Vm = 200, K = 0.1),
                   trace = TRUE)

