lowess                 package:stats                 R Documentation

_S_c_a_t_t_e_r _P_l_o_t _S_m_o_o_t_h_i_n_g

_D_e_s_c_r_i_p_t_i_o_n:

     This function performs the computations for the _LOWESS_ smoother
     which uses locally-weighted polynomial regression (see the
     references).

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_s:

    x, y: vectors giving the coordinates of the points in the scatter
          plot. Alternatively a single plotting structure can be
          specified - see 'xy.coords'.

       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 'iter' will make 'lowess'
          run faster.

   delta: See 'Details'.  Defaults to 1/100th of the range of 'x'.

_D_e_t_a_i_l_s:

     'lowess' is defined by a complex algorithm, the Ratfor original of
     which (by W. S. Cleveland) can be found in the R sources as file
     'src/appl/lowess.doc'.  Normally a local linear polynomial fit is
     used, but under some circumstances (see the file) a local constant
     fit can be used.  'Local' is defined by the distance to the
     'floor(f*n)'th nearest neighbour, and tricubic weighting is used
     for 'x' which fall within the neighbourhood.

     The initial fit is done using weighted least squares.  If 'iter >
     0', further weighted fits are done using the product of the
     weights from the proximity of the 'x' values and case weights
     derived from the residuals at the previous iteration. 
     Specifically, the case weight is Tukey's biweight, with cutoff 6
     times the MAD of the residuals.  (The current R implementation
     differs from the original in stopping iteration if the MAD is
     effectively zero since the algorithm is highly unstable in that
     case.)

     'delta' is used to speed up computation: instead of computing the
     local polynomial fit at each data point it is not computed for
     points within 'delta' of the last computed point, and linear
     interpolation is used to fill in the fitted values for the skipped
     points.

_V_a_l_u_e:

     'lowess' returns a list containing components 'x' and 'y' which
     give the coordinates of the smooth. The smooth can be added to a
     plot of the original points with the function 'lines': see the
     examples.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

     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.

_S_e_e _A_l_s_o:

     'loess', a newer formula based version of 'lowess' (with different
     defaults!).

_E_x_a_m_p_l_e_s:

     require(graphics)

     plot(cars, main = "lowess(cars)")
     lines(lowess(cars), col = 2)
     lines(lowess(cars, f=.2), col = 3)
     legend(5, 120, c(paste("f = ", c("2/3", ".2"))), lty = 1, col = 2:3)

