% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/components.R
\name{seasonal}
\alias{seasonal}
\alias{trendcycle}
\alias{remainder}
\title{Extract components from a time series decomposition}
\usage{
seasonal(object)

trendcycle(object)

remainder(object)
}
\arguments{
\item{object}{Object created by \code{\link[stats:decompose]{stats::decompose()}},
\code{\link[stats:stl]{stats::stl()}} or \code{\link[=tbats]{tbats()}}.}
}
\value{
Univariate time series.
}
\description{
Returns a univariate time series equal to either a seasonal component,
trend-cycle component or remainder component from a time series
decomposition.
}
\examples{
plot(USAccDeaths)
fit <- stl(USAccDeaths, s.window = "periodic")
lines(trendcycle(fit), col = "red")

library(ggplot2)
autoplot(
  cbind(
    Data = USAccDeaths,
    Seasonal = seasonal(fit),
    Trend = trendcycle(fit),
    Remainder = remainder(fit)
  ),
  facets = TRUE
) +
  labs(x = "Year", y = "")

}
\seealso{
\code{\link[stats:stl]{stats::stl()}}, \code{\link[stats:decompose]{stats::decompose()}}, \code{\link[=tbats]{tbats()}}, \code{\link[=seasadj]{seasadj()}}.
}
\author{
Rob J Hyndman
}
\keyword{ts}
