1
$\begingroup$

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?

$\endgroup$
  • 2
    $\begingroup$ 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. $\endgroup$ – tchakravarty May 9 '14 at 8:49
  • $\begingroup$ 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 <- stl(USAccDeaths,s.window="periodic");plot(forecast(fit)) see also ?auto.arima $\endgroup$ – David Arenburg May 9 '14 at 9:20
  • 1
    $\begingroup$ arima captures seasonality, and auto.arima. This question displays no research effort. $\endgroup$ – Rich Scriven May 9 '14 at 9:24
  • $\begingroup$ @fg nu I would love to see that review. $\endgroup$ – Dimitriy V. Masterov May 9 '14 at 11:47
  • 2
    $\begingroup$ What makes you think that ARIMA doesn't capture seasonality? Seasonal ARIMA is explicitly designed to do just that. $\endgroup$ – Glen_b -Reinstate Monica Jun 13 '14 at 10:21
2
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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/

$\endgroup$
-1
$\begingroup$

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.

$\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.