2
$\begingroup$

I'm displaying time-series data as a "stacked line" or "stacked area" chart. (E.g. with percentage data, data points at 10%, 20% and 30% are displayed at 10%, 30% and 60% on the chart.) Unsmoothed lines through the data points obviously never cross (and never go below the minimum data value or above the maximum total; think 0% and 100% again for instance). I'm looking for a smoothing function that will preserve these properties; that is, the smoothed lines should never cross (including between data points), should never exceed the maximum/minimum values given by the data points, and (ideally) should only touch at data points. Does such a beast exist?

As is probably apparent, I'm not a statistician. The smoothing here is only for visual appeal, so solutions that are theoretically less than ideal are still definitely on the cards.

$\endgroup$
1
  • $\begingroup$ A linear interpolator will surely work :-). $\endgroup$
    – whuber
    Commented Jan 9, 2012 at 15:25

1 Answer 1

1
$\begingroup$

If all series have the same number of data points at the same x positions, then a LOESS smoother with lambda=0 (essentially a weighted moving average) will satisfy your constraints.

0th degree lambda smoothers

At each position, you're computing $z_i = \frac{w_i * y_i}{n}$, where $w$ is the local smoothing function around the position. Given that $w_i$ and $n$ are the same for each series, if all the $y_i$ in one series are greater than or equal to the corresponding $y_i$ in another series, then the $z_i$ will follow the same rule. The external bounds condition is met by applying the above logic with a series of all min values or all max values.

This smoother will not usually go through the data points.

$\endgroup$
1
  • $\begingroup$ Some more thought has convinced me that I cannot get a (natural-looking) smoother that satisfies my requirements above and also passes through the data points. (Let two series coincide on an upward trend then diverge with one continuing upwards and the other going back down. Think about the derivatives at the point where they part company.) Looks like this is the best I'm gonna get. $\endgroup$
    – Tikitu
    Commented Jan 16, 2012 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.