

nlr(gnlm)                                    R Documentation

_N_o_n_l_i_n_e_a_r _R_e_g_r_e_s_s_i_o_n

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

     `nlr' fits a user-specified nonlinear regression equa-
     tion by least squares (normal) or its generalization
     for the gamma and inverse Gauss distributions.

_U_s_a_g_e_:

     nlr(y, mu=NULL, pmu=NULL, distribution="normal", wt=1, delta=1,
             envir=sys.frame(sys.parent()), print.level=0, typsiz=abs(pmu),
             ndigit=10, gradtol=0.00001, stepmax=10*sqrt(pmu%*%pmu),
             steptol=0.00001, iterlim=100, fscale=1)

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

       y: The response vector.

      mu: A function of `p' giving the regression equation
          for the mean or a formula beginning with ~, speci-
          fying either a linear regression function in the
          Wilkinson and Rogers notation or a general nonlin-
          ear function with named unknown parameters.

     pmu: Vector of initial estimates of the parameters.  If
          `mu' is a formula with unknown parameters, their
          estimates must be supplied either in their order
          of appearance in the expression or in a named
          list.

distribution: The distribution to be used: normal, gamma, or
          inverse Gauss.

      wt: Weight vector.

   delta: Scalar or vector giving the unit of measurement
          for each response value, set to unity by default.
          For example, if a response is measured to two dec-
          imals, delta=0.01. If the response is transformed,
          this must be multiplied by the Jacobian. For exam-
          ple, with a log transformation, `delta=1/y'.

   envir: Environment in which model formulae are to be
          interpreted or a data object of class, repeated,
          tccov, or tvcov.  If `y' has class `repeated', it
          is used as the environment.

  others: Arguments controlling `nlm'.

_V_a_l_u_e_:

     A list of class nlr is returned.  The printed output
     includes the -log likelihood (not the deviance), the
     corresponding AIC, the parameter estimates, standard
     errors, and correlations. A list is returned that con-
     tains all of the relevant information calculated,
     including error codes.

     A nonlinear regression model can be supplied as a for-
     mula where parameters are unknowns. Factor variables
     cannot be used and parameters must be scalars. (See
     `finterp'.)

_A_u_t_h_o_r_(_s_)_:

     J.K. Lindsey

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

     `finterp', `fmr', `glm', `glmm', `gnlmm', `gnlr',
     `gnlr3', `lm'.

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

     x <- c(3,5,0,0,0,3,2,2,2,7,4,0,0,2,2,2,0,1,3,4)
     y <- c(-26,-191,2,1,10,-25,9,0,-8,-598,-80,3,-4,-7,-10,-22,-5,-8,-52,-84)
     # 2*x^2-2*x^3+rnorm(20,0,10)
     # linear regression
     mu1 <- function(p) p[1]+p[2]*x
     summary(lm(y~x))
     nlr(y, mu=mu1, pmu=c(3,2))
     # or
     nlr(y, mu=~x, pmu=c(3,2))
     # or
     nlr(y, mu=~b0+b1*x, pmu=c(3,2))
     # nonlinear regression
     mu2 <- function(p) p[1]*x^p[2]+p[3]*x^p[4]
     nlr(y, mu=mu2, pmu=c(1,1,-1,2))
     # or
     nlr(y, mu=~b0*x^b1+c0*x^c1, pmu=list(b0=1,b1=1,c0=-1,c1=2))
     # with gamma distribution
     y <- rgamma(20,2,0.2+2*exp(0.1*x))
     nlr(y, dist="gamma", mu=~b0+c0*exp(c1*x),
             pmu=list(b0=0.2,c0=3,c1=0.2))

