I am using a Kaggle dataset on noise complaints in NYC (https://www.kaggle.com/somesnm/partynyc/version/4) as a teaching example.
The time series has exact time and date of the noise complaint but for illustrative purposes I am collapsing the time information and only consider number of noise complaints per day.
I am showing here the raw time-series and the classical decomposition into season, trend, and remainder.
auto.arima() from the forecast package, suggests an ARIMA (3,1,0)(2,0,0) solution. This picks up nicely on the weekly trend in the data (more noise complaints on the weekends).
What surprises me is that when I forecast the data for a whole year, I am getting the weekly pattern, but the forecast converges to the mean.
Why does it not pick up the pattern that exists over the year (more noise complaints in the summer month, when people are outside). Do I need to restructure the time series object to not have frequency 7 (and instead have frequency (seasonality) of something else? Or can I add a second seasonality component? Or do I simply need to observe more than one year of data?
Thanks so much!
After you download the kaggle data, you should be able to reproduce the code below.
#here I first extract a date column, discarding the time information party$Created.Date <- as.character(mdy_hm(party$Created.Date)) party$date <- substr(party$Created.Date,1,10) #then I sort the dataset, and remove one observation from 2015, so that I #only have 2016 partydf <- arrange_all(data.frame(table(party$date)))[2:367,] #then I create the ts object, and define the week as the seasonal frequency #hence the number in the timeseries represents the week of the year 2016 #(1=first week, until 53) partyts <- ts(partydf$Freq,start=c(1,1),frequency = 7) aarm <- auto.arima(partyts,stepwise = FALSE,approximation = FALSE, trace=TRUE,lambda = 0) summary(aarm) autoplot(aarm) partyfore <- forecast(aarm,h=106) autoplot(partyfore,conf.int = FALSE)