suppressMessages(library(fpp2))
library(seasonal)we can see a postive/up trend cicle and sensational increase.
autoplot(plastics)ggseasonplot(plastics) autoplot(plastics %>% decompose(type="multiplicative")) ### c. Do the results support the graphical interpretation from part a?
Yes. we can see the senasational trend on the graph which goes increasing by months. starting low sales on january and goes up.
plastics %>% decompose(type="multiplicative") -> fit
autoplot(plastics, series="Data") +
autolayer(seasadj(fit), series="Seas. Adj.") +
labs(title = "Plastic Sales",
x = "", y = "") +
scale_colour_manual(values=c("blue","green","red"),
breaks=c("Data","Trend","Seas. Adj."))#beginning
outliers_plastic <- plastics
outliers_plastic[1] <- outliers_plastic[1] + 500
autoplot(outliers_plastic %>% decompose(type="multiplicative"))plastics %>% decompose(type="multiplicative") -> fit
autoplot(outliers_plastic, series="Data") +
autolayer(seasadj(fit), series="Seas. Adj.") +
labs(title = "Plastic Sales",
x = "", y = "") +
scale_colour_manual(values=c("blue","green","red"),
breaks=c("Data","Trend","Seas. Adj."))# the middle
outliers_plastic2 <- plastics
outliers_plastic2[30] <- outliers_plastic2[30] + 500
autoplot(outliers_plastic2 %>% decompose(type="multiplicative"))plastics %>% decompose(type="multiplicative") -> fit
autoplot(outliers_plastic2, series="Data") +
autolayer(seasadj(fit), series="Seas. Adj.") +
labs(title = "Plastic Sales",
x = "", y = "") +
scale_colour_manual(values=c("blue","green","red"),
breaks=c("Data","Trend","Seas. Adj."))# at the end
outliers_plastic3 <- plastics
outliers_plastic3[58] <- outliers_plastic[58] + 500
autoplot(outliers_plastic3 %>% decompose(type="multiplicative"))plastics %>% decompose(type="multiplicative") -> fit
autoplot(outliers_plastic3, series="Data") +
autolayer(seasadj(fit), series="Seas. Adj.") +
labs(title = "Plastic Sales",
x = "", y = "") +
scale_colour_manual(values=c("blue","green","red"),
breaks=c("Data","Trend","Seas. Adj."))Yes, it makes a difference depending on where the outliers are. We can see in the graph that where the outliers are located shows an increasing point. it also shows how to affect the sensational pattern on the graph.
retaildata <- readxl::read_excel("retail.xlsx", skip=1)
myts <- ts(retaildata[,"A3349709X"],
frequency=12, start=c(1982,4))
autoplot(myts)myts %>% seas(x11="") -> fit
autoplot(fit) +
ggtitle("X11 decomposition")After comparing both we can see the graph shows both increasing patterns but in the decomposition- sensational we have seen a decrease in the middle and again an increase at the end. in the reminder graph we also can see more clear an increase around 2000 -02 which seems more noticeable after the decomposition.