Data 624 HW 3

Maryluz Cruz

2021-03-08

require(fpp2)
require(fpp3)
require(readxl)

6.2. The plastics data set consists of the monthly sales (in thousands) of product A for a plastics manufacturer for five years.

  1. Plot the time series of sales of product A. Can you identify seasonal fluctuations and/or a trend-cycle?
autoplot(plastics)

ggseasonplot(plastics)

Looking at the plot it seems like it peaks during the summer and it goes down in other times, so this seems to have seasonal fluctuations.

  1. Use a classical multiplicative decomposition to calculate the trend-cycle and seasonal indices.
plastics %>% 
  decompose(type="multiplicative")%>% 
  autoplot()+ggtitle('Classical multiplicative decomposition of Monthly Sales of plastic product')

  1. Do the results support the graphical interpretation from part a?

The results do support the graphical interpretation because it seems to peak at a particular time and decrease as well.

  1. Compute and plot the seasonally adjusted data.
seas_adj<-seasadj(decompose(plastics,"multiplicative"))
autoplot(plastics,series="Data")+
  autolayer(seas_adj, series= "seasonally adjusted")+
  ggtitle("Seasonally adjusted data")

  1. Change one observation to be an outlier (e.g., add 500 to one observation), and recompute the seasonally adjusted data. What is the effect of the outlier?

It has a big peak towards the end.

plastics[50] <- plastics[50] + 500
seas_adj<-seasadj(decompose(plastics,"multiplicative"))
autoplot(plastics, series='Data') +
  autolayer(seas_adj, series='seasonally adjusted')

  1. Does it make any difference if the outlier is near the end rather than in the middle of the time series?

There seems to be no difference whether the outlier is near the end instead of the middle the peaks are still the same regardless where the outliers are.

plastics[50] <- plastics[50] - 1000
plastics[10] <- plastics[10] + 1000
seas_adj<-seasadj(decompose(plastics,"multiplicative"))
autoplot(plastics, series='Data') +
  autolayer(seas_adj, series='seasonally adjusted')

plastics[10] <- plastics[10] - 1000
plastics[55] <- plastics[55] + 1000
seas_adj<-seasadj(decompose(plastics,"multiplicative"))
autoplot(plastics, series='Data') +
  autolayer(seas_adj, series='seasonally adjusted')

6.3. 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?

It does not seem to reveal anything that is unusual, especially while looking at the trend its just an upward trend.

retaildata <- readxl::read_excel("retail.xlsx", skip=1)

myts <- ts(retaildata[,"A3349352V"],
  frequency=12, start=c(1982,4))
autoplot(myts)

library(seasonal)
myts %>% seas(x11="") -> fit
autoplot(fit) +
  ggtitle("X11 decomposition of Retail Sales")