1. Time-series data understanding & pre-processing
Time series data pre-processing is the key step to converting raw data into processed data that can be effectively analyzed and help in gaining critical insights out it.
Convert 'object' dtype to 'datetime' dtype
2. Time-series decomposition
The time-series data can be modeled as an addition or product of trend, seasonality, cyclical, and irregular components.
The additive time-series model is given by
Yt = Tt + St + Ct + It
The multiplicative time-series model is given by
Yt = Tt x St x Ct x It
Where Tt = Trend component St = Seasonality Ct = cyclical component It = irregular component
Let's look at the code below
3. Time-series data analysis and visualization
3.1 Comparative analysis of the stock prices of companies within the same industry
Comparative analysis of stock prices refers to comparing the performance of one or more stocks in a given market or industry over a specific period
The goal of this analysis is to understand how stocks are performing relative to each other and to identify trends, patterns, and relationships between them.
3.2 Growth of the stock prices over 5 years
The growth of stock prices refers to the increase in the value of a stock over some time. It is an important metric for investors to consider when making investment decisions, as it can indicate the potential return on investment.
The commonly used formula for calculating the growth of stock price is as below:
Rate of return = (Ending price — Starting price) / Starting price
Rate of return over a period of 5 years
4. Forecasting using ARIMA models
ARIMA (AutoRegressive Integrated Moving Average) models are a class of time-series forecasting models that are commonly used for modeling and predicting future values of time-series data.
ARIMA models capture the autoregressive element, the difference element, and the moving average element of time-series data to make predictions.
5. Stationarity test using statsmodels library
The AR and MA models can only be used if the time series is stationary. the I elements help to build forecasting models on non-stationary time series.
ARIMA models are used when the time-series data is non-stationary. time-series data is called stationary if the mean, variance, and covariance are constant over time.
We can set up the null hypothesis and alternate hypothesis as below to test dicky-fuller test.
H0: Time series is non-stationary
Ha: Time series is a stationary
If the p-value is less than 0.05 then we will reject the null hypothesis and accept the alternative hypothesis.