predict.nls              package:stats              R Documentation

_P_r_e_d_i_c_t_i_n_g _f_r_o_m _N_o_n_l_i_n_e_a_r _L_e_a_s_t _S_q_u_a_r_e_s _F_i_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     'predict.nls' produces predicted values, obtained by evaluating
     the regression function in the frame 'newdata'.  If the logical
     'se.fit' is 'TRUE', standard errors of the predictions are
     calculated.  If the numeric argument 'scale' is set (with optional
     'df'), it is used as the residual standard deviation in the
     computation of the standard errors, otherwise this is extracted
     from the model fit.  Setting 'intervals' specifies computation of
     confidence or prediction (tolerance) intervals at the specified
     'level'.

     At present 'se.fit' and 'interval' are ignored.

_U_s_a_g_e:

     ## S3 method for class 'nls':
     predict(object, newdata , se.fit = FALSE, scale = NULL, df = Inf, 
             interval = c("none", "confidence", "prediction"),
             level = 0.95, ...)

_A_r_g_u_m_e_n_t_s:

  object: An object that inherits from class 'nls'.

 newdata: A named list or data frame in which to look for variables
          with which to predict.  If 'newdata' is missing the fitted
          values at the original data points are returned.

  se.fit: A logical value indicating if the standard errors of the
          predictions should be calculated.  Defaults to 'FALSE'.  At
          present this argument is ignored.

   scale: A numeric scalar.  If it is set (with optional 'df'), it is
          used as the residual standard deviation in the computation of
          the standard errors, otherwise this information is extracted
          from the model fit. At present this argument is ignored.

      df: A positive numeric scalar giving the number of degrees of
          freedom for the 'scale' estimate. At present this argument is
          ignored.

interval: A character string indicating if prediction intervals or a
          confidence interval on the mean responses are to be
          calculated. At present this argument is ignored.

   level: A numeric scalar between 0 and 1 giving the confidence level
          for the intervals (if any) to be calculated.  At present this
          argument is ignored.

     ...: Additional optional arguments.  At present no optional
          arguments are used.

_V_a_l_u_e:

     'predict.nls' produces a vector of predictions. When implemented,
     'interval' will produce a matrix of predictions and bounds with
     column names 'fit', 'lwr', and 'upr'.  When implemented, if
     'se.fit' is 'TRUE', a list with the following components will be
     returned:

     fit: vector or matrix as above

  se.fit: standard error of predictions

residual.scale: residual standard deviations

      df: degrees of freedom for residual

_N_o_t_e:

     Variables are first looked for in 'newdata' and then searched for
     in the usual way (which will include the environment of the
     formula used in the fit).  As from R 2.0.0 a warning will be given
     if the variables found are not of the same length as those in
     'newdata' if it was supplied.

_S_e_e _A_l_s_o:

     The model fitting function 'nls', 'predict'.

_E_x_a_m_p_l_e_s:

     fm <- nls(demand ~ SSasympOrig(Time, A, lrc), data = BOD)
     predict(fm)              # fitted values at observed times
     ## Form data plot and smooth line for the predictions
     opar <- par(las = 1)
     plot(demand ~ Time, data = BOD, col = 4,
          main = "BOD data and fitted first-order curve",
          xlim = c(0,7), ylim = c(0, 20) )
     tt <- seq(0, 8, length = 101)
     lines(tt, predict(fm, list(Time = tt)))
     par(opar)

