Back to Resources
Analytics

Time Series Analysis: Methods, Models, and Real-World Applications

Saad Selim
May 4, 2026
14 min read

Time series analysis is the study of data points collected sequentially over time. Unlike cross-sectional data (a snapshot at one moment), time series data has a temporal ordering that carries information. Past values influence future values, and understanding these temporal patterns enables forecasting, anomaly detection, and causal inference.

Every business generates time series data: daily revenue, monthly active users, hourly server requests, weekly inventory levels. The methods in this guide help you decompose these series into interpretable components, build predictive models, and make better decisions with temporal data.

Components of a Time Series

Any time series can be decomposed into four fundamental components:

1. Trend

The long-term direction of the series (upward, downward, or flat). Trends capture structural changes like market growth, population increase, or gradual technology adoption.

Example: A SaaS company's monthly recurring revenue (MRR) showing steady 5% month-over-month growth over three years.

2. Seasonality

Regular, predictable patterns that repeat at fixed intervals. The key feature is that the interval is known and constant.

Examples:

  • Retail sales peak in November-December every year
  • Restaurant traffic peaks at lunch and dinner daily
  • B2B SaaS usage dips on weekends
  • Utility demand peaks in summer (AC) and winter (heating)

3. Cyclicality

Longer-term fluctuations that are not tied to a fixed calendar period. Cycles have variable length and are often driven by economic or business factors.

Examples:

  • Business cycles (expansion and recession) lasting 2-10 years
  • Real estate market cycles
  • Commodity price cycles

Key distinction from seasonality: Seasonal patterns have a fixed, known period (12 months, 7 days). Cycles have irregular, unknown periods.

4. Residual (Noise)

The random variation remaining after removing trend, seasonality, and cycles. In a good model, residuals should be random (no remaining pattern).

Decomposition Models

Additive model: Y(t) = Trend + Seasonal + Residual

Use when seasonal fluctuations are roughly constant in magnitude over time.

Multiplicative model: Y(t) = Trend x Seasonal x Residual

Use when seasonal fluctuations grow proportionally with the level of the series (common in business data).

from statsmodels.tsa.seasonal import seasonal_decompose

result = seasonal_decompose(series, model='multiplicative', period=12)
result.plot()

Stationarity: The Foundation

Most time series models require stationarity, meaning the statistical properties (mean, variance, autocorrelation) do not change over time.

A stationary series has:

  • Constant mean (no trend)
  • Constant variance (no heteroscedasticity over time)
  • Autocovariance that depends only on lag, not on time position

Why it matters: Non-stationary data violates the assumptions of most statistical models, leading to spurious results (e.g., two unrelated series with upward trends will appear correlated).

Testing for Stationarity

Augmented Dickey-Fuller (ADF) Test:

  • H0: Series has a unit root (non-stationary)
  • H1: Series is stationary
  • If p-value < 0.05: reject H0, series is stationary

KPSS Test:

  • H0: Series is stationary
  • H1: Series has a unit root
  • If p-value < 0.05: reject H0, series is NOT stationary

Using both tests together provides more confidence. If ADF rejects and KPSS fails to reject, you have strong evidence of stationarity.

from statsmodels.tsa.stattools import adfuller, kpss

adf_result = adfuller(series)
print(f'ADF p-value: {adf_result[1]}')

kpss_result = kpss(series, regression='c')
print(f'KPSS p-value: {kpss_result[1]}')

Making a Series Stationary

Differencing: Subtract the previous value from the current value. First differencing removes linear trends. Second differencing removes quadratic trends. Seasonal differencing (subtracting the value from the same period last year) removes seasonal patterns.

Log transformation: Stabilizes variance when fluctuations grow with level.

Combined: Log first (stabilize variance), then difference (remove trend).

Classical Forecasting Methods

Moving Averages

The simplest smoothing technique. Replace each data point with the average of surrounding points.

Simple Moving Average (SMA): Average of the last k observations. Good for removing noise but introduces lag.

Weighted Moving Average: More recent observations get higher weights.

Exponential Smoothing

A family of methods that weight recent observations more heavily, with weights decaying exponentially into the past.

Simple Exponential Smoothing (SES): For series with no trend or seasonality. One parameter (alpha) controls how quickly weights decay.

Holt's Linear Method: Extends SES to handle trends. Two parameters: alpha (level smoothing) and beta (trend smoothing).

Holt-Winters Method: Extends further to handle seasonality. Three parameters: alpha, beta, and gamma (seasonal smoothing). Comes in additive and multiplicative variants.

from statsmodels.tsa.holtwinters import ExponentialSmoothing

model = ExponentialSmoothing(
    series,
    trend='mul',
    seasonal='mul',
    seasonal_periods=12
).fit()
forecast = model.forecast(steps=12)

ARIMA Models

ARIMA (AutoRegressive Integrated Moving Average) is the workhorse of classical time series analysis. It combines three components:

AR (AutoRegressive, p): The current value depends on p previous values.

  • AR(1): Y(t) = c + phi1 * Y(t-1) + error
  • AR(2): Y(t) = c + phi1 * Y(t-1) + phi2 * Y(t-2) + error

I (Integrated, d): The number of times the series is differenced to achieve stationarity.

  • d=0: already stationary
  • d=1: first differencing applied
  • d=2: differenced twice (rare)

