lowess
Scatter Plot Smoothing

Description

Gives a robust, local smooth of scatter plot data. Among other options is the fraction of data smoothed at each point.

Usage


lowess(x, y = NULL, f = 2/3, iter = 3, delta = 0.01 * diff(range(xy$x[o]))) 

Arguments

x,y vectors of data for scatter plot. y can be NULL, then x can be a univariate time series, a matrix or data.frame with two columns or a list with two components named x and y..
f fraction of the data used for smoothing at each x point. The larger the f value, the smoother the fit.
iter number of iterations used in computing robust estimates.
delta interval size (in units corresponding to x). If lowess estimates at two x values within delta of one another, it fits any points between them by linear interpolation. The default is 1% of the lagged differences of range of x coordinates (the first column of x if it is a data structure). If delta=0 all but identical x values are estimated independently.

Details

This is a scatter plot smoother - it does not make any assumptions about the x values being evenly spaced. Lowess uses robust locally linear fits. A window, dependent on f, is placed about each x value; points that are inside the window are weighted so that nearby points get the most weight.
Value
list containing components named x and y which are the x,y points of the smoothed scatter plot. Note that x is a sorted version of the input x vector, with duplicate points removed.
Note
This function may be slow for large numbers of points; execution time is proportional to (iter*f*n^2). Increasing delta should speed things up, as will decreasing f.
References
Becker, R. A., Chambers, J. M., and Wilks, A. R. 1988. The New S Language: A Programming Environment for Data Analysis and Graphics. Pacific Grove, CA: Wadsworth & Brooks/Cole Advanced Books and Software.
Chambers, J. M., et al. 1983. Graphical Methods for Data Analysis. Pacific Grove, CA.: Wadsworth & Brooks/Cole.
Cleveland, W. S. 1979. Robust locally weighted regression and smoothing scatterplots. Journal of the American Statistical Association. Volume 74. 829-836.
Cleveland, W. S. 1981. LOWESS: A program for smoothing scatterplots by robust locally weighted regression. The American Statistician.
See Also
approx, lines, loess, plot, smooth, supsmu.
Examples
require(Sdatasets)

fit <- lowess(car.miles, car.gals) fit2 <- lowess(car.miles, car.gals, f = 0.2)

resid <- car.gals - approx(fit, xout = car.miles)$y

# Same values with a data.frame: car.df <- data.frame(miles=car.miles, gals=car.gals) fit <- lowess(car.df) fit2 <- lowess(car.df, f = 0.8)

Package stats version 6.0.0-69
Package Index