Fit a polynomial surface determined by one or more numerical predictors, using local fitting.
1 2 3 4 5 6 
formula 
a formula specifying the numeric response and one to four numeric predictors (best specified via an interaction, but can also be specified additively). Will be coerced to a formula if necessary. 
data 
an optional data frame, list or environment (or object
coercible by 
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 given by

model 
should the model frame be returned? 
span 
the parameter α which controls the degree of smoothing. 
enp.target 
an alternative way to specify 
degree 
the degree of the polynomials to be used, normally 1 or 2. (Degree 0 is also allowed, but see the ‘Note’.) 
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

normalize 
should the predictors be normalized to a common scale if there is more than one? The normalization used is to set the 10% trimmed standard deviation to one. Set to false for spatial coordinate predictors and others known to be on a common scale. 
family 
if 
method 
fit the model or just extract the model frame. Can be abbreviated. 
control 
control parameters: see 
... 
control parameters can also be supplied directly
(if 
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 controlled by α (set by span
or
enp.target
). For α < 1, the
neighbourhood includes proportion α of the points,
and these have tricubic weighting (proportional to (1  (dist/maxdist)^3)^3). For
α > 1, all points are used, with the
‘maximum distance’ assumed to be α^(1/p)
times the actual maximum distance for p explanatory variables.
For the default family, fitting is by (weighted) least squares. For
family="symmetric"
a few iterations of an Mestimation
procedure with Tukey's biweight are used. Be aware that as the initial
value is the leastsquares 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.
An object of class "loess"
.
As this is based on cloess
, 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.
degree = 0
, local constant fitting, is allowed in this
implementation but not documented in the reference. It seems very little
tested, so use with caution.
B. D. Ripley, based on the cloess
package of Cleveland,
Grosse and Shyu.
The 1998 version of cloess
package of Cleveland,
Grosse and Shyu. A later version is available as dloess
at
http://www.netlib.org/a.
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.
loess.control
,
predict.loess
.
lowess
, the ancestor of loess
(with
different defaults!).
1 2 3 4 5 6  cars.lo < loess(dist ~ speed, cars)
predict(cars.lo, data.frame(speed = seq(5, 30, 1)), se = TRUE)
# to allow extrapolation
cars.lo2 < loess(dist ~ speed, cars,
control = loess.control(surface = "direct"))
predict(cars.lo2, data.frame(speed = seq(5, 30, 1)), se = TRUE)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.