The TS_SMOOTH function computes central, backward, or forward moving averages of an n -element time-series. Autoregressive forecasting and backcasting are used to extrapolate the time-series and compute a moving average for each point. The result is an n -element vector of the same data type as the input vector.
Note that central moving averages require Nvalues /2 forecasts and Nvalues /2 backcasts. Backward moving averages require Nvalues -1 backcasts. Forward moving averages require Nvalues -1 forecasts.
This routine is written in the IDL language. Its source code can be found in the file
ts_smooth.pro
in the
lib
subdirectory of the IDL distribution.
Set this keyword to compute backward-moving averages. If BACKWARD is set, the Nvalues argument must be an integer greater than one.
Set this keyword to compute forward-moving averages. If FORWARD is set, the Nvalues argument must be an integer greater than one.
An integer or long-integer scalar that specifies the order of the autoregressive model used to compute the forecasts and backcasts of the time-series. By default, a time-series with a length between 11 and 219 elements will use an autoregressive model with an order of 10. A time-series with a length greater than 219 will use an autoregressive model with an order equal to 5% of its length. The ORDER keyword is used to override this default.
Define an n-element vector of time-series samples.
X = [6.63, 6.59, 6.46, 6.49, 6.45, 6.41, 6.38, 6.26, 6.09, 5.99,$
5.92, 5.93, 5.83, 5.82, 5.95, 5.91, 5.81, 5.64, 5.51, 5.31,$
5.36, 5.17, 5.07, 4.97, 5.00, 5.01, 4.85, 4.79, 4.73, 4.76]
PRINT, TS_SMOOTH(X, 11) ; Compute the 11-point central-moving-averages of the time-series.
6.65761 6.60592 6.54673 6.47646 6.40480 6.33364
6.27000 6.20091 6.14273 6.09364 6.04455 5.99000
5.92273 5.85455 5.78364 5.72636 5.65818 5.58000