I am new in R and time series analysis and need some help. I am currently trying to create a tool to forecast the demand of power for a company. On my data set I have 17550 observations that correspond to the demand on the last 17550 hours.

My approach to the problem was to try fit a time series with a multi seasonality approach. I tried using Fourier series terms as regressors, and as a first step I am checking the AIC values for certain combinations of the number of terms.

my code so far is:

Demand = head(MyData$Value,-1000)

aic_vals_temp <- NULL
aic_vals <- NULL

y1 <- msts(Demand,seasonal.periods=c(24, 168, 8766),ts.frequency=24)

for (i in 1:4) {
 for (j in 1:4){
  for (z in 1:4){

    z1 <- fourier(y1, K=c(i,j,z))
    fitma1 <- auto.arima(y1,D=0,max.P=0,max.Q=0,xreg=z1)
    aic_vals_temp <- cbind(i,j,z,fitma1$aic)
    aic_vals <- rbind(aic_vals,aic_vals_temp)

I want to test the influence of last day, last week and last year information. Am I doing this correctly so far? I have noticed that it takes a lot of time to get the AIC values.

Thanks a lot for your help in advance.

  • $\begingroup$ Hi Nick, There are acres of literature on multiple time series. Can you tell us a bit more about the precise nature of the multiple seasonality, as the answer will depend on that. $\endgroup$ Oct 6, 2017 at 14:09
  • $\begingroup$ i am assuming that the demand for power for this company depends on what happened yesterday, a week ago and a year ago. The assumption is totally arbitrarily. $\endgroup$ Oct 6, 2017 at 14:13
  • $\begingroup$ I would say rule number one is don't make arbitrary assumptions. I would suggest that you begin by visually analysing the data to see what the pattern actually is. A simple Excel line chart is the best place to start. I would also suggest that you investigate what the real-world causes of the variation in seasonality are (e.g. - "we spike at 11am because the widget production line runs, then we dip at 12:30 because the operators are having their lunch", etc. Once you've qualitatively analysed the data, then you can think about quantitative modelling. (1 of 2) $\endgroup$ Oct 6, 2017 at 14:53
  • $\begingroup$ You might be surprised by how simple the model you need actually is. In any case, you can't say anything sensible about what model you should be using until you understand in broad, non-technical terms, what the seasonality pattern actually is and, ideally, the real-world underlying causes. I will post this as an answer. (2 of 2) $\endgroup$ Oct 6, 2017 at 14:57

2 Answers 2


What you need to do is to identify whether or not there is an hourly effect , a daily effect, a monthly effect , a day-of-the-month effect , a week-of-the-month effects, lead and lag effects around holidays , long-weekend effects , level shifts , multiple trends and of course memory effects. All of this has to be simultaneously while taking into account pulses and possible changes in model error variance over time. http://autobox.com/cms/index.php/afs-university/intro-to-forecasting/doc_download/53-capabilities-presentation slide 41- may help you understand this kind of approach. This is always easier when there is domain knowledge about possibly known other external events that may have contributed to variation.


Per the comments thread above - it is too early to be looking at sophisticated data modelling until you have actually examined the underlying nature of the demand variation. Look at the data series and examine the patterns visually before you worry about that - otherwise, you're putting the cart before the horse.

In terms of models for dealing with multiple seasonality, it really depends on the nature of the multiple seasonality (which is why you have to understand that first). Some examples of models include the TBATS model of Hyndman & De Livera, and various "quadruple exponential smoothing models". For nested seasonality, depending on the nature of the nesting, you can use a triple-exponential-smoothing model like Holt-Winters, but change the date referenced for the seasonality to (t-s+1), instead of t-s. E.g. t-364 instead of t-365.

That's my two cents.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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