Learn R Programming

forecast (version 9.0.0)

seasonal: Extract components from a time series decomposition

Description

Returns a univariate time series equal to either a seasonal component, trend-cycle component or remainder component from a time series decomposition.

Usage

seasonal(object)

trendcycle(object)

remainder(object)

Value

Univariate time series.

Arguments

object

Object created by stats::decompose(), stats::stl() or tbats().

Author

Rob J Hyndman

See Also

stats::stl(), stats::decompose(), tbats(), seasadj().

Examples

Run this code
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 = "")

Run the code above in your browser using DataLab