Skip to main content

Time Series Decomposition Demo

Explore trend and seasonality in a simple time series decomposition demo. Paste your data, choose a seasonal period and model, and see separate trend, seasonal, and residual components with interactive charts.

For educational purposes only - not for trading, forecasting, or financial advice

Configure Decomposition

Quick Start with Demo Data:

Examples: 7 (weekly in daily), 12 (yearly in monthly), 4 (yearly in quarterly)

Decompose a Time Series into Trend and Seasonality

Paste a simple time series, choose a seasonal period and model, and we'll show you separate trend, seasonal, and residual components with interactive charts. Great for learning time series concepts.

Getting Started:

  1. 1Enter your time series values (one per line or comma-separated)
  2. 2Choose the seasonal length (e.g., 12 for monthly data with yearly seasonality)
  3. 3Select additive or multiplicative model
  4. 4Click "Decompose Time Series" to see the breakdown

Pro tip: Try the demo presets to see how decomposition works with different patterns. This is a simple educational tool — not for forecasting or trading decisions.

Separating Trend From Seasonal Swing in Your Data

Revenue was up 12% in December, and the VP asks whether the business is actually growing or just riding the holiday bump. A raw chart cannot answer that — both the upward trend and the December spike live in the same line. Time series decomposition pulls the line apart into three layers: the trend (is the baseline rising, falling, or flat over months?), the seasonal component (how much does December reliably add every year?), and the residual (the noise left after removing both). Once those layers are separated, you can answer the VP’s question with a number instead of a shrug.

The mistake that derails most first attempts: eyeballing a peak and calling it “growth.” If December always adds 15% and this December added 12%, the trend actually slowed — the seasonal component just masked it. Decomposition strips the mask away so you see the underlying trajectory.

Picking the Right Period for Your Decomposition

The period tells the algorithm how many data points make up one full seasonal cycle. Monthly data with yearly seasonality uses period = 12. Daily data with weekly patterns uses period = 7. Hourly server logs with daily cycles use period = 24. Get the number wrong and the seasonal component absorbs part of the trend or vice versa — every downstream conclusion is then off.

If you are unsure of the period, plot the raw data and count the distance (in data points) between repeating peaks. An autocorrelation plot makes this mechanical: the first strong positive spike after the origin marks the period. For monthly sales data, the spike should appear at lag 12. If it appears at lag 6 instead, you may have a semi-annual pattern, or your data might have two overlapping cycles (quarterly promotions inside a yearly trend).

One trap: choosing a period longer than half your data length. Classical decomposition needs at least two full cycles to estimate seasonal indices reliably. Twelve months of monthly data (period = 12) gives exactly one cycle — not enough. You need at least 24 months, and 36 or more is much better. If your series is too short, the seasonal estimates will be noisy and the residuals will look patterned.

What the Residual Component Is Telling You

The residual is everything the model could not explain with trend and seasonality. If the decomposition did its job, the residual should look like random noise — no visible pattern, no autocorrelation, roughly centred at zero (additive) or at one (multiplicative). That is the sign that you extracted all the structure the data has to offer at this level of complexity.

Patterned residuals are the most useful diagnostic. If you see a clear wave in the residuals, you probably picked the wrong period or missed a second seasonal cycle (daily inside weekly, for example). If the residuals trend upward, the moving-average window was too short to capture a slowly bending trend. If specific months consistently show large residual spikes, there may be a holiday or event effect that the fixed seasonal index cannot represent.

Residuals also flag outliers. A single point with a residual three times the standard deviation of the rest is worth investigating — it could be a data error, a one-time promotion, or a system outage. Classical decomposition does not handle outliers; it simply dumps them into the residual. More advanced methods like STL apply robustness weights to downplay these spikes.

Additive or Multiplicative: Picking the Wrong Model

The seasonal swings in my data are getting bigger over time. Which model?
Multiplicative. In an additive model, the seasonal component adds a fixed amount each December — say, +$50k. In a multiplicative model, December multiplies the trend by a factor — say, 1.20. As the trend rises, 1.20× produces larger absolute swings. If your December spike was $10k in year one and $30k in year three (while the trend tripled), the pattern is multiplicative. A quick check: plot the data. If the seasonal envelope fans out like a trumpet, use multiplicative.