MA (Moving Average, q): The current value depends on q previous error terms.

  • MA(1): Y(t) = c + error(t) + theta1 * error(t-1)

ARIMA(p, d, q) notation specifies all three. For example, ARIMA(1,1,1) means:

  • One autoregressive term
  • One round of differencing
  • One moving average term

Selecting p, d, q

d: Use ADF/KPSS tests. Difference until stationary (usually d=0 or d=1, rarely d=2).

p and q: Examine ACF (autocorrelation function) and PACF (partial autocorrelation function) plots:

  • ACF cuts off at lag q: suggests MA(q) component
  • PACF cuts off at lag p: suggests AR(p) component
  • Both tail off gradually: suggests mixed ARMA model

Automated selection: Use AIC/BIC to compare models. The auto_arima function in pmdarima (Python) or forecast::auto.arima (R) searches across combinations.

import pmdarima as pm

model = pm.auto_arima(
    series,
    seasonal=True,
    m=12,
    stepwise=True,
    suppress_warnings=True
)
print(model.summary())
forecast = model.predict(n_periods=12)

SARIMA: Seasonal ARIMA

SARIMA extends ARIMA to handle seasonality: SARIMA(p,d,q)(P,D,Q,m)

  • (p,d,q): non-seasonal components
  • (P,D,Q,m): seasonal components with period m

Example: SARIMA(1,1,1)(1,1,1,12) for monthly data with yearly seasonality.

Modern Approaches

Prophet (Meta/Facebook)

Designed for business time series with strong seasonality and holiday effects. Uses an additive decomposition model with automatic changepoint detection.

Strengths: Handles missing data, outliers, holidays. Intuitive parameters. Good for daily/weekly business data.

Weaknesses: Not always competitive with well-tuned ARIMA on clean data. Assumes additive structure.

Machine Learning Methods

Gradient boosting (XGBoost, LightGBM): Treat forecasting as a supervised learning problem. Engineer lag features, rolling statistics, calendar features. Often wins competitions.

Neural networks (LSTM, Transformer): Deep learning models can capture complex temporal patterns. N-BEATS, Temporal Fusion Transformer, and TimesFM represent the state of the art. Best for large datasets with many series.

Comparison

MethodBest ForData NeedsInterpretability
Exponential SmoothingSimple series, quick forecasts2+ seasons of historyHigh
ARIMA/SARIMAUnivariate series with complex autocorrelation50+ observationsModerate
ProphetBusiness data with holidays and changepoints1+ year of daily dataHigh
Gradient BoostingMultiple explanatory variables available1000+ observationsLow-Moderate
Deep LearningMany related series, complex patterns10,000+ observationsLow

Evaluating Forecast Accuracy

Metrics

MAE (Mean Absolute Error): Average absolute difference between forecast and actual. Same units as the data. Easy to interpret.

RMSE (Root Mean Squared Error): Penalizes large errors more heavily than MAE. Use when big misses are costly.

MAPE (Mean Absolute Percentage Error): Percentage-based. Comparable across series with different scales. Undefined when actual values are zero.

SMAPE (Symmetric MAPE): Addresses MAPE asymmetry. Bounded between 0% and 200%.

Backtesting (Time Series Cross-Validation)

Never use random train/test splits for time series. Use expanding or sliding window cross-validation:

  1. Train on data up to time t
  2. Forecast time t+1 to t+h
  3. Move forward one period
  4. Repeat

This mimics real forecasting conditions where you only have past data available.

Practical Applications

Demand Forecasting

Predicting product demand for inventory management. Retailers use SARIMA or ML models with promotional calendars, weather data, and economic indicators.

Capacity Planning

Forecasting server load, call center volume, or manufacturing capacity needs. Under-forecasting causes outages; over-forecasting wastes resources.

Financial Forecasting

Revenue projection, cash flow modeling, budget planning. Often combines time series models with business assumptions (new product launches, pricing changes).

Anomaly Detection

Using time series models to define "expected" ranges and flagging actual values that fall outside confidence intervals. Critical for monitoring infrastructure, fraud detection, and quality control.

Time Series Analysis in Modern Analytics

Analytics platforms like Skopx enable teams to perform time series analysis through natural-language queries. Instead of writing ARIMA code, an analyst can ask "forecast next quarter's revenue based on the last three years" or "detect anomalies in our daily sign-up rate." The platform handles decomposition, model selection, and validation automatically while still exposing the underlying statistical reasoning.

The key insight for practitioners: the best forecasting model depends on your data characteristics (length, frequency, seasonality patterns, number of series) and your operational needs (accuracy requirements, interpretability, update frequency). Start simple (exponential smoothing), add complexity only when justified by improved accuracy on held-out data.

Summary

Time series analysis decomposes temporal data into trend, seasonality, cyclicality, and noise. Stationarity is the foundation for most models. Exponential smoothing handles simple patterns; ARIMA/SARIMA captures complex autocorrelation structures; modern ML methods excel with large datasets and many features. Always validate with time-respecting cross-validation, and choose methods based on data characteristics and interpretability needs rather than complexity for its own sake.

Share this article

Saad Selim

The Skopx engineering and product team

Stay Updated

Get the latest insights on AI-powered code intelligence delivered to your inbox.