seasonal: Extract components from a time series decomposition

View source: R/components.R

seasonalR Documentation

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)

Arguments

object

Object created by decompose, stl or tbats.

Value

Univariate time series.

Author(s)

Rob J Hyndman

See Also

stl, decompose, tbats, seasadj.

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) +
  ylab("") + xlab("Year")


forecast documentation built on June 22, 2024, 9:20 a.m.