ma: Simple Moving Average

Description Usage Arguments Value See Also Examples

Description

Smoothing a time series with moving averages using the filter function.

Usage

1
ma(x, n, sides = 1)

Arguments

x

numeric vector to be smoothed

n

numeric vector of length one determining the width of the smoothing window

sides

see filter

Value

a vector as long as x, but smoothed. Possibly with NAs.

See Also

filter

Examples

1
2
ma(1:10, n = 3, sides = 2)    # centered around lag 0
ma(1:10, n = 3)               # past values

Example output

Loading required package: xts
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: lmom
Loading required package: lattice
 [1] NA  2  3  4  5  6  7  8  9 NA
 [1] NA NA  2  3  4  5  6  7  8  9

lfstat documentation built on May 2, 2019, 6:07 p.m.