The plastics data set consists of the monthly sales (in thousands) of product A for a plastics manufacturer for five years.
data("plastics")
plastics %>%
autoplot()
The data shows a general upward trend over the course of the five years and what appears to be yearly seasonality.
Use a classical multiplicative decomposition to calculate the trend-cycle and seasonal indices.
plastics %>%
decompose(type='multiplicative') %>%
autoplot()
Yes. The data supports my initial observations from the data. There does appear, however, to be some seasonality not captured in the remainder observed by the cyclic pattern of the remainder facet.
sea <- plastics %>%
decompose(type='multiplicative')
autoplot(plastics, series='Data') +
autolayer(seasadj(sea), series='Seasonally Adjusted')
plastics[30] <- plastics[30] + 500
sea <- plastics %>%
decompose(type='multiplicative')
autoplot(plastics, series='Data') +
autolayer(seasadj(sea), series='Seasonally Adjusted')
The outlier has a moderate effect on the seasonally adjusted data. The response is somewhat robust to the outlier.
Does it make any difference if the outlier is near the end rather than in the middle of the time series?
plastics[30] <- plastics[30] - 500
plastics[5] <- plastics[5] + 500
sea <- plastics %>%
decompose(type='multiplicative')
autoplot(plastics, series='Data') +
autolayer(seasadj(sea), series='Seasonally Adjusted')
plastics[5] <- plastics[5] - 500
plastics[55] <- plastics[55] + 500
sea <- plastics %>%
decompose(type='multiplicative')
autoplot(plastics, series='Data') +
autolayer(seasadj(sea), series='Seasonally Adjusted')
No. The decomposition appears to be highly sensitive to outliers no matter where they are in the time series. It is less resiliant to an outlier on the edge than it is to an outlier in the middle of the data.
Recall your retail time series data (from Exercise 3 in Section 2.10). Decompose the series using X11. Does it reveal any outliers, or unusual features that you had not noticed previously?
retaildata <- readxl::read_excel('./retail.xlsx', skip=1)
myts <- retaildata %>%
select(A3349335T) %>%
ts(frequency=12, start=c(1982, 4))
myts %>%
autoplot()
myts %>%
seas(x11='') %>%
autoplot()
The decomposition of the seasonality and trend matches the previous work done on this data set. The remainder facet, however, reveals a number of interesting features. There appear to be a number of unusually large values across the data set that are worthy of further investigation. These points are not easily identified on the original plot. At the same time, it should be noted that the size of these remainder values is small compared to the overall trend of the data but sizeable considering the seasonality. This indicates that there was an a number of anomously large values in certain seasons.