Index
Time Series Analysis
🕒 Time Series Analysis: Basics
🔹 What is a Time Series?
A time series is a sequence of data points indexed in time order. Typically, the data is collected at consistent intervals (e.g., daily stock prices, hourly temperature, monthly sales).
Example:
Time Temperature (°C)
---------------------------
01:00 22.1
02:00 22.3
03:00 21.8
04:00 21.2
🔹 Why Analyze Time Series?
Time series analysis is used for:
- Forecasting (e.g., predicting future stock prices)
- Trend detection (e.g., increasing or decreasing behavior over time)
- Anomaly detection (e.g., detecting faults in equipment)
- Seasonal behavior (e.g., sales rising every December)
🧱 Components of a Time Series
Time series data is usually decomposed into the following key components:
1. Trend (Tt)
A long-term increase or decrease in the data. It doesn't have to be linear.
Example:
Gradual increase in global temperatures over years.
2. Seasonality (St)
A repeating pattern at regular intervals (hourly, daily, monthly, yearly).
It’s caused by seasonal factors like weather, holidays, habits, etc.
Example:
Higher ice cream sales in summer months every year.
3. Cyclic Patterns (Ct)
==These are long-term oscillations not fixed to a calendar.
Cycles are influenced by economic conditions, business cycles,== etc.
Difference from seasonality:
Seasonality is fixed and periodic; cycles are irregular and non-fixed.
4. Noise/Irregular (Et)
==Random variations or residuals left after removing other components.
Unpredictable and caused by unexpected or rare events== (e.g., pandemic).
📊 Types of Time Series Models
-
Additive Model:
Assumes the components add together:
Yt = Tt + St + Ct + Et -
Multiplicative Model:
Assumes the components multiply together:
Yt = Tt × St × Ct × Et
Use additive if the seasonal fluctuations remain constant in magnitude.
Use multiplicative if fluctuations increase with the level of the series.
🧠 Other Key Concepts
✅ Stationarity
A stationary time series has constant statistical properties over time (mean, variance, autocorrelation).
Stationarity is often required for many forecasting models (like ARIMA).
✅ Lag
How many steps back in time you’re comparing data.
Lag helps in autocorrelation and feature engineering.
✅ Autocorrelation
How related current values are with past values in the series.
Helpful for modeling dependencies over time.
🧩 Real-World Applications
- Weather prediction
- Stock market forecasting
- Sales forecasting
- Network traffic monitoring
- Energy consumption trends
Periodicity Analysis
🚩 What Is Periodicity?
Periodicity is when a time series repeats a pattern at regular intervals. These intervals are called the period. Common examples:
- Daily temperature patterns
- Seasonal sales trends (e.g., spikes during Diwali or Christmas)
- Traffic congestion patterns during weekdays
If trends show an upward or downward movement, periodicity shows cyclic up-and-down movements at fixed durations.
🧠 Intuition
Imagine you’re tracking the number of coffee sales at a cafe every hour. You’ll likely see spikes in the morning and late afternoon — repeating every day. That’s a daily periodicity.
🔍 Identifying Periodicity
There are three key ways to detect periodicity:
-
Visual Inspection: Plot the time series. Look for repeating patterns.
-
Autocorrelation Function (ACF):
- Measures how similar the series is with itself at different lags.
- High ACF at a lag = possible periodicity at that interval.
-
Fourier Transform:
- Converts time series from time-domain to frequency-domain.
- Helps us spot dominant frequencies (or periods).
- Output: Frequencies with high amplitudes indicate repeating cycles.