MA.Grid: Grid search for single and double moving average

MA.GridR Documentation

Grid search for single and double moving average

Description

Grid search for single and double moving averages to find optimal window value that minimize errors with respect to a certain test set. Iterates across given range of window values.

Usage

MA.Grid(trainset, testset, start = 2, end, dist = 1, nahead, type)

Arguments

trainset

A set of univariate time series data. Can be a vector (type double) or a data.table.

testset

Same as above.

start

Starting value for m (see sma.dt and dma.dt).

end

Maximum value for m. Must be less than or equal to the length of the training set for SMA, or less than or equal to the length of the training set divided by two for DMA.

dist

Distance between successive values for m. The vector of m values will be constructed as seq(start,end,dist).

nahead

Number of observations to forecast.

type

Type of moving average. Can be "SMA" or "DMA"

Value

A data.table containing tested values of m, with MSE and MAPE for each value.

Examples

MA.Grid(crudenow$Close, crudetest$Close, start=1, end=30, dist=2, nahead=12, type="SMA")
MA.Grid(crudenow$Close, crudetest$Close, start=1, end=30, dist=2, nahead=12, type="DMA")

ammarsahab/smoothCV documentation built on April 18, 2022, 4:39 p.m.