

   loess {modreg}                               R Documentation

   LLooccaall PPoollyynnoommiiaall RReeggrreessssiioonn FFiittttiinngg

   DDeessccrriippttiioonn::

        Fit a polynomial surface determined by one or more
        numerical predictors, using local fitting.

   UUssaaggee::

        loess(formula, data, weights, subset, na.action, model = FALSE,
              span = 0.75, enp.target, degree = 2,
              parametric = FALSE, drop.square = FALSE, normalize = TRUE,
              family = c("gaussian", "symmetric"),
              method = c("loess", "model.frame"),
              control = loess.control(...), ...)

   AArrgguummeennttss::

    formula: a formula specifying the response and one or more
             numeric predictors (best specified via an interac-
             tion, but can also be specified additively).

       data: an optional data frame within which to look first
             for the response, predictors and weights.

    weights: optional weights for each case.

     subset: an optional specification of a subset of the data
             to be used.

   na.action: the action to be taken with missing values in the
             response or predictors.  The default is to stop.

      model: should the model frame be returned?

       span: the parameter alpha which controls the degree of
             smoothing.

   enp.target: an alternative way to specify `span', as the
             approximate equivalent number of parameters to be
             used.

     degree: the degree of the polynomials to be used, up to 2.

   parametric: should any terms be fitted globally rather than
             locally?  Terms can be specified by name, number
             or as a logical vector of the same length as the
             number of predictors.

   drop.square: for fits with more than one predictor and
             `degree=2', should the quadratic term (and cross-
             terms) be dropped for particular predictors?
             Terms are specified in the same way as for `para-
             metric'.

   normalize: should the predictors be normalized to a common
             scale if there is more than one?  The normaliza-
             tion used is to set the 10% trimmed standard devi-
             ation to one.  Set to false for spatial coordinate
             predictors and others know to be a common scale.

     family: if `"gaussian"' fitting is by least-squares, and
             if `"symmetric"' a re-descending M estimator is
             used with Tukey's biweight function.

     method: fit the model or just extract the model frame.

    control: control parameters: see `loess.control'.

        ...: control parameters can also be supplied directly.

   DDeettaaiillss::

        Fitting is done locally.  That is, for the fit at point
        x, the fit is made using points in a neighbourhood of
        x, weighted by their distance from x (with differences
        in `parametric' variables being ignored when computing
        the distance). The size of the neighbourhood is con-
        trolled by alpha (set by `span' or `enp.target').  For
        alpha < 1, the neighbourhood includes proportion alpha
        of the points, and these have tricubic weighting (pro-
        portional to (1 - (dist/maxdist)^3)^3.  For alpha > 1,
        all points are used, with the `maximum distance'
        assumed to be alpha times the actual maximum distance.

        For the default family, fitting is by (weighted) least
        squares. For `family="symmetric"' a few iterations of
        an M-estimation procedure with Tukey's biweight are
        used. Be aware that as the initial value is the least-
        squares fit, this need not be a very resistant fit.

        It can be important to tune the control list to achieve
        acceptable speed. See loess.control for details.

   VVaalluuee::

        An object of class `"loess"'.

   NNoottee::

        As this is based on the `cloess' package available at
        `netlib', it is similar to but not identical to the
        `loess' function of S. In particular, conditioning is
        not implemented.

        The memory usage of this implementation of `loess' is
        roughly quadratic in the number of points, with 1000
        points taking about 10Mb.

   AAuutthhoorr((ss))::

        B.D. Ripley, based on the `cloess' package of Cleve-
        land, Grosse and Shyu.

   RReeffeerreenncceess::

        W.S. Cleveland, E. Grosse and W.M. Shyu (1992) Local
        regression models. Chapter 8 of Statistical Models in S
        eds J.M. Chambers and T.J. Hastie, Wadsworth &
        Brooks/Cole.

   SSeeee AAllssoo::

        `loess.control', `predict.loess'

   EExxaammpplleess::

        data(cars)
        cars.lo <- loess(dist ~ speed, cars)
        predict(cars.lo, data.frame(speed=seq(5, 30, 1)), se=TRUE)
        # to get extrapolation
        cars.lo2 <- loess(dist ~ speed, cars,
          control=loess.control(surface="direct"))
        predict(cars.lo2, data.frame(speed=seq(5, 30, 1)), se=TRUE)

