2019issue C038
Constructing nested regression projections as smoothers
A linear projection reports the fitted value of a price series against a running bar index. A nested-projection smoother then applies a second projection whose inner lookback is the integer part of the square root of the outer lookback. A moving average and a Hull moving average sit beside that nested form as construction contrasts.
- A linear projection fits a chosen price series to a running bar index over n bars and reports the fitted value at the current index.
- Slope and intercept both come from least-squares identities that reuse the same window sums of the index-price product, the index, the price, and the squared index.
- The nested-projection smoother feeds the first projection into a second projection whose inner lookback is the integer part of the square root of the outer lookback.
- A moving average averages one window of ordered observations, and a Hull moving average is the weighted comparison baseline used when a reader asked for a platform implementation of the nested form.
A construction contrast
Editorial: this note teaches how an ordinary moving average, a Hull moving average, and a nested-projection smoother are assembled. It does not rank the three constructions.
A moving average is a single-window average of ordered observations. A Hull moving average is a weighted moving-average smoother used here as the explicit comparison baseline. The nested-projection smoother is a two-stage filter that feeds one linear projection into a second projection.
What a linear projection reports
A linear projection fits a linear relationship between a running bar index and a chosen price series over a lookback of n bars, then reports the fitted value at the current index.
The bar index used as the regressor increments by one on each new observation.
The slope is obtained from the ordinary least-squares identity that combines the lookback length with the window sums of the index-price product, the index, the price, and the squared index. The intercept is obtained from the matching least-squares identity that uses those same window sums.
How the nested-projection smoother is stacked
The nested-projection smoother is defined as a second linear projection applied to the first projection, with the inner lookback set to the integer part of the square root of the outer lookback.
The outer lookback is the window length supplied to the first projection on the raw series. The inner lookback is the shorter second-stage window.
Lookbacks in the supplied examples
One supplied implementation uses an outer lookback of 20 and therefore an inner lookback equal to the integer square root of 20.
A plotted variant uses an outer length of 9 with the same nested projections and colors the line by whether the current value is above or below the prior value.
All readings on this track · 6 readings
- 2010Constructing a Hull smoother and a Hull-based oscillator gate
- 2015Evaluating moving-average lag in cycle filters
- 2017Rebuild a Hull moving average with linear-regression intercepts
- 2017A Hull moving-average forecast in a credit-spread trend procedure
- 2019Constructing nested regression projections as smoothers
- 2020Evaluating countertrend ETF rules against a buy-and-hold control