MA.Grid | R Documentation |
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.
MA.Grid(trainset, testset, start = 2, end, dist = 1, nahead, type)
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 |
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 |
nahead |
Number of observations to forecast. |
type |
Type of moving average. Can be |
A data.table containing tested values of m, with MSE and MAPE for each value.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.