Moving Average (MA)

Rolling Average

TrendDecomposition.rollingAverageFunction
rollingAverage(y :: Vector, p :: Int; centered::Bool = true, discard::Bool = false, offset::Int = 0)

Computes the moving average of the vector y with p data points.

With centered equal true, p has to be an odd number so that an equal number of leads and lags can be used. By default when centered = false, the computation includes the datum plus its most recent p-1 lagged values. This behavior can be changed by including an offset; a positive offset includes one additonal lead at the expense of the oldest lag value

For discard=false the function rolls over all data, even if not all p data points can be used.

source
rollingAverage(y :: Vector, p :: Int, weights :: Vector;
    centered::Bool = true, discard::Bool = false, offset::Int = 0)

Computes the moving average of the vector y with p data points weighted by vector w.

With centered equal true, p has to be an odd number so that an equal number of leads and lags can be used. By default when centered = false, the computation includes the datum plus its most recent p-1 lagged values. This behavior can be changed by including an offset; a positive offset includes one additonal lead at the expense of the oldest lag value.

For discard=false the function rolls over all data, even if not all p data points can be used, in any case all used weights will sum to 1.

source

Seasonal Average

TrendDecomposition.maSeasonFunction
maSeason(y :: Vector, seasons :: Int; repeating::Bool = false)

Given the number of seasons, the function computes the average value of each season component. This method works better for detrended data.

With reapeating equal true the function will repeat the results until the output vector has the same length as the input vector y.

source

MA decomposition

TrendDecomposition.maDecomposeFunction
maDecompose(y :: Vector, seasons :: Int; combine::Bool = false, model=:add)

Decomposes the time series y into trend (T), season (S) and noise components (I).

Either assumes an additive model (:add) or a multiplicative model (:mul).

Replicates the R decompose{stats} function. For a more generic function implementation see decompose of this package (TrendDecomposition.decompose).

Returns a matrix where the columns correspont to the above mentioned components in (T, S, I) order; with combine equal true it returns (y, T, S, I) as columns.

source