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.

classical decomposition

auto.arima() from the forecast package, suggests an ARIMA (3,1,0)(2,0,0)[7] 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?

enter image description here

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)
partyfore <- forecast(aarm,h=106)
autoplot(partyfore,conf.int = FALSE)
  • $\begingroup$ Does auto.arima allow for multiple seasonality? I note that the forecast package by Hyndman handles multiple seasonality in its mstl function, not arima. You might try that. See cran.r-project.org/web/packages/forecast/forecast.pdf $\endgroup$ – zbicyclist Apr 19 '18 at 13:33
  • $\begingroup$ auto.arima doesn;t work effectively when you have deterministic structure such as multiple trends or outliers or changes in parameters or changes in error variance over time. $\endgroup$ – IrishStat Apr 19 '18 at 19:48
  • $\begingroup$ Thanks both of you - the first comment motivated me to find this (robjhyndman.com/publications/complex-seasonality) by Hyndman, which actually seems to address my issue. ARIMA (and auto.arima) do not handle multiple seasons, but an approach called TBATS apparently does. $\endgroup$ – Felix Thoemmes Apr 19 '18 at 20:09
  • $\begingroup$ You may want to look at the tbats and the bats tags. $\endgroup$ – Stephan Kolassa May 26 '18 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.