I have a dataset with 3 different Item Numbers, with corresponding 36 months Quantity value. When I run the forecast output, it shows only the cumulative/only the first Item Numbers forecast. I want the output to show the forecast of each individual Item Number(That is Item1 - "004-0013" -> 6 months forecast, followed by Item2- "DP-023-0059"-> 6 months forecast and lastly Item3 -"502-00038R"-> 6 months forecast). Thanks in advance for any help. p.s: This is my first post, so if there is an error in the format of the post, please do let me know.
library('ggplot2')
library('forecast')
library('tseries')
a <- read.csv("high.csv", stringsAsFactors = F)
a$Month <- as.Date(a$Month)
Qty_ts = ts(a[,c('Qty')])
a$Qty_ma12 = ma(a$Qty, order = 3)
Qty_ma = ts(na.omit(a$Qty_ma), start = c(2016,1),end = c(2019),frequency =
12)
decomp = stl(Qty_ma, s.window = "periodic")
deseasonal_Qty <- seasadj(decomp)
plot(decomp)
adf.test(Qty_ma, alternative = "stationary")
Acf(Qty_ma, main="")
Pacf(Qty_ma,main="")
Qty_d1 = diff(deseasonal_Qty, differences =1)
plot(Qty_d1)
adf.test(Qty_d1, alternative = "stationary")
Acf(Qty_d1, main ='ACF for differenced Series')
Pacf(Qty_d1,main ='PACF for Differenced Series')
auto.arima(deseasonal_Qty, seasonal = FALSE)
fit<- auto.arima(deseasonal_Qty, seasonal =FALSE)
tsdisplay(residuals(fit), lag.max=45, main='(0,1,1) Model Residuals')
fit2 = arima(deseasonal_Qty, order =c(1,1,0))
fit2
tsdisplay(residuals(fit2), lag.max=15, main='Seasonal model Residuals')
fcast<- forecast(fit2, h=6)
plot(fcast)
fcast
####Data###
Item.Number Month Qty
1 004-0013 7/1/2017 1
2 DP-023-0059 12/1/2017 1
3 DP-023-0059 1/1/2018 1
4 502-00038R 11/1/2018 73
5 502-00038R 1/1/2019 738
6 502-00038R 6/1/2018 358
7 502-00038R 8/1/2018 751
8 502-00038R 5/1/2018 697
9 502-00038R 9/1/2018 1400
10 502-00038R 7/1/2018 210
11 004-0013 3/1/2018 4
12 004-0013 7/1/2016 4
13 502-00038R 12/1/2018 1832
14 DP-023-0059 12/1/2018 2
15 DP-023-0059 4/1/2017 2
16 DP-023-0059 11/1/2018 3
17 DP-023-0059 5/1/2016 3
18 502-00038R 5/1/2016 197
19 502-00038R 3/1/2018 302
20 502-00038R 2/1/2018 275
21 502-00038R 3/1/2017 291
22 502-00038R 3/1/2016 359
23 004-0013 8/1/2016 9
24 DP-023-0059 6/1/2017 4
25 DP-023-0059 11/1/2016 4
26 DP-023-0059 7/1/2017 4
27 DP-023-0059 9/1/2016 4
28 DP-023-0059 10/1/2017 4
29 DP-023-0059 5/1/2018 4
30 DP-023-0059 8/1/2016 4
31 DP-023-0059 6/1/2016 4
32 DP-023-0059 3/1/2018 4
33 DP-023-0059 2/1/2016 4
34 502-00038R 4/1/2017 365
35 502-00038R 1/1/2017 297
36 502-00038R 6/1/2016 590
37 502-00038R 7/1/2017 380
38 502-00038R 7/1/2016 418
39 502-00038R 10/1/2017 438
40 502-00038R 4/1/2018 288
41 502-00038R 5/1/2017 369
42 502-00038R 4/1/2016 237
43 DP-023-0059 3/1/2016 6
44 DP-023-0059 8/1/2017 5
45 DP-023-0059 2/1/2018 5
46 DP-023-0059 9/1/2017 5
47 DP-023-0059 8/1/2018 5
48 DP-023-0059 4/1/2016 5
49 DP-023-0059 6/1/2018 7
50 DP-023-0059 1/1/2016 6
51 DP-023-0059 7/1/2018 6
52 DP-023-0059 4/1/2018 6
53 DP-023-0059 11/1/2017 6
54 DP-023-0059 7/1/2016 6
55 DP-023-0059 1/1/2017 6
56 DP-023-0059 12/1/2016 6
57 502-00038R 1/1/2018 1483
58 502-00038R 2/1/2016 306
59 502-00038R 9/1/2016 420
60 502-00038R 8/1/2016 534
61 DP-023-0059 2/1/2017 9
62 DP-023-0059 5/1/2017 8
63 DP-023-0059 10/1/2018 8
64 502-00038R 11/1/2017 492
65 502-00038R 8/1/2017 723
66 502-00038R 12/1/2016 445
67 502-00038R 2/1/2017 1544
68 DP-023-0059 9/1/2018 9
69 502-00038R 1/1/2016 619
70 502-00038R 6/1/2017 679
71 502-00038R 9/1/2017 829
72 502-00038R 10/1/2016 517
73 DP-023-0059 3/1/2017 8
74 DP-023-0059 10/1/2016 8
75 502-00038R 12/1/2017 313
76 502-00038R 11/1/2016 867
77 004-0013 11/1/2018 14
78 004-0013 12/1/2018 15
79 004-0013 2/1/2017 14
80 004-0013 1/1/2019 19
81 004-0013 11/1/2016 30
82 004-0013 2/1/2018 13
83 004-0013 3/1/2017 9
84 004-0013 5/1/2017 4
85 004-0013 8/1/2017 15
86 004-0013 7/1/2018 13
87 004-0013 9/1/2016 16
88 004-0013 2/1/2016 17
89 004-0013 10/1/2018 6
90 004-0013 6/1/2018 7
91 004-0013 1/1/2018 6
92 004-0013 4/1/2017 11
93 004-0013 10/1/2017 17
94 004-0013 10/1/2016 21
95 004-0013 5/1/2018 13
96 004-0013 1/1/2017 12
97 004-0013 4/1/2016 24
98 004-0013 6/1/2017 11
99 004-0013 11/1/2017 12
100 004-0013 4/1/2018 14
101 004-0013 3/1/2016 13
102 004-0013 12/1/2016 12
103 004-0013 6/1/2016 16
104 004-0013 1/1/2016 6
105 004-0013 12/1/2017 9
106 004-0013 8/1/2018 12
107 004-0013 9/1/2017 21
108 004-0013 9/1/2018 6
109 004-0013 5/1/2016 12