November 2016
Beginner to intermediate
959 pages
43h 46m
English
The stats package provides many functions to process time series. This recipe covers the use of the decompose and stl functions to extract the seasonal, trend, and random components of time series.
If you have not already downloaded the data files for this chapter, do it now and ensure that the files are in your R working directory.
The following steps decompose time series:
> prices <- read.csv("prices.csv")> prices.ts = ts(prices, start = c(1980,1), frequency = 12)
> plot(prices.ts[,2])Read now
Unlock full access