Skip to main content
. Author manuscript; available in PMC: 2009 Sep 21.
Published in final edited form as: Int J Comput Biol Drug Des. 2008 Jan 1;1(4):368–395. doi: 10.1504/IJCBDD.2008.022208

Algorithm 1.

Loess Regression

  1. Let X = {x1, x2,…, xp} be a set of p points (or observations), and let Y = {y1, y2, …, yp} be the corresponding data values.

  2. for i=1 to p do

  3. Let xi be the point to be fitted on the loess curve.

  4. Let D(·) be an appropriate distance metric. For each point xjX, ij, define the distance dj = D(xi,xj).

  5. Let d(1}, d(2), …, d(p) be the ordered set of distances.

  6. Let k be the number of neighbors of xi to be used in the local regression. The value of k is given as a percentage of the number of observations and is called the span of the regression.

  7. Define N(xi), the neighborhood of xi, as the set of points closest to xi using the distance metric D:

    xjN(xi) if d(j)<k

  8. Define Δ, the maximum distance in the span, as

    Δ=maxxjN(xi)xixj
  9. Assign weights wj to each of the points xj

    wj=W(xixjΔ)

    where W(·) is the tri-cube function

    W(u)={(1u3)3,0u<1,0,otherwise.
  10. Calculate the weighted least squares fit of Y on the neighborhood of X using the weights w.

  11. Let s(·), the smooth function, be given by s(xi) = ŷj at the point xi

  12. end for

Source: Adapted from Cleveland and Devlin (1988)