I used additive but the residuals show a pattern that follows the trend. What went wrong?
The additive model subtracted a constant seasonal value from a series whose seasonal swings grew with the level. The leftover growth shows up as patterned residuals — positive residuals in peak months, negative in troughs, scaling with the trend. Switch to multiplicative and the residuals should flatten.

Can I take the log and use additive instead of multiplicative?
Yes. log(Trend × Seasonal × Residual) = log(Trend) + log(Seasonal) + log(Residual), so a multiplicative model on the original scale becomes additive on the log scale. This is a common trick when your tooling supports only additive decomposition. Just remember to exponentiate the components when you present results.

Decomposition Interpretation Pitfalls

The trend line looks flat but the series is clearly rising. Why?
The moving-average window may be too wide, over-smoothing the trend and pushing the real movement into the residual. Try a narrower window. Alternatively, if the rise is entirely seasonal (every Q4 spikes, then drops back), the trend correctly shows no lasting change — the series bounces but never ratchets higher.

Trend strength is 85% and seasonality strength is 90%. Do they add up?
No. Strength measures are not additive shares of variance. Trend strength compares the variance of the detrended series to the original; seasonality strength compares the residual variance to the original. Both can be high simultaneously if the series is dominated by trend and a strong repeating cycle on top of it.

Can I use the decomposition output for forecasting?
Not directly. Classical decomposition describes the past — it does not extrapolate. The trend stops at the last data point, and the seasonal indices assume the pattern repeats unchanged. For forecasting you need a method that projects the trend forward (ARIMA, exponential smoothing, Prophet). But decomposition is a useful first step: it tells you what components to model.

The first and last few trend values are missing. Is that a bug?
No. The centred moving average needs data on both sides of each point. With period = 12, the first 6 and last 6 trend values cannot be computed because there are not enough neighbours. This is an inherent limitation of classical decomposition, not a software error.

Trend, Seasonal, and Residual Decomposition Equations

Two model forms and one trend estimator cover classical decomposition:

Additive model
Yt = Tt + St + Rt
Seasonal indices sum to ≈ 0 across one period
Multiplicative model
Yt = Tt × St × Rt
Seasonal indices average to ≈ 1 across one period
Trend via centred moving average
Tt = (1/m) × Σ Yt−k … Yt+k
where m = period (or period+1 if even, for odd window)
Null at first k and last k points (edge effect)

Units note: in the additive model, T, S, and R share the same units as Y. In the multiplicative model, T is in original units, S and R are dimensionless ratios (1.20 means 20% above trend).

Monthly SaaS Revenue Decomposition Walkthrough

Scenario: You have 36 months of MRR (monthly recurring revenue) for a B2B SaaS product. Revenue grows from $120k to $340k with visible Q4 spikes each year. The seasonal swings appear to grow with the level, so you choose multiplicative decomposition with period = 12.

Step 1 — Estimate trend.
A 13-point centred moving average (period = 12, made odd) smooths away the monthly noise. The trend line rises from about $135k in month 7 to $310k in month 30. The first 6 and last 6 trend values are null.

Step 2 — Detrend and compute seasonal indices.
Divide each observation by its trend value. Group the ratios by month position (January values together, February values together, and so on). Average each group and normalise so the 12 indices average to 1.0. Result: January index = 0.93 (7% below trend), November index = 1.08 (8% above), December index = 1.14 (14% above).

Step 3 — Compute residuals.
Residual = Original / (Trend × Seasonal). Most residual values cluster between 0.95 and 1.05 with no visible pattern — the decomposition captured the main structure. One month shows a residual of 1.18 — a pricing change that boosted revenue beyond the seasonal norm.

Step 4 — Narrate the result.
“Underlying MRR grew roughly 2.5× over three years. Q4 reliably adds 8–14% on top of trend, with December as the strongest month. After removing trend and seasonality, residuals are random except for one anomaly in month 22 — the mid-contract price increase. The business is genuinely growing, not just cycling.”

Sources

Hyndman & Athanasopoulos — Forecasting: Principles and Practice: Classical and STL decomposition methods with additive/multiplicative model selection.

NIST/SEMATECH — Seasonal Decomposition: Moving-average trend estimation and seasonal index computation.

