# Time series analysis vs linear regression

I am working on developing an algorithm which will predict the future traffic for the restaurant. I am confuse that which of the two: Linear regression or time series analysis I should use as the base for my algorithm. The features I am using are: Day,whether there was festival,temperature,climatic condition , current rating,whether there was holiday,service rating,number of reviews etc.

Please guide me how should I proceed . Also how can I optimize my algorithm so that it can learn with time.

The data you are having is panel data which is a combination of both cross sectional data and Time series.

You can try with regression models by giving time stamp to your data .Like maintaining one feature based your weekday (1 to 7).or if you have trends and seasonality in your data you can go to giving week number as feature like (0 to 53) weeks.

Why do you not try both? Test the accuracy of the methods in your test and cross validation set. Use learning curves related techniques to come to a experimental logical conclusion. Remember, this is data "science"!

I think Linear regression is more feasible than time series analysis here, becasuse I think you have lots of categorical variables, and time series analysis works better with purely numeric data.

Many of your categorical vriables are likely to be NA, and many might have high cardinality and thus might not be suited for one-hot-encoding. So you have to choose an algorithm that can handle NA values well and can deal with many unique categorical variables turned into indicator variables. You can also handle this with appropriate preprocessing.

Also you didn't tell use whether your dataset has sub-daily (e.g. hourly) or daily resolution. I think daily resolution is too coarse (weather may change several times per day), guest arrivals may peak in the morning or evening. So time series analysis shines when you want to determine, say, the periodicity (which is likely on an hourly scale for the workdays most restaurants), but your variables seem to be on the daily level and less predictable.

A time series model such as SARIMAX would likely be the best option, but under a few conditions. Most important is having historic data on restaurant traffic. Say that the restaurant opened a while ago but next month it will become very popular for some reason not captured by your data, one of the most important predictors for todays traffic will be the last few days of traffic - this would not be present in a linear regression unless you transformed the variable into a moving average or similar, at which point you're just replicating the inherent functionality of a time series model.

SARIMAX requires a long history of training data however, as it needs to learn that, for instance, if your restaurant is an ice cream shop, the yearly seasonality would likely imply that august shows higher demand for ice cream than december. You have a predictor for temperature, which sort of covers that, but seasonality would be more robust. Weekly seasonality is also important, as there's probably higher demand on saturday than tuesday.

So essentially, if you have enough historic data and believe that there is a trend in traffic (going up or down instead of randomly distributed) use time series. Otherwise, sounds like you have a decent enough set of predictors to make a linear regression, just try to transform your predictors to take the time-series nature of your data into account