How to use the stl function
- For explanation on how to interpret the function, please click here
- So when i was exploring the ?(hsales), I noticed the documentation had used stl function in the examples with the dataset
- My interpretation of this function, is that it shows you how much of the variation is due to seasonality and trend.
- I plot the function below
library(fpp2)
library(GGally)
library(cowplot)
plot(stl(hsales,"per"),main="Sales of new one-family houses using stl function")

- The box on the right side provides a scale. Smaller boxes, indicate the level of influence
- From what I can tell, as trend is closer in scale to data, that would imply our data is showing a trend? It also implies the data isn’t really showing seasonality, considering seasonality scale is much larger?
- Yet when we look at the seasonal subseries plot below, it seems pretty obvious that there is a seasonal effect, with higher sales in the spring and summer.
- Can anyone better explain how the stl function works and if I am misinterpreting it?
plot_grid(autoplot(hsales),ggAcf(hsales,lag=12))

ggsubseriesplot(hsales) +
ggtitle("Seasonal subseries plot: h sales")
