10  FAQ - Time Series

Q: How do I know if my data is suitable for ARIMA or Prophet? Which one should I use?

A: ARIMA is suitable for data that can be made stationary through transformations like differencing. It works well with data that lacks a strong seasonal component. Prophet is ideal for data with strong seasonal patterns and can handle daily, weekly, and yearly seasonality, as well as holiday effects.

In short:

Use ARIMA if:

  • Your data is stable and can be made stationary through transformations.
  • You have expertise in statistical analysis and can fine-tune model parameters.
  • You don’t need to account for complex seasonal patterns or holiday effects.

Use Prophet if:

  • Your data has strong seasonal variations or unusual holiday effects.
  • You prefer an easier, more automatic approach to model fitting.
  • You need to handle large datasets or include external variables in your forecasts.

Q: How can I check if my time series data is stationary?

A: Stationarity can be checked using statistical tests such as the Augmented Dickey-Fuller (ADF) test. In Python, this can be performed using the adfuller method from the statsmodels library. A p-value less than 0.05 generally suggests that the series is stationary.

However, there are alternative tests to the ADF tests. You may be interested in the Zivot-Andrews Test. This test is a variation of the traditional unit root tests that allows for a single structural break in the series. It’s particularly useful when the data may have been influenced by a one-time structural shift, such as an economic policy change or the Covid-19 pandemic. A small p-value suggests that the series is stationary when accounting for a structural break.

Documentation

Q: What are the ‘p’, ‘d’, and ‘q’ parameters in ARIMA?

A: In ARIMA models:

  • ‘p’ is the order of the autoregressive part and refers to the number of lags of the series included in the model.
  • ‘d’ is the degree of differencing required to make the series stationary.
  • ‘q’ is the order of the moving average part and refers to the number of lagged forecast errors included in the model.

Q: How do I forecast future data using Prophet?

A: After fitting your model to historical data, use the make_future_dataframe method to create future dates, and then call predict to generate forecasts. Prophet will provide a DataFrame with predictions and components of the forecasts.

Q: What should I do if my model gives inaccurate forecasts?

A: Model inaccuracy can often be improved by:

  • Checking data quality and ensuring no critical data is missing.
  • Reevaluating model parameters (e.g., adjusting p, d, q in ARIMA or tweaking seasonality settings in Prophet).
  • Increasing the amount of training data.
  • Considering external variables or additional regressors in Prophet.

Q: How can I evaluate the performance of my forecasting model?

A: Common metrics to evaluate forecasting models include the Mean Absolute Error (MAE), Mean Squared Error (MSE), and Root Mean Squared Error (RMSE). These metrics provide information on the average magnitude of the forecasts’ errors.

Q: Can I use both ARIMA and Prophet on the same dataset?

A: Yes, it can be beneficial to compare forecasts from both models to determine which provides better accuracy or to combine (ensemble) their forecasts for potentially better results.