Time Series Analysis Guide

Time series analysis uncovers patterns in sequential data to forecast future trends, essential for data science, finance, and more. This guide explores components, models, and applications with visualizations.

Key Components

Time series data is decomposed as \( y_t = T_t + S_t + \epsilon_t \).

Trend

Long-term direction, modeled as:

\[ T_t = \alpha + \beta t \]

Example: Sales \( T_t = 1000 + 500t \).

Seasonality

Periodic patterns:

\[ S_t = \sum_{k=1}^{m} \left( a_k \cos\left(\frac{2\pi k t}{P}\right) + b_k \sin\left(\frac{2\pi k t}{P}\right) \right) \]

Noise

Random fluctuations: \( \epsilon_t \sim N(0, \sigma^2) \).

\[ \rho_k = \frac{\text{Cov}(y_t, y_{t-k})}{\text{Var}(y_t)} \]

Forecasting Models

Moving Average

Smooths data:

\[ \hat{y}_t = \frac{1}{k} \sum_{i=t-k}^{t-1} y_i \]

Example: \( \{100, 110, 130\} \), \( \hat{y}_4 = 113.33 \).

Exponential Smoothing

\( \hat{y}_{t+1} = \alpha y_t + (1 - \alpha) \hat{y}_t \):

\[ \hat{y}_{t+1} = 0.3 \cdot 130 + 0.7 \cdot 110 = 116 \]

ARIMA

ARIMA(1,1,1):

\[ y'_t = \phi_1 y'_{t-1} + \epsilon_t + \theta_1 \epsilon_{t-1} \]

Example Analysis

Sales 2025: {1000, 1050, 1120, 1200, 1250}.

Trend

\( T_t = 930 + 64.29t \):

\[ \beta \approx 64.29, \, \alpha \approx 930 \]

Forecasting

MA(2): \( \hat{y}_6 = 1225 \). Trend: \( T_6 \approx 1315 \).

Visualizations

Trend and forecast comparison.

Applications

Finance

Stock forecasting with GARCH:

\[ \sigma_t^2 = \alpha_0 + \alpha_1 r_{t-1}^2 + \beta_1 \sigma_{t-1}^2 \]

Weather

Temperature prediction:

\[ \text{RMSE} = \sqrt{\frac{1}{n} \sum (y_t - \hat{y}_t)^2} \]

Retail

Demand forecasting reduces costs.

Energy

Load forecasting optimizes grids.