Consider the following code:
library(forecast) library(lubridate) # Create random walk with growing tendency and decreasing tendency after 182 days a <- c(rnorm(182, 0, 100), rnorm(204, 0, 100)) b <- c(seq(1000, 3000, length.out = 182), seq(3000, 1000, length.out = 204)) y <- a + b date <- seq(as.Date('2019-01-01'), as.Date('2020-01-21'), by='day') data <- data.frame(date = date, y = y) # Plot data ggplot()+ geom_line(data = data, aes(x = date, y = y)) # I want to consider yearly and weekly seasonal periods datats <- msts(data$y, seasonal.periods = c(365.25, 7), start = decimal_date(as.Date(date))) # Create arima model with seasonal differences model <- auto.arima(datats, max.d = 1, D = 1, seasonal.test = 'ch') # Plot forecast plot(forecast(model, 100))
The prediction of this model is really bad. I would like a prediction which decreases as the recent days, but at the same time it takes into account the anual seasonality. I don't know how to do this, because it seems that the model don't keep the tendency. Obviously, this artificial data has an exaggerated peak. But what happens if I have a data that has a growing tendency, and then it decreases? Will I be able to keep the recent tendency and consider the year seasonality as well?
Thank you very much.