Least squares smoothing of adjacent values
Another method that provides smoothed values up to both ends of a time series is called lowess (locally weighted scatterplot smoothing). When used with time series, it is similar to running means except that instead of using the average of values at adjacent times, it fits a least squares line through them and uses this least squares line to estimate the smoothed value.
Since a separate least squares line must be fitted to obtain each smoothed value, a computer must be used to apply this method.
US defence expenditure
The time series plot below shows the percentage of GDP in the USA that was invested in defence between 1947 and 2013.
The diagram initially shows lowess smoothed values based on adjacent groups of 3 values. Click on any value to see the adjacent values that are used, the least squares line that is fitted to them, and the smoothed value that is obtained from this least squares line. Drag over the time series plot to see how these 'local' least squares lines change as the set of adjacent values moves.
Use the slider to increase the number of adjacent values used to obtain the least squares lines and smoothed values. A 'window' width of about 5 results in a fairly smooth curve.
Click at the ends of the series and observe how smoothed values are obtained up to the ends of the series by extending the final least squares line.