9
$\begingroup$

As a side hobby, I have been exploring forecasting time series (in particular, using R).

For my data, I have the number of visits per day, for every day going back almost 4 years. In this data there are some distinct patterns:

  1. Monday-Fri has a lot of visits (highest on Mon/Tue), but drastically less on Sat-Sun.
  2. Certain times of the year drop (i.e. many less visits around U.S. Holidays, summers show less growth)
  3. Significant growth year-to-year

It would be nice to be able to forecast an upcoming year with this data, and also use it to have seasonally adjusted month-to-month growth. The main thing that throws me off with a monthly view is:

  • Certain months will have more Mon/Tue than other months (and that isn't consistent over years either). Therefore a month that happens to more weekdays needs to be adjusted accordingly.

Exploring weeks also seems difficult since the week numbering systems change from 52-53 depending on the year, and it seems ts doesn't handle that.

I'm pondering taking an average for the weekdays of the month, but the resulting unit is a bit strange (Growth in Avg. Weekday Visits) and that would be dropping data which is valid.

I feel this sort of data would be common in time series, (say for example electricity usage in office building might be something like this), anyone have any advice on how to model it, in particular, in R?

The data I am working with is pretty straight forward, it starts like:

            [,1]
2008-10-05 17607
2008-10-06 36368
2008-10-07 40250
2008-10-08 39631
2008-10-09 40870
2008-10-10 35706
2008-10-11 18245
2008-10-12 23528
2008-10-13 48077
2008-10-14 48500
2008-10-15 49017
2008-10-16 50733
2008-10-17 46909
2008-10-18 22467

and continues like this up to the present, with an overall trend of growth, some dips around US holiday weeks, and growth generally slowing during the summer.

$\endgroup$
  • $\begingroup$ Another interesting aspect to the data is that there are sudden events that interrupt the overall trend of growth by a period of ~ couple months. Right now though, where I am at the stage of trying to properly set seasonality, I am ignoring that aspect. $\endgroup$ – Kyle Brandt Feb 21 '12 at 17:38
  • $\begingroup$ Also, correct me if I am not using "seasonality" correctly. I am currently thinking of it a patter within the time unit I say. So "Weekly Seasonality" to me means "A pattern that repeats every week". $\endgroup$ – Kyle Brandt Feb 21 '12 at 17:40
  • $\begingroup$ Hmm, sounds familiar (-; $\endgroup$ – user88 Feb 21 '12 at 18:16
  • $\begingroup$ See answers to stats.stackexchange.com/questions/14742/…. Might be a starting point. $\endgroup$ – Peter Ellis Feb 21 '12 at 20:15
  • $\begingroup$ Maybe at the heart of this is the combination of week + year? It seems ts (and even msts) doesn't fit a sampling period of a week with a "natural" period of a year (Nor do calendars really I guess). Or, I just don't understand how to make that work... $\endgroup$ – Kyle Brandt Feb 21 '12 at 20:45
4
$\begingroup$

I model thus kind of data all the time. You need to incorporate

  • day-of-the-week
  • holiday effects ( lead , contemporaneous and lag effects )
  • special days-of-the-month
  • perhaps Friday before a holiday or a Monday after a holiday
  • weekly effects
  • monthly effects
  • ARIMA structure to render the errors white noise;
  • et.al. .

The statistical approach is called Transfer Function Modelling with Intervention DEtection. If you want to share your data either privately via dave@autobox.com or preferably via SE , I would be more than glad to actually show you the specifics of a final model and further your ability to do it yourself or at least to help you and others to understand what needs to be done and what can be done. In either case you come out smarter without spending any treasure be it coin or time.You might read some of my other responses to time series questions to learn more.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.