Learn R Programming

TSPred (version 4.0)

MAS: Moving average smoothing

Description

The MAS() function returns a simple moving average smoother of the provided time series. MAS.rev() reverses the transformation(smoothing) process.

Usage

MAS(x,order)

MAS.rev(xm,xinit,order,addinit=TRUE)

Arguments

x

A numeric vector or univariate time series.

order

Order of moving average smoother.

xm

A numeric vector or univariate time series that was moving average smoothed. Possibly returned by MAS().

xinit

Initial order-1 values/observations used for reverse smoothing. First order-1 known non-transformed values used to recursively obtain the original series.

addinit

If TRUE, xinit is included in the return.

Value

Numerical time series of length length(x)-order+1 containing the simple moving average smoothed values.

Details

The moving average smoother transformation is given by $$$$ where k=order, t assume values in the range 1:(n-k+1), and n=length(x). See also the ma of the forecast package.

References

R.H. Shumway and D.S. Stoffer, 2010, Time Series Analysis and Its Applications: With R Examples. 3rd ed. 2011 edition ed. New York, Springer.

See Also

DIF,detrend, PCT, LT, BCT

Examples

Run this code
# NOT RUN {
data(CATS)
# }
# NOT RUN {
#automatically select order of moving average
order <- fittestMAS(CATS[,1],h=20,model="arima")$order
# }
# NOT RUN {
order <- 5
m <- MAS(CATS[,1],order=order)

xinit <- head(CATS[,1],order-1)
x <- MAS.rev(m,xinit,order,addinit=TRUE)

all(round(x,4)==round(CATS[,1],4))
# }

Run the code above in your browser using DataLab