Skip to content

Latest commit

 

History

History
 
 

Time_Series_Forecasting

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Time Series Forecasting in Python

Description:

Time series forecasting is use for scientific predictions based on historical time stamped data. Building or developing models through historical data analysis and using them to make observations and drive future strategic decision-making.

Time series analysis is a statistical technique that analyze time series data or trend data. Time series data is a group of observations on a single entity over time; for example, the daily closing prices over one year for a single financial security.

Purpose:

To make the data from non-stationary to time series stationary.

ARIMA Models

ARIMA (Auto Regressive Integrated Moving Average) is a class of models that explains a given time series based on its own past values. The lags and the lagged forecast errors is the equation that can be used to forecast future values.

ARIMA model has 3 characterized terms: p, d, q.

The 'p' is the order of the AR term, 'q' is the order of the MA term, and 'd' is the number of differencing required to make the time series stationary.

If a time series, has seasonal patterns, then you need to add seasonal terms and it becomes SARIMA, short for ‘Seasonal ARIMA’. More on that once we finish ARIMA.

In time series, the first step to build an ARIMA model is to make the time series stationary. The most common method is to defference it. For example, subtract the previous value from the current value. However, the data might need more than one differencing because the complexity of the series. The value of 'd' is the minimum number of differencing needed to make the series stationary. If the time series is already stationary, then d = 0. The 'p' is the order of the 'Auto Regressive' (AR) term and is the number of lags of Y to be used as predictors. The 'q' is the order of the 'Moving Average' (MA) term and is the number of lagged forecast errors that should go into the ARIMA Model.

Auto Regressive (AR only) model Equations:

Moving Average (MA only) model is one where Yt depends only on the lagged forecast errors.

Moving Average (MA only) model Equations:

Error Terms

Error terms are the errors of the autoregressive models of the respective lags.

Error Terms Equations:

ARIMA

ARIMA is a model where the time series was differenced at least once to make it stationary; therefore, you combine the AR and the MA terms.

ARIMA Equations:

Libraries:

Darts

https://github.com/unit8co/darts
from darts import TimeSeries
from darts.models import ExponentialSmoothing

Orbit

https://orbit-ml.readthedocs.io/en/stable/
https://github.com/uber/orbit
import orbit
from orbit.eda import eda_plot

Prophet

https://facebook.github.io/prophet/
https://github.com/facebook/prophet
from prophet import Prophet

Pastas

https://pastas.readthedocs.io/en/latest/index.html
https://github.com/pastas/pastas
import pastas as ps

PyAF

https://github.com/antoinecarme/pyaf
import pyaf.ForecastEngine as autof

Author

* Tin Hang

🔴 Warning: This is not financial advisor. Do not use this to invest or trade. It is for educational purpose.