ma {lfstat}R Documentation

Simple Moving Average

Description

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

Usage

ma(x, n, sides = "past")

Arguments

x

numeric vector to be smoothed

n

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

sides

one of 'past', 'center' or 'future' indicating the side of the filter.)

Value

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

See Also

filter

Examples

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

[Package lfstat version 0.9.12 Index]