Autolayer not placing data at correct time stamp

i appreciate this is not a reprex apologies, but i am struggling to work out why the data is not plotting for the correct time. it seems to default to plotting for the start of 2015 instead of in may. as a result the attempt to autolayer over the arima forecast is not working. any help appreciated thanks

df.train.ts <- msts(df.train[,-3], seasonal.periods = c(7,365.25), start=c(2013,01,01))

df.test.ts <- msts(df.validation[,-3], seasonal.periods = c(7,365.25), start = c(2015,5, 25) )

forecast3 <- forecast::forecast(fit3, h=218)
forecast3 %>%
autoplot() + autolayer(df.test.ts[,2])

The start argument should be a vector of two elements: the year, and the period of the major seasonal period (in this case that is the year). Any additional elements of start are ignored. So start = c(2013,01,01) is interpreted as the first day of 2013, while start = c(2015,5, 25) is interpreted as the fifth day of 2015. This corresponds to your graph.

You would find it much easier to use a tsibble object rather than a ts object, as you can have an explicit date index. Then you can use the fable package instead of the forecast package to produce forecasts.

See Forecasting: Principles and Practice (3rd ed) for lots of examples.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.