I am trying to check and plot accuracy of an ARIMA model on out-of-sample (test) data.
I have following time series.
> ts.all
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2014 145 135 137 137 120 119 188 130 119 140 125 126
2015 186 174 178 239 189 181 270 174 228 270 247 190
2016 236 203 193 250 178 214 242 174 194 210 160 184
2017 182 164 177 250 170 222 268 279 196 264 241 218
2018 252 203 160 263 169 165
EDIT: output of dput(ts.all)
> dput(ts.all)
structure(c(145, 135, 137, 137, 120, 119, 188, 130, 119, 140,
125, 126, 186, 174, 178, 239, 189, 181, 270, 174, 228, 270, 247,
190, 236, 203, 193, 250, 178, 214, 242, 174, 194, 210, 160, 184,
182, 164, 177, 250, 170, 222, 268, 279, 196, 264, 241, 218, 252,
203, 160, 263, 169, 165), .Tsp = c(2014, 2018.41666666667, 12
), class = "ts", .Names = c("Gross_Orders_Invoiced1", "Gross_Orders_Invoiced2",
"Gross_Orders_Invoiced3", "Gross_Orders_Invoiced4", "Gross_Orders_Invoiced5",
"Gross_Orders_Invoiced6", "Gross_Orders_Invoiced7", "Gross_Orders_Invoiced8",
"Gross_Orders_Invoiced9", "Gross_Orders_Invoiced10", "Gross_Orders_Invoiced11",
"Gross_Orders_Invoiced12", "Gross_Orders_Invoiced13", "Gross_Orders_Invoiced14",
"Gross_Orders_Invoiced15", "Gross_Orders_Invoiced16", "Gross_Orders_Invoiced17",
"Gross_Orders_Invoiced18", "Gross_Orders_Invoiced19", "Gross_Orders_Invoiced20",
"Gross_Orders_Invoiced21", "Gross_Orders_Invoiced22", "Gross_Orders_Invoiced23",
"Gross_Orders_Invoiced24", "Gross_Orders_Invoiced25", "Gross_Orders_Invoiced26",
"Gross_Orders_Invoiced27", "Gross_Orders_Invoiced28", "Gross_Orders_Invoiced29",
"Gross_Orders_Invoiced30", "Gross_Orders_Invoiced31", "Gross_Orders_Invoiced32",
"Gross_Orders_Invoiced33", "Gross_Orders_Invoiced34", "Gross_Orders_Invoiced35",
"Gross_Orders_Invoiced36", "Gross_Orders_Invoiced37", "Gross_Orders_Invoiced38",
"Gross_Orders_Invoiced39", "Gross_Orders_Invoiced40", "Gross_Orders_Invoiced41",
"Gross_Orders_Invoiced42", "Gross_Orders_Invoiced43", "Gross_Orders_Invoiced44",
"Gross_Orders_Invoiced45", "Gross_Orders_Invoiced46", "Gross_Orders_Invoiced47",
"Gross_Orders_Invoiced48", "Gross_Orders_Invoiced49", "Gross_Orders_Invoiced50",
"Gross_Orders_Invoiced51", "Gross_Orders_Invoiced52", "Gross_Orders_Invoiced53",
"Gross_Orders_Invoiced54"))
I have figured out an ARIMA model (using ACF/differencing/auto.arima/seasonality testing etc.), and do the forecast like this
ts.train = window(ts.all, start = c(2014,1), end = c(2017,6))
ts.test = window(ts.all, start = c(2017,7))
fit.train = arima(ts.train, order=c(1,1,0),seasonal = c(0,1,1))
pred.train = forecast(fit.train, h=12)
autoplot(ts.train) + autolayer(pred.train)
The last line throws following error
Error: Invalid input: date_trans works with objects of class Date only
I had a look at here and here, but I am at a loss on how to format the date part of my time series or how to modify the autolayer
function to resolve this.
Version info:
R version 3.4.4 (2018-03-15)
Package: forecast
Version: 8.4
Package: ggplot2
Version: 3.0.0
PS: I have tried similar ARIMA prediction on goog
which is daily time series in package fpp2
. The autolayer
function works there.
Edit: I am not particularly behind autoplot
and autolayer
functions, base graphics or any other functions/libraries are fine, however, I want to scale the labels on y axis (to show 1,000,000 as 1m) and need to show minor breaks on x-axis for each month and major breaks for each quarter, both of which I have already figured out for ggplot
/autoplot
.