# ma

From forecast v3.22
by Rob Hyndman

##### Moving-average smoothing

Computes a simple moving average smoother.

- Keywords
- ts

##### Usage

`ma(x, order, centre=TRUE)`

##### Arguments

- x
- Univariate time series
- order
- Order of moving average smoother
- centre
- If TRUE, then the moving average is centred.

##### Value

- Numerical time series object containing the smoothed values.

##### See Also

##### Examples

```
plot(wineind)
sm <- ma(wineind,order=12)
lines(sm,col="red")
```

*Documentation reproduced from package forecast, version 3.22, License: GPL (>= 2)*

### Community examples

**twigt.arie@gmail.com**at Sep 23, 2018 forecast v8.4

## Example to get an understanding how values are calculated by applying the `ma()` function. ```{r} # create a numerical vector which is easy to understand numbers <- c(3, 5, 3, 6, 4, 5, 3, 4, 4, 6, 3, 5, 4, 6, 3, 5, 4, 4, 6, 3, 5) # apply the 'ma' function ma(numbers, order = 5) ``` Calculate the average for the first 5 numbers by hand. ```{r} (sum(3, 5, 3, 6, 4))/5 ```