ts_fil_ma: Moving Average (MA)

View source: R/ts_fil_ma.R

ts_fil_maR Documentation

Moving Average (MA)

Description

Smooth out fluctuations and reduce noise by averaging over a fixed-size rolling window.

Usage

ts_fil_ma(ma = 3)

Arguments

ma

moving average size

Details

Larger windows produce smoother series but may lag turning points.

Value

A ts_fil_ma object.

Examples

# time series with noise
library(daltoolbox)
data(tsd)
tsd$y[9] <- 2*tsd$y[9]

# filter
filter <- ts_fil_ma(3)
filter <- fit(filter, tsd$y)
y <- transform(filter, tsd$y)

# plot
plot_ts_pred(y=tsd$y, yadj=y)

tspredit documentation built on Feb. 11, 2026, 9:08 a.m.