\HeaderA{decompose}{Classical Seasonal Decomposition by Moving Averages}{decompose}
\aliasA{plot.decomposed.ts}{decompose}{plot.decomposed.ts}
\keyword{ts}{decompose}
\begin{Description}\relax
Decompose a time series into seasonal, trend and irregular components
using moving averages.  Deals with additive or multiplicative
seasonal component.
\end{Description}
\begin{Usage}
\begin{verbatim}
decompose(x, type = c("additive", "multiplicative"), filter = NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] A time series.
\item[\code{type}] The type of seasonal component. Can be abbreviated.
\item[\code{filter}] A vector of filter coefficients in reverse time order (as for
AR or MA coefficients), used for filtering out the seasonal
component. If \code{NULL}, a moving average with symmetric window is
performed.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The additive model used is:
\deqn{Y_t = T_t + S_t + e_t}{Y[t] = T[t] + S[t] + e[t]}
The multiplicative model used is:
\deqn{Y_t = T_t\,S_t\, e_t}{Y[t] = T[t] * S[t] * e[t]}

The function first determines the trend component using a moving
average (if \code{filter} is \code{NULL}, a symmetric window with equal
weights is used), and removes it from the time series.  Then, 
the seasonal figure is computed by averaging, for each time unit,
over all periods. The seasonal figure is then centered.
Finally, the error component is determined by
removing trend and seasonal figure (recycled as needed) from the orginal
time series.
\end{Details}
\begin{Value}
An object of class \code{"decomposed.ts"} with following components:
\begin{ldescription}
\item[\code{seasonal}] The seasonal component (i.e., the repeated seasonal figure)
\item[\code{figure}] The estimated seasonal figure only
\item[\code{trend}] The trend component
\item[\code{random}] The remainder part
\item[\code{type}] The value of \code{type}
\end{ldescription}
\end{Value}
\begin{Note}\relax
The function \code{\LinkA{stl}{stl}} provides a much more sophisticated
decomposition.
\end{Note}
\begin{Author}\relax
David Meyer \email{David.Meyer@wu-wien.ac.at}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{stl}{stl}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
require(graphics)

m <- decompose(co2)
m$figure
plot(m)
\end{ExampleCode}
\end{Examples}

