When conducting exploratory data analysis, scatter plots are commonly used tools to visualise a relationship between two variables.
A common geom_ in ggplot2 is geom_smooth which "Aids the eye in seeing patterns in the presence of overplotting".
We can see this is a great smoother to cut through the noise and help interpret the data. For less than 1000 observation this is done using a method called loess.
LOESS also has applications in time series decomposition (trying to understand the trend in noisy time series data).
LOESS (LOcal Polynomial RegrESSion, or LOWESS "Locally Weighted Scatter plot Smoothing") is a commonly used technique for smoothing a bivariate set of points.
LOESS draws a smooth line through your points.
Given bivariate observations (xi, yi), i = 1, 2, .., m the basic model that can be fitted may be written as yi = g(xi) + ϵi, i = 1, …, n where ϵi = NID(0, σ2) and g(x) is a local polynomial of degree λ ≥ 0, which may be written as g(x) = β0(x) + β1(x)x + … + βλ(x)xλ.
This line is created from a statistical model that can be a simple average of the points, a straight line or a squiggly line.
As we go along the x-axis to draw our squiggle, at any given point, the model tries to draw a small part of that line. The model places stronger emphasis on points nearby that x-value by applying a special weight formula.
with wi(x) = T(Δi(x)/Δ(x, α)) to define the local neighborhood weights for the data at the point x. Here Δi(x) = |x − xi| and Δ(x, α) controls the amount of smoothing (larger values of Δ(x, α) result in more smoothing). As Δ(x, α) → ∞, wi(x) → 1 , for each i = 1, 2, …, n, and the local linear model reduces to the standard parametric polynomial regression.
For 0 < α ≤ 1, Δ(x, α) is the distance to the qth nearest neighbor where q = [αn] ([.] is the integer part function). Hence, Δ(x, α) = Δ(q)(x), where Δ(q)(x) denotes the qth largest value of Δi(x), i = 1, …, n, . For , α > 1, Δ(x, α) = αΔ(n)(x) . It follows that as α → ∞ , the local linear model reduces to a parametric polynomial regression of degree λ .
To define what is meant by 'nearby', there is a special window created around any given x-value. If we make this window really small, only the points close to our current position on the x-axis influence where the smoothed line gets drawn, so the line will hug closely to the actual data and produce a noisy, squiggly line. If we relax this and make the window large, more points will fight for influence and as a result we will get a much smoother line.
When we adjust α the smoothing parameter, this controls the percentage of data included in the window around any point on the x-axis when we fit the model.