R: Time series decomposition using a moving average
decaverage
R Documentation
Time series decomposition using a moving average
Description
Decompose a single regular time series with a moving average filtering. Return a 'tsd' object. To decompose several time series at once, use tsd() with the argument method="average"
a regular time series ('rts' under S+ and 'ts' under R)
type
the type of model, either type="additive" (by default), or type="multiplicative"
order
the order of the moving average (the window of the average being 2*order+1), centered around the current observation or at left of this observation depending upon the value of the sides argument. Weights are the same for all observations within the window. However, if the argument weights is provided, it supersedes order. One can also use order="periodic". In this case, a deseasoning filter is calculated according to the value of frequency
times
The number of times to apply the method (by default, once)
sides
If 2 (by default), the window is centered around the current observation. If 1, the window is at left of the current observation (including it)
ends
either "NAs" (fill first and last values that are not calculable with NAs), or "fill" (fill them with the average of observations before applying the filter, by default), or "circular" (use last values for estimating first ones and vice versa), or "periodic" (use entire periods of contiguous cycles, deseasoning)
weights
a vector indicating weight to give to all observations in the window. This argument has the priority over order
Details
This function is a wrapper around the filter() function and returns a 'tsd' object. However, it offers more methods to handle ends.