## Time-Series [1:60] from 1 to 5.92: 742 697 776 898 1030 ...
## $x
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
## 1 742 697 776 898 1030 1107 1165 1216 1208 1131 971 783
## 2 741 700 774 932 1099 1223 1290 1349 1341 1296 1066 901
## 3 896 793 885 1055 1204 1326 1303 1436 1473 1453 1170 1023
## 4 951 861 938 1109 1274 1422 1486 1555 1604 1600 1403 1209
## 5 1030 1032 1126 1285 1468 1637 1611 1608 1528 1420 1119 1013
##
## $seasonal
## Jan Feb Mar Apr May Jun Jul
## 1 0.7670466 0.7103357 0.7765294 0.9103112 1.0447386 1.1570026 1.1636317
## 2 0.7670466 0.7103357 0.7765294 0.9103112 1.0447386 1.1570026 1.1636317
## 3 0.7670466 0.7103357 0.7765294 0.9103112 1.0447386 1.1570026 1.1636317
## 4 0.7670466 0.7103357 0.7765294 0.9103112 1.0447386 1.1570026 1.1636317
## 5 0.7670466 0.7103357 0.7765294 0.9103112 1.0447386 1.1570026 1.1636317
## Aug Sep Oct Nov Dec
## 1 1.2252952 1.2313635 1.1887444 0.9919176 0.8330834
## 2 1.2252952 1.2313635 1.1887444 0.9919176 0.8330834
## 3 1.2252952 1.2313635 1.1887444 0.9919176 0.8330834
## 4 1.2252952 1.2313635 1.1887444 0.9919176 0.8330834
## 5 1.2252952 1.2313635 1.1887444 0.9919176 0.8330834
##
## $trend
## Jan Feb Mar Apr May Jun Jul
## 1 NA NA NA NA NA NA 976.9583
## 2 1000.4583 1011.2083 1022.2917 1034.7083 1045.5417 1054.4167 1065.7917
## 3 1117.3750 1121.5417 1130.6667 1142.7083 1153.5833 1163.0000 1170.3750
## 4 1208.7083 1221.2917 1231.7083 1243.2917 1259.1250 1276.5833 1287.6250
## 5 1374.7917 1382.2083 1381.2500 1370.5833 1351.2500 1331.2500 NA
## Aug Sep Oct Nov Dec
## 1 977.0417 977.0833 978.4167 982.7083 990.4167
## 2 1076.1250 1084.6250 1094.3750 1103.8750 1112.5417
## 3 1175.5000 1180.5417 1185.0000 1190.1667 1197.0833
## 4 1298.0417 1313.0000 1328.1667 1343.5833 1360.6250
## 5 NA NA NA NA NA
##
## $random
## Jan Feb Mar Apr May Jun Jul
## 1 NA NA NA NA NA NA 1.0247887
## 2 0.9656005 0.9745267 0.9750081 0.9894824 1.0061175 1.0024895 1.0401641
## 3 1.0454117 0.9953920 1.0079773 1.0142083 0.9990100 0.9854384 0.9567618
## 4 1.0257400 0.9924762 0.9807020 0.9798704 0.9684851 0.9627557 0.9917766
## 5 0.9767392 1.0510964 1.0498039 1.0299302 1.0398787 1.0628077 NA
## Aug Sep Oct Nov Dec
## 1 1.0157335 1.0040354 0.9724119 0.9961368 0.9489762
## 2 1.0230774 1.0040674 0.9962088 0.9735577 0.9721203
## 3 0.9969907 1.0132932 1.0314752 0.9910657 1.0258002
## 4 0.9776897 0.9920952 1.0133954 1.0527311 1.0665946
## 5 NA NA NA NA NA
##
## $figure
## [1] 0.7670466 0.7103357 0.7765294 0.9103112 1.0447386 1.1570026 1.1636317
## [8] 1.2252952 1.2313635 1.1887444 0.9919176 0.8330834
##
## $type
## [1] "multiplicative"
##
## attr(,"class")
## [1] "decomposed.ts"
str(plastics) autoplot(plastics) +xlab(‘year’)+ theme(text = element_text(family = “corben”,color=‘#249382’,size=12),panel.background = element_rect(fill = ‘#f4f4ef’))
#compute multiplicative decomposition traditional_multiplicative<-decompose(plastics,type=“multiplicative”) traditional_multiplicative plastics %>% decompose(type=“multiplicative”) %>% autoplot(color=‘#249382’) + xlab(“Year”) + ggtitle(“classical multiplicative decomposition of product a, plastics”)+ theme(text = element_text(family = “corben”,color=‘#249382’,size=12),panel.background = element_rect(fill = ‘#f4f4ef’)) #seasonally adjust the plastics set autoplot(plastics, series=“Data”) + autolayer(seasadj(traditional_multiplicative), series=“Seasadj”,size=1) + xlab(“Year”) + ylab(“Sales”) + ggtitle(“Plastics, Product a (seasonally adjusted)”) + scale_colour_manual(values=c(“Data”=“#baa9f9”,“Seasadj”=“#2267d8”), breaks=c(“Data”,“Seasadj”))+ theme(panel.background = element_rect(fill = ‘#f4f4ef’),panel.grid.major = element_blank(), panel.grid.minor = element_blank(),text = element_text(family = “corben”,color=‘#2267d8’,size=12))
plastics[26]<-1100
traditional_multiplicative<-decompose(plastics,type=“multiplicative”) autoplot(plastics, series=“Data”) + autolayer(seasadj(traditional_multiplicative), series=“Seasadj”,size=1) + xlab(“Year”) + ylab(“Sales”) + ggtitle(“Plastics, high outlier at low of cycle”) + scale_colour_manual(values=c(“Data”=“#baa9f9”,“Seasadj”=“#55a9d1”), breaks=c(“Data”,“Seasadj”))+ theme(panel.background = element_rect(fill = ‘#f4f4ef’),panel.grid.major = element_blank(), panel.grid.minor = element_blank(),text = element_text(family = “corben”,color=‘#55a9d1’,size=12))
plastics[26]<-793 plastics[29]<-1600
traditional_multiplicative<-decompose(plastics,type=“multiplicative”) autoplot(plastics, series=“Data”) + autolayer(seasadj(traditional_multiplicative), series=“Seasadj”,size=1) + xlab(“Year”) + ylab(“Sales”) + ggtitle(“Plastics, high outlier at middle of cycle”) + scale_colour_manual(values=c(“Data”=“#baa9f9”,“Seasadj”=“#55a9d1”), breaks=c(“Data”,“Seasadj”))+ theme(panel.background = element_rect(fill = ‘#f4f4ef’),panel.grid.major = element_blank(), panel.grid.minor = element_blank(),text = element_text(family = “corben”,color=‘#55a9d1’,size=12))
plastics[29]<-1204 plastics[33]<-2000
traditional_multiplicative<-decompose(plastics,type=“multiplicative”) autoplot(plastics, series=“Data”) + autolayer(seasadj(traditional_multiplicative), series=“Seasadj”,size=1) + xlab(“Year”) + ylab(“Sales”) + ggtitle(“Plastics, high outlier at top of cycle”) + scale_colour_manual(values=c(“Data”=“#baa9f9”,“Seasadj”=“#55a9d1”), breaks=c(“Data”,“Seasadj”))+ theme(panel.background = element_rect(fill = ‘#f4f4ef’),panel.grid.major = element_blank(), panel.grid.minor = element_blank(),text = element_text(family = “corben”,color=‘#55a9d1’,size=12))
plastics %>% decompose(type=“multiplicative”) %>% autoplot(color=‘#249382’) + xlab(“Year”) + ggtitle(“multiplicative decomposition, high outlier at top of cycle”)+ theme(text = element_text(family = “corben”,color=‘#5574d1’,size=12),panel.background = element_rect(fill = ‘#f4f4ef’))
plastics[33]<-1000
traditional_multiplicative<-decompose(plastics,type=“multiplicative”) autoplot(plastics, series=“Data”) + autolayer(seasadj(traditional_multiplicative), series=“Seasadj”,size=1) + xlab(“Year”) + ylab(“Sales”) + ggtitle(“multiplicative decomposition, low outlier at top of cycle”) + scale_colour_manual(values=c(“Data”=“#baa9f9”,“Seasadj”=“#55a9d1”), breaks=c(“Data”,“Seasadj”))+ theme(panel.background = element_rect(fill = ‘#f4f4ef’),panel.grid.major = element_blank(), panel.grid.minor = element_blank(),text = element_text(family = “corben”,color=‘#55a9d1’,size=12))
plastics %>% decompose(type=“multiplicative”) %>% autoplot(color=‘#249382’) + xlab(“Year”) + ggtitle(“classical multiplicative decomposition of product a, plastics”)+ theme(text = element_text(family = “corben”,color=‘#5574d1’,size=12),panel.background = element_rect(fill = ‘#f4f4ef’))
retaildata <- readxl::read_excel(“C:/Users/dawig/Desktop/Data624/retail.xlsx”, skip=1) turnover <- ts(retaildata[,“A3349608L”], frequency=12, start=c(1982,4)) autoplot(turnover, ylab=“turnover”, xlab=“”)+ theme(panel.background = element_rect(fill = ‘#efeae8’))+ ggtitle(“clothing, footwear and personal accessory turnover series”)+ theme(text = element_text(family = “corben”,color=‘#249382’,size=12),panel.background = element_rect(fill = ‘#f4f4ef’)) turnover %>% seas(x11=“”) -> fit autoplot(fit) + ggtitle(“X11 decomposition of clothing, footwear and personal accessory turnover”)+ theme(text = element_text(family = “corben”,color=‘#249382’,size=12),panel.background = element_rect(fill = ‘#f4f4ef’))