# MA

0th

Percentile

##### Moving Average Filter

Applies moving average filter to estimate the linear trend or nonseasonal pattern.

##### Usage
MA(x, nlag = NULL, plot = TRUE)
##### Arguments
x
a numeric vector or univariate time series.
nlag
the number of period to calculate the average. The default is NULL.
plot
a logical value indicating to print out the plot. The default is TRUE.
##### Details

The moving average filter uses the unweight mean of (2*nlag + 1) adjacent observations. That is, $$hat{X}[t] = (X[t - nlag] + ... + X[t] + ...+ X[t + nlag])/(2*nlag + 1)$$ for $nlag < t < n - nlag$. For the values at the boundary $t \le nlag$ or $n - nlag \le t \le n$, you can refer to Equation (7) in Qiu et al., (2013) for details of calculations. The default method for choosing the optimal nlag uses the rule-of-thumb criterion proposed by Qiu, et al., (2013), in which they showed that the moving average is a special case of local linear estimator in the sense that the kernel function is the uniform one, and the moving average period nlag is a function of bandwidth. Thus, choosing the optimal nlag is equivalent to choosing the optimal bandwidth in local linear regression.

The plot of original values v.s fitted values will be displayed if plot = TRUE.

##### Value

• A list with class "MA" containing the following components:
• estimatethe smoothed values.
• nlagthe period used to compute the average.
• accuratethe accurate measurements.

##### References

D. Qiu, Q. Shao, and L. Yang (2013), Efficient inference for autoregressive coefficient in the presence of trend. Journal of Multivariate Analysis 114, 40-53.

P.J. Brockwell, R.A. Davis, Time Series: Theory and Methods, second ed., Springer, New York, 1991.

• MA
##### Examples
x <- arima.sim(list(order = c(1,0,0),ar = 0.4),n = 100)
y <- 5*(1:100)/100 + x
MA(y)

# moving average filter for co2 data
MA(co2)
Documentation reproduced from package aTSA, version 3.1.2, License: GPL-2 | GPL-3

### Community examples

Looks like there are no examples yet.