1

We have three years of data for online visits at a daily level. We want to forecast the daily visits for the next 90 days. What would be the best method to capture weekday seasonality , holiday seasons, and also the drift.

Can this be successfully done in R? We are currently using R. We have considered ARIMA but it does not capture seasonality.

While converting the data to a time series in R, what should be the "frequency"?

Should we use ARIMA with regressors?

Ana
  • 11
  • 2
  • 2
    Ana, please post a sample of your data. You can capture seasonality using the S(easonal)ARMA (look at the `astsa` R package) or P(eriodic)ARMA (as covered in the `partsm` R package) class of models. Complex (multiresolution) seasonality can be captured using, for example, Hyndman's `tsbats()` function. Forecasting daily time series is not something that there is a lot of literature on, but I will try to post a short literature survey if time permits. – tchakravarty May 09 '14 at 08:49
  • @fg nu I would love to see that review. – dimitriy May 09 '14 at 11:47
  • Try `forecast` library it has a feature to combine Loess decomposition (`stl()`) with its `forecast()` function. Try the follwing: `install.packages("forecast");library(forecast);fit – David Arenburg May 09 '14 at 09:20
  • 1
    `arima` captures seasonality, and `auto.arima`. This question displays no research effort. – Rich Scriven May 09 '14 at 09:24
  • 2
    What makes you think that ARIMA doesn't capture seasonality? Seasonal ARIMA is explicitly designed to do just that. – Glen_b Jun 13 '14 at 10:21
  • http://stats.stackexchange.com/questions/124533/transfer-function-in-forecasting-models-interpretation/125732#125732 presents a discussion regarding daily forecasts and hourly forecasts. Your problem is simpler .. just days ...so follow the discussion regarding ARTMAX models and identifying lad and lag effects around holidays,level shifts, ARMA structure etc. – IrishStat Nov 28 '14 at 02:16

3 Answers3

2

In addition to what has been said, you might want to consider structural time series models. They account explicitly for one or more seasonalities and trend, and are very tolerant of missing data. A good starting point might be the R function StructTS(). More complex models can be fit with packages such as dlm, KFAS, and several others.

F. Tusell
  • 7,733
  • 19
  • 34
0

Yes. You can use the ARIMAX Model.

ARIMAX stands for Auto regressive Moving average with External variable. For incorporating weekday seasonality and holiday seasons, you can create dummy variables with 1 and 0 values to fulfill each variables conditions.

In R, you can use the packages TSA and FORECAST. The model command is

arimax(x, order = c(0, 0, 0), seasonal = list(order = c(0, 0, 0), period = NA)))

Regarding your second question, While converting the data to a time series in R, what should be the "frequency"?Since you have daily data, your command to convert the data into a timeseries is

data.ts=ts(data$date, start=c(start_year,start_date), frequency=365) 

Read more about models here - http://www.r-bloggers.com/forecasting-with-daily-data/ and http://www.r-bloggers.com/the-arimax-model-muddle/

RHelp
  • 111
  • 3
-1

I am not sure whether I can define the solution, but for periodic/seasonal data/series you can use Hidden Markov Model, it can easily handle the periodic behavior. Let say that one day is one state with a particular model (e.g. you somehow characterize days with a model) and trans. probabilities are the probs. of transitions from one state to another.