Tutorials › Regression Analysis (Undergraduate) › Choosing a Smoother Span

Visualizing Relationships · Tutorial 59 of 991

Choosing a Smoother Span

Compare LOESS span settings to find a curve that shows broad structure without chasing random scatter or smoothing away meaningful patterns.

Beginner 10 min read

What You'll Learn

  • Explain how the span determines the approximate fraction of observations used in each local fit.
  • Compare small, moderate, and large spans on the same scatterplot.
  • Recognize signs that a smoother is following local noise or hiding visible structure.
  • Use a consistent, plot-based process to compare candidate span settings.
  • Explain why smoother choice involves a trade-off between wiggliness and flattening.

Why the Span Matters

A LOESS curve is a flexible summary of how a response tends to vary across a quantitative predictor. Its span controls how much of the data contributes to each part of the curve. Change the span, and the same scatterplot can look noticeably different: a smaller span can follow more local changes, while a larger span tends to show a broader, smoother pattern.

The goal is not to make the curve pass close to every point, nor to make it as smooth as possible. Either extreme can mislead. A curve that follows random ups and downs can make noise look like structure; a curve that smooths too broadly can conceal a real bend or local feature. Choosing a span is therefore a visual judgment about the balance between detail and stability, made while keeping the underlying scatterplot visible.

What the Span Controls

At a chosen predictor value, LOESS fits a local polynomial using nearby observations. The span sets the approximate fraction of the data included in each local fit. For instance, with a span of 0.5, the fit at each location uses roughly the nearest half of the observations, with closer observations generally receiving more weight. Exact conventions, rounding, and weighting details can differ across software.

Definition: The LOESS span is a setting that controls the size of the local neighborhood used to estimate the curve at each predictor value. A smaller span uses a narrower neighborhood and can respond more to local variation; a larger span uses a broader neighborhood and tends to produce a smoother curve. The span is a fraction or proportion setting, not the number of response units over which the curve is smoothed.

A common LOESS fit chooses nearby points, gives them distance-based weights, and fits a low-degree polynomial locally. A typical distance weighting gives more influence to nearby observations and gradually less to those farther away. The estimated curve at a location is then obtained from the local fit at that location. The span changes the neighborhood size; it does not change the recorded observations or the axes.

As a rough guide, if there are \(n\) observations, a span \(s\) corresponds to about \(s n\) observations in a local neighborhood. This is only an approximation: ties in predictor values, software conventions, and locations near the ends of the predictor range can affect the exact number and arrangement of points used. The same numerical span also need not produce the same curve in two data sets with different sample sizes or predictor distributions.

Worked Example: Comparing a Narrow and Broad Neighborhood

Worked Example: Comparing a Narrow and Broad Neighborhood

Suppose a hypothetical class records study time \(x\), in hours, and a quiz score \(y\), in points, for 10 students. The points, listed in order of study time, are \((1,2), (2,4), (3,5), (4,8), (5,9), (6,10), (7,9), (8,7), (9,5), (10,4)\). These values suggest a broad rise and fall, with small local irregularities.

Compare spans of 0.3 and 0.8. With \(n=10\), the rough neighborhood counts are:

$$ 0.3(10)=3 \qquad\text{and}\qquad 0.8(10)=8. $$

The 0.3 span uses about three nearby students for each local fit. It can respond strongly to the differences among adjacent scores, so the curve may turn at several points. The 0.8 span uses about eight students at a time. Because it draws information from a much wider portion of the data, it is likely to show a gentler, broader pattern and may mute the small changes between neighboring scores.

Here the intended comparison is not which curve passes closest to every listed score. Instead, inspect both curves against the points: does the narrow-span curve create repeated bends that seem to track isolated ups and downs? Does the broad-span curve make the overall rise and fall hard to see? A useful setting would show the broad pattern without making every adjacent difference look like a lasting feature. The calculation predicts how local the fits are; the plot is needed to judge the resulting curves.

Reading Small and Large Spans on a Plot

A small span is not automatically wrong. It can reveal genuine local shape when the data support it. But a curve with many abrupt turns, especially turns associated with just one or two points, is a warning that the span may be too small for a stable summary. A large span can be useful when the aim is to show a broad overall pattern. But if a bend that is visible in a sequence of nearby points disappears entirely, the span may be too large for that feature.

The judgement should be made relative to the scatterplot. A curve is not evidence that every point follows a precise path; it is a guide to the general pattern across the plotted data. Keep the points visible, and compare candidate spans on the same axes, using the same data and fitting options. Otherwise, differences in appearance may come from changed scales or data rather than from the span itself.

The curve can also behave differently at the edges. Near an end of the predictor range, its neighborhood may have fewer points on one side than the other. A change in span can therefore affect the ends noticeably. Inspect those regions rather than assuming that a smooth-looking edge is equally well supported as the middle of the plot.

Worked Example: Detecting an Overly Wiggly Curve

In another hypothetical data set, 20 measurements are recorded at regularly spaced values of \(x\), from 1 to 20. The scatterplot shows a steady broad increase in \(y\), but consecutive observations vary above and below that general pattern. Consider a span of 0.2 and a span of 0.6.

The approximate neighborhood sizes are:

$$ 0.2(20)=4 \qquad\text{and}\qquad 0.6(20)=12. $$

With a span of 0.2, each fit uses about four nearby observations. In a region where the points alternate around the broad rise, the fitted curve may also rise and fall locally. If those turns appear where only a small number of points depart from the broader sequence, they may be the smoother reacting to local scatter rather than revealing a stable feature.