statsmodels — seasonal_decompose: Python implementation of classical decomposition with additive and multiplicative options.

NCBI — Time Series Decomposition in Epidemiology: Practical decomposition application with residual diagnostics and model selection.

Frequently Asked Questions

What is the difference between additive and multiplicative decomposition?

In an additive model, the components add up: Original = Trend + Seasonal + Residual. This is appropriate when seasonal fluctuations are roughly constant regardless of the level of the series. In a multiplicative model, the components multiply: Original = Trend × Seasonal × Residual. This is better when seasonal variations scale with the level (e.g., holiday sales are 20% higher, not a fixed amount). Understanding this helps you see which model to use for your data and why each model is useful.

How do I choose the right seasonal length?

The seasonal length should match your data's periodicity: use 7 for weekly patterns in daily data, 12 for yearly patterns in monthly data, 4 for yearly patterns in quarterly data, or 52 for yearly patterns in weekly data. If you're unsure, plot your data and look for repeating patterns—count the number of periods between peaks. Understanding this helps you see how to choose appropriate seasonal length and why it matters for accurate decomposition.

Why do the trend and seasonal components look strange near the edges?

This is called 'edge effect.' The moving average used to estimate the trend requires values before and after each point. At the beginning and end of the series, there aren't enough neighbors, so the trend cannot be computed there. This is a limitation of simple decomposition methods. Understanding this helps you see why edge effects occur and how to interpret missing trend values.

Can I use this tool to forecast or trade stocks?

No, this is NOT a forecasting or trading tool. It only decomposes past data into components for educational understanding. It does not predict future values, detect market signals, or provide any investment recommendations. For actual forecasting, you would need more sophisticated methods and domain expertise. Understanding this limitation helps you use the tool correctly and recognize when forecasting methods are needed.

What if my data has multiple seasonalities (e.g., daily + weekly)?

This simple decomposition tool only handles a single seasonal pattern. Real-world data often has multiple overlapping seasonalities (e.g., hourly, daily, weekly, yearly). For such cases, you would need more advanced methods like STL decomposition with multiple passes, or specialized models like Prophet. Understanding this limitation helps you use the tool correctly and recognize when advanced methods are needed.

What do the trend and seasonality strength percentages mean?

Trend strength and seasonality strength (both 0-100%) indicate how much of the variance in the original series is explained by each component. High trend strength (>60%) suggests a clear upward or downward direction. High seasonality strength (>60%) suggests clear repeating patterns. These are approximations based on variance ratios. Understanding this helps you see how to interpret strength measures and why they're useful indicators.

Why are my residuals not random / showing patterns?

If residuals show patterns (e.g., autocorrelation, trends, or remaining seasonality), it suggests the decomposition didn't fully capture the series structure. This could happen if: (1) the seasonal length is wrong, (2) the wrong model (additive vs multiplicative) was chosen, (3) there are multiple seasonalities, or (4) the series has structural breaks or outliers. Understanding this helps you see how to diagnose decomposition problems and improve your model.

How many data points do I need?

Ideally, you should have at least 2 full seasonal cycles (e.g., 24 months for monthly data with yearly seasonality). With fewer points, the decomposition becomes unstable and unreliable. The tool will warn you if you have insufficient data. Understanding this helps you see why sufficient data is needed and how to ensure reliable decomposition.

What algorithm does this tool use?

This tool uses classical decomposition with a simple centered moving average for trend estimation and averaging of detrended values for seasonal indices. This is the simplest and most educational approach, but it has limitations compared to modern methods like STL, X-13ARIMA-SEATS, or machine learning approaches. Understanding this helps you see when simple methods are appropriate and when advanced methods are needed.

Is this tool suitable for business decisions?

This is an educational demonstration tool, not a production analytics system. Do not use it as the sole basis for business, financial, or operational decisions. For real analytics, use established statistical software with proper validation, domain expertise, and consideration of uncertainty. Understanding this limitation helps you use the tool for learning while recognizing that business decisions require validated procedures and professional judgment.

Explore More Data Science Tools

Build essential skills in data analysis, statistics, and operations research

Explore All Data Science & Operations Tools

How helpful was this calculator?

Time Series Decomposition - Trend, seasonality, residual