The `lowess`

function performs the computations for the
*LOWESS* smoother (see the reference below).
`lowess`

returns a an object containing components
`x`

and `y`

which give the coordinates of the smooth.
The smooth can then be added to a plot of the original
points with the function `lines`

.

Alternatively, `plot`

can be called directly on the object
returned from `lowess`

and the 'lowess' method for `plot`

will generate a scatterplot of the original data with a `lowess`

line superimposed.

Finally, the `plotLowess`

function both calculates the
`lowess`

smooth and plots the original data with a `lowess`

smooth.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
lowess(x, ...)
## Default S3 method:
lowess(x, y=NULL, f=2/3, iter=3L, delta=0.01 *
diff(range(x)), ...)
## S3 method for class 'formula'
lowess(formula,data=parent.frame(), ..., subset, f=2/3,
iter=3L, delta=.01*diff(range(mf[-response])))
## S3 method for class 'lowess'
plot(x, y, ..., col.lowess="red", lty.lowess=2)
plotLowess(formula, data=parent.frame(), ..., subset=parent.frame(),
col.lowess="red", lty.lowess=2 )
``` |

`formula` |
formula providing a single dependent variable (y) and an single independent variable (x) to use as coordinates in the scatter plot. |

`data` |
a data.frame (or list) from which the variables in ‘formula’ should be taken. |

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

`x, y` |
vectors giving the coordinates of the points in the scatter plot. Alternatively a single plotting structure can be specified. |

`f` |
the smoother span. This gives the proportion of points in the plot which influence the smooth at each value. Larger values give more smoothness. |

`iter` |
the number of robustifying iterations which should be
performed.
Using smaller values of |

`delta` |
values of |

`...` |
parameters for methods. |

`col.lowess, lty.lowess` |
color and line type for plotted line |

Cleveland, W. S. (1979)
Robust locally weighted regression and smoothing scatterplots.
*J. Amer. Statist. Assoc.* **74**, 829–836.

Cleveland, W. S. (1981)
LOWESS: A program for smoothing scatterplots by robust locally weighted
regression. *The American Statistician*, **35**, 54.

`loess`

(in package `modreg`

), a newer
formula based version of `lowess`

(with different defaults!).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ```
data(cars)
#
# x,y method
#
plot(cars$speed, cars$dist, main="lowess(cars)")
lines(lowess(cars$speed, cars$dist), col=2)
lines(lowess(cars$speed, cars$dist, f=.2), col=3)
legend(5, 120, c(paste("f=", c("2/3", ".2"))), lty=1, col=2:3)
#
# formula method: plot, then calculate the lowess smoother,
# then add smooth to the plot
#
plot(dist ~ speed, data=cars, main="lowess(cars)")
lines(lowess(dist ~ speed, data=cars), col=2, lty=2)
lines(lowess(dist ~ speed, data=cars, f=.2), col=3) # smaller bandwith
legend(5, 120, c(paste("f=", c("2/3", ".2"))), lty=1, col=2:3)
#
# formula method: calculate lowess() smoother, then call plot()
# on the lowess object
#
lw <- lowess(dist ~ speed, data=cars)
plot(lw, main="lowess(cars)" )
#
# formula method: calculate and plot in a single command
#
plotLowess(dist ~ speed, data=cars, main="lowess(cars)")
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.