Last Update: June 1, 2022
My online video tutorials are hosted at YouTube channel.
For learning this concept, you can view my online video tutorial: Time Series Decomposition: Classical Method in R.
Video Code
1. Packages
library(forecast)
library(ggplot2)
2. Data
mdata <- AirPassengers
head(mdata)
Ranges Delimiting
tdata <- window(x = mdata, end = c(1958, 12))
fdata <- window(x = mdata, start = c(1959, 1))
Chart
autoplot(object = tdata) + labs(y = "Air Passengers", x = "Year")
3. Time Series Decomposition
Classical Method
tsdec <- decompose(x = tdata, type = "additive", filter = NULL)
autoplot(tsdec)