Time Series Analysis
âšī¸ Why It Matters
Time series appear everywhere: stock prices, sensor data, user traffic, weather records, GDP growth. Unlike cross-sectional data, time series have temporal structure â trends, seasonality, and autocorrelation â that requires specialized methods. Understanding these patterns is crucial for forecasting, anomaly detection, and understanding dynamic systems. Ignoring temporal structure leads to invalid inference and poor predictions.
Overview
A time series decomposes into four components: trend (long-term direction), seasonality (fixed-period patterns like daily or yearly cycles), cyclical (irregular long-term fluctuations), and noise (random variation). Most time series methods require stationarity â constant mean and variance over time. The ADF test checks for a unit root (non-stationarity). The ARIMA framework applies differencing to achieve stationarity, autoregressive terms to capture dependence on past values, and moving-average terms to capture dependence on past errors. ACF/PACF plots guide model order selection. Once fitted, the model extrapolates future values, but confidence intervals widen with forecast horizon.
Key Concepts
ARIMA(p, d, q) Model
Here,
- =Autoregressive polynomial: $1 - \phi_1 B - \cdots - \phi_p B^p$
- =Differencing operator of order d
- =Moving average polynomial: $1 + \theta_1 B + \cdots + \theta_q B^q$
- =White noise error: $\epsilon_t \sim N(0, \sigma^2)$
Backshift Operator
Here,
- =Backshift (lag) operator
AR(1) Model
Here,
- =Autoregressive coefficient; $|\phi| < 1$ for stationarity
MA(1) Model
Here,
- =Moving average coefficient
Exponential Smoothing (Simple)
Here,
- =Smoothing parameter ($0 < \alpha < 1$)
Time Series Components
| Component | Description | Example |
|---|---|---|
| Trend | Long-term direction | Increasing user base |
| Seasonality | Fixed-period pattern | Daily traffic peaks at noon |
| Cyclical | Irregular long-term swings | Business cycles (years) |
| Noise | Random variation | Weather fluctuations |
ACF/PACF Pattern Guide
| Model | ACF Pattern | PACF Pattern |
|---|---|---|
| AR(p) | Tails off (exponential/sinusoidal) | Cuts off after lag p |
| MA(q) | Cuts off after lag q | Tails off |
| ARMA(p,q) | Tails off | Tails off |
Quick Example
đInterpreting ADF Test
ADF test on a time series: statistic = -1.2, p-value = 0.85.
Cannot reject the null of a unit root. The series is non-stationary. Apply differencing ( in ARIMA) until the ADF p-value < 0.05.
After first differencing: ADF statistic = -4.5, p-value = 0.001. Now stationary â use ARIMA with .
đARIMA Order Selection
ACF cuts off after lag 1 â MA(1). PACF cuts off after lag 2 â AR(2). ACF tails off, PACF cuts off after lag 2 â AR(2). Use AIC to choose between competing models â lower AIC = better fit penalized for complexity.
Key Takeaways
đSummary: Time Series Analysis
- Four Components: Trend, seasonality, cyclical, noise. Identifying these guides model selection.
- Stationarity: Required for most models. Constant mean and variance over time. Test with ADF test.
- ARIMA: AR (autoregressive lags) + I (differencing for stationarity) + MA (moving average of errors). Select order via ACF/PACF or AIC.
- Backshift Operator: simplifies notation. removes trends of order .
- Forecasting: Extrapolate with
forecast(steps=10), but confidence intervals widen with horizon â shorter forecasts are more reliable. - Workflow: Plot series â test stationarity â difference if needed â identify ARIMA order â fit â validate residuals â forecast.
- Seasonal Extension: SARIMA adds seasonal AR, I, and MA terms for periodic patterns.
Deep Dive
For detailed explanations, worked examples, and Python implementations, explore the dedicated statistics lessons:
Stationarity
- Time Series Stationarity â ADF test, KPSS test, differencing strategies, and achieving stationarity
Model Identification
- ACF and PACF â Autocorrelation and partial autocorrelation functions for identifying ARIMA order with examples
ARIMA Models
- ARIMA Models â Fitting, diagnostics, forecasting, order selection, and Python implementation
Seasonal Models
- Seasonal Decomposition â STL decomposition, seasonal patterns, trend estimation, and decomposition methods
Smoothing Methods
- Exponential Smoothing â Simple, double, and triple (Holt-Winters) exponential smoothing for forecasting
Causality
- Granger Causality â Testing whether one time series helps predict another
Related Topics
- Standard Error â How SE applies to time-dependent data
- Regression Assumptions â Autocorrelation violates independence; see Durbin-Watson test
- Heteroscedasticity â Non-constant variance in time series