Description
Decompose a time series into seasonal, trend and irregularcomponents using moving averages. Deals with additive ormultiplicative seasonal component.
Usage

decompose(x, type=c("additive", "multiplicative"),filter=NULL)Arguments
xA time series.
typeThe type of seasonal component. Can be abbreviated.filterA vector of filter coefficients in reverse time order (as forAR or MA coefficients), used for filtering out the seasonalcomponent. If NULL, a moving average with symmetric window isperformed.
Details
The additive model used is:
Y[t]=T[t] + S[t] + e[t]
The multiplicative model used is:
Y[t]=T[t] * S[t] * e[t]
The function first determines the trend component using amoving average (if filter is NULL, a symmetric window with equalweights is used), and removes it from the time series. Then, theseasonal figure is computed by averaging, for each time unit, ov erall periods. The seasonal figure is then centered. Finally, theerror component is determined by removing trend and seasonal figure(recycled as needed) from the original time series.
Value
An object of class "decomposed.ts" with followingcomponents:
seasonalThe seasonal component (i.e., the repeated seasonalfigure)
figureThe estimated seasonal figure only
trendThe trend component
randomThe remainder part
typeThe value of type
#这个函数,主要用移动平均把趋势分解成季节影响,本身趋势,随机影响三部分。
#ts>xx<-ts(1:1095,start=c(2011,1,1),frequency=365)#DATA=1:1095;起始时间是2011年1月1日;一年为一个周期#decompose>f<-decompose(xx)> plot(f)