With a span of 0.6, each fit uses about 12 observations, so it draws on more of the broader increase. Compare the two curves: if the 0.2 curve has several extra bends but the 0.6 curve still shows the broad rise, the larger span may be a clearer visual summary. This does not prove that every small bend is random. It means the scatterplot provides limited reason to emphasize those bends as part of the general pattern.

Why There Is a Trade-Off

The span creates a familiar tension: a narrow neighborhood is responsive but can be unstable, while a broad neighborhood is steadier but can blur local changes. A short calculation with a local weighted average helps explain one part of this trade-off. Suppose the predictor locations are fixed and the responses can be written as \(y_i=m_i+\varepsilon_i\), where \(m_i\) is the underlying mean response and the errors \(\varepsilon_i\) are independent, have mean zero, and have common variance \(\sigma^2\). For fixed local weights \(a_i\) that sum to 1, the weighted average is \(\hat m=\sum_i a_i y_i\). Its error due to the random errors is \(\sum_i a_i\varepsilon_i\), so independence gives:

$$ \operatorname{Var}\!\left(\sum_i a_i\varepsilon_i\right) =\sum_i a_i^2\operatorname{Var}(\varepsilon_i) =\sigma^2\sum_i a_i^2. $$

When the weight is spread more broadly across observations, no single \(a_i\) tends to dominate, and \(\sum_i a_i^2\) can be smaller. That can make the local estimate less sensitive to random error. However, if the underlying mean response changes across the neighborhood, averaging observations from farther away can pull the estimate away from the local mean. That is the reason broader smoothing can hide real shape. LOESS usually uses local polynomial fits rather than just a weighted average, so this calculation is an illustration of the stability idea, not a general formula for the variance of every LOESS fit.

This trade-off explains why one span cannot be declared best for every plot. The useful choice depends on how much structure the data show, how densely the predictor range is covered, and what level of detail the curve is intended to summarize. In all cases, the point cloud remains essential context.

Worked Example: Choosing Between Candidate Spans

A hypothetical environmental monitoring team plots 15 daily measurements against temperature. The point cloud shows a broad increase that becomes less steep at higher temperatures. The team wants a curve that summarizes this broad shape, not a separate description of each daily fluctuation. They compare spans of 0.2, 0.5, and 0.9, keeping the same points, axes, and fitting options.

Their approximate neighborhood counts are:

$$ 0.2(15)=3,\qquad 0.5(15)=7.5\approx 8,\qquad 0.9(15)=13.5\approx 14. $$

The narrowest span uses only about three nearby days at a time. If its curve repeatedly turns around small isolated departures from the broad increase, it is too responsive for the team's stated goal. The 0.9 span uses almost the whole data set in each local fit. If it makes the change in steepness hard to see, it is smoothing beyond the level of detail the team wants to retain. The 0.5 span is a reasonable candidate if it shows the broad increase and its flattening without tracing the individual daily fluctuations.

This is a reasoned visual choice, not a numerical proof that 0.5 is optimal. The span should be reported or otherwise made clear when presenting the graph, so readers can interpret how much local detail the curve is designed to retain.

A Practical Comparison Process

A disciplined comparison makes span choice easier to explain and less dependent on selecting whichever curve looks most appealing. Use several plausible settings on the same scatterplot, starting with a smaller, a middle, and a larger span. The specific values are candidates, not universal cutoffs. Compare the curves in the context of the points and ask which visible features persist as the span changes.

1
Keep the plot fixed.
Use the same observations, axis limits, and LOESS fitting choices for every candidate span, so the span is the meaningful difference.
2
Compare a range of spans.
Include a narrower, a moderate, and a broader neighborhood. Remember that the span corresponds approximately to a fraction of the observations, not a fixed distance on the horizontal axis.
3
Look for sensitivity.
Notice which turns or bends remain visible across settings and which appear only with a very narrow span. A feature that changes greatly with small span adjustments deserves cautious description.
4
Match the curve to its purpose.
Choose a setting that conveys the broad pattern at the desired level of detail, and describe the displayed curve as a visual summary rather than as a complete account of every observation.

The process is not a search for a curve that confirms a preferred story. If the curve looks different under nearby reasonable spans, that sensitivity is itself useful information: the data do not support a single clear level of detail in that region. It is better to show that uncertainty in the visual summary than to present a highly specific curve as though its small features were unquestionable.

Common Mistake: Treating Every Bend as Real

  • Wrong reasoning: “The narrowest span passes closest to the points, so it must be the most accurate curve.” That reasoning confuses closeness to observed values with a stable representation of the overall pattern. Individual points include variation, and a very responsive curve can follow that variation.
  • Correction: Compare multiple spans and judge whether apparent bends are supported by a sequence of nearby observations and remain visible under reasonable changes to the span. Keep the scatterplot visible and describe the curve as a summary, not as proof that every turn represents a lasting feature.
  • Another wrong turn: “The smoothest curve is always best.” A very broad span can erase visible changes in shape. Choose the span to preserve the level of structure relevant to the plot, not simply to minimize the number of bends.
Key takeaway: Smaller spans give LOESS more local responsiveness, and larger spans favor broader smoothness. Compare candidate settings on the same scatterplot; prefer a curve that communicates the pattern without either chasing isolated fluctuations or flattening visible structure.

Check Your Understanding

Use the definitions and comparison principles above to answer these questions.

  1. With 30 observations, about how many points contribute to a local fit when the span is 0.4? Why is this only an approximate count?
  2. A small-span curve has several sharp turns, each near only one unusual point. What should you check before describing those turns as features of the pattern?
  3. Why might a very large span make a visible bend in the scatterplot harder to see?
  4. When comparing two spans, why should the data and axis limits remain the same?
  5. A curve changes substantially when the span is adjusted slightly. What does this sensitivity suggest about how confidently to describe its local detail?