← 7. Time series
Time Series Decomposition
Try this analysis →

Trend–Seasonal Decomposition and Rolling Statistics for Time Series

Separating the long-run direction and the seasonal effect within a month-to-month difference.

Moving averageAdditive & multiplicative decompositionSTLSeasonal adjustment

JanJulDecJul 2024: 14066Monthly rentals (thousands)Trend 108Seasonal +26Remainder +6140 = 108 + 26 + 6

Suppose we are looking at the monthly number of trips on a city bike-share service. Usage tends to rise in summer and fall in winter, but the service itself may also become more popular year after year.

That is why, just because this July's trip count is higher than last December's, we cannot say the business grew rapidly. The two months fall in different seasons, and they come at different points in the service's operation.

Data recorded in time order like this are called a time series. To understand a time series, you need to separate the trend, which shows the long-run direction; seasonality, which repeats over a fixed cycle; and the remainder that neither of these explains.

On top of that, using rolling statistics such as the moving average and the rolling standard deviation lets you check how persistent and how unstable changes over a given period are. In this article, we use monthly bike-share data to calculate moving averages, additive and multiplicative decomposition, STL, seasonal adjustment, and rolling volatility, and look at how to interpret the results.

SECTION 1

What is different about time series data?

Ordinary cross-sectional data compare the values of many subjects, while time series data look at how the same subject changes over time.

So the order and spacing of observations matter. If you shuffle the order of the monthly trip counts, it becomes hard to see the pattern of rising in spring and falling in winter.

60901201502022202320242025thousandMonthlyTrend
Monthly trips and trend

A time series can show a level, a trend, seasonality, and irregular variation all at once. For example, a bike-share service's average usage might be about 100,000 trips a month, but it grows over the long run, with July–August above average and January–February below. Fluctuations caused by weather or a temporary service outage should be treated separately from these repeating patterns.

Decomposition is first and foremost a tool for understanding the data. The decomposition itself does not guarantee future trip counts or prove the causes of changes in usage.

SECTION 2

Real example: monthly trips on a city bike-share service

Suppose a city tallied bike-share trips for 48 months, from January 2022 to December 2025.

The figures are in thousands of trips.

ItemSetting
Subject observedCitywide bike-share service
PeriodJan 2022 – Dec 2025
FrequencyMonthly, 48 observations
Outcome variableMonthly rentals (thousands)
Seasonal period12 months
Questions of interestIs usage increasing over the long run? How large is the seasonal effect that repeats every year?

The values below are some of the observations, to help understand the example.

TimeRentals (thousands)
Jan 202466
Feb 202471
Mar 202492
Apr 2024110
May 2024123
Jun 2024132
Jul 2024140
Aug 2024138
Sep 2024126
Oct 2024115
Nov 202491
Dec 202476
2024 total1,280

Looking at just these 12 months, you can see a pattern within the year: high in summer and low in winter. But to judge the long-run trend, you need to compare the full 2022–2025 data. Seasonality is not established from a single year's changes; you need to examine whether it repeats across several years.

SECTION 3

How do you identify the trend?

The trend is the direction that persists over a long period once short-term ups and downs are set aside.

For example, suppose the bike-share service's annual trips increased from 960 thousand in 2022 to 1,080 thousand in 2023, 1,280 thousand in 2024, and 1,400 thousand in 2025. These values are evidence that usage has grown over the long run.

2022960 thousand20231,080 thousand20241,280 thousand20251,400 thousand+12.5%+18.5%+9.4%
Annual trips and growth rate
YearAnnual trips (thousands)Year-over-year growth
2022960—
20231,08012.5%
20241,28018.5%
20251,4009.4%

Year-over-year growth is calculated as (this year − previous year) ÷ previous year × 100. The growth rate for 2024 is (1,280 − 1,080) ÷ 1,080 × 100 ≈ 18.5%.

However, using annual totals like this can hide monthly fluctuations. In a real analysis, it is good to plot the raw series together with a smoothly estimated trend line, and to check for level shifts or sudden structural changes.

SECTION 4

What is a moving average?

A moving average is calculated by averaging the observations in a fixed window and then shifting that window forward one time point at a time.

It is used to smooth out short-term fluctuations so that the course of the series is easier to see. For example, trips in April–June 2024 were 110, 123, and 132 thousand, so the 3-month moving average for this window is (110 + 123 + 132) ÷ 3 ≈ 121.7 thousand.

6090120150Apr–Jun window123456789101112June moving average 121.7Month of 2024 →Monthly values3-month trailing moving average
3-month trailing moving average
Reference monthMonths included3-month trailing moving average (thousands)
May 2024Mar–May108.3
Jun 2024Apr–Jun121.7
Jul 2024May–Jul131.7
Aug 2024Jun–Aug136.7

The moving averages in this table are trailing moving averages that use the current month and the two months before it. So the July value is calculated from May–July only and uses no future values. A centered moving average, by contrast, uses observations before and after a given month, so carelessly using it as an input for real-time forecasting can cause future information leakage.

SECTION 5

How do 3-month and 12-month moving averages differ?

The window length of a moving average determines which fluctuations are kept and which are smoothed out.

A 3-month moving average reflects recent changes relatively quickly, but much of the seasonal up-and-down can remain. For monthly data, a 12-month moving average, on the other hand, is useful for smoothing out the annual seasonal cycle but can be slow to show a change in the trend's direction.

60901201502022202320242025thousandRaw data3-month6-month12-month
Moving averages by window length
WindowAdvantagesCautions
3-monthResponds quickly to recent changesSeasonal fluctuations may remain
6-monthSmooths short-term fluctuations moreSomewhat slow to detect turning points
12 monthsUseful for smoothing the annual seasonal cycleMore points at both ends cannot be calculated, and it responds slowly to change

Since 12 months is an even-length window, traditional classical decomposition can use a centered trend obtained through two stages of moving averages. But the 12-month moving average itself is not always an accurate seasonally adjusted value. When observations are irregularly spaced or the seasonal pattern changes, a different approach is needed.

SECTION 6

How does time series decomposition work?

Time series decomposition splits observations into trend, seasonality, and remainder.

The typical structures are additive decomposition and multiplicative decomposition.

Additive: Yt = Tt + St + Rt

Multiplicative: Yt = Tt × St × Rt

Additive Y = T + S + RConstant swingMultiplicative Y = T × S × RSwing proportional to level
Additive and multiplicative decomposition

An additive model can be suitable when the absolute size of the seasonal swings is similar regardless of the level. For example, if summer usage is roughly 20,000 trips higher every year, an additive structure is intuitive. On the other hand, if the gap between summer and winter grows in proportion as usage grows, you can consider a multiplicative structure.

Multiplicative decomposition is generally used with positive data. When a log transformation is possible, you can also take logs to handle a multiplicative relationship in additive form. But if the data include zeros, be especially careful with how logs and transformations are handled.

SECTION 7

What is STL decomposition, and why use it?

STL (Seasonal and Trend decomposition using Loess) estimates trend and seasonality using local regression (LOESS).

Its advantage over classical decomposition is that it can flexibly handle situations where the seasonal pattern changes gradually.

Raw series Y40 ~ 180Trend T60 ~ 140Seasonal S-40 ~ 40Remainder R-16 ~ 162022202320242025
Four panels of the decomposition

STL provides an additive decomposition by default. So if the seasonal swings grow in proportion to usage, you can consider an appropriate transformation, such as a log transformation.

The main settings include the seasonal period, the smoothness of the seasonal component, the smoothness of the trend component, and a robust decomposition option that reduces the influence of outliers. When analyzing an annually repeating pattern in monthly data, it is natural to set the period to 12.

However, 48 months of data contain only four annual cycles, which limits how precisely you can judge the stability of the seasonal pattern and the long-run trend. STL results should be treated as estimates that describe the data rather than as established facts.

SECTION 8

How do you read the numbers in a decomposition table?

Suppose trips in July 2024 were 140 thousand, and the STL estimates for that month were as follows.

ComponentJuly 2024 value (thousands)Interpretation
Trend (T)108Baseline usage expected over the long run
Seasonal (S)+26The recurring seasonal effect of July
Remainder (R)+6Difference not explained by trend and seasonality
Actual trips (Y)140108 + 26 + 6
Trend T108+Seasonal S+26+Remainder R+6=Actual Y, July 2024140 thousand
Decomposition of July 2024

Since an additive decomposition is used here, 140 = 108 + 26 + 6. A seasonal component of +26 thousand for July means the model estimated a pattern in which that month's trips run about 26 thousand above the trend level for seasonal reasons.

The remainder of +6 thousand is the difference that trend and seasonality could not explain. However, it cannot be immediately interpreted as the effect of a specific event, because many factors, such as weather conditions, events, service outages, and data errors, can affect the remainder.

SECTION 9

How is seasonal adjustment done?

Seasonal adjustment removes recurring seasonal effects so that changes between time points are easier to compare.

In an additive decomposition, you subtract the estimated seasonal component from the actual observation.

YtSA = Yt − St = Tt + Rt

60901201502022202320242025thousandJul 2024: 140Seasonally adjusted 114Raw data YSeasonally adjusted Y − SS = +26
Before and after seasonal adjustment

In the July 2024 example above, actual trips were 140 thousand and the seasonal component was +26 thousand, so seasonally adjusted trips are 140 − 26 = 114 thousand.

This figure shows "the level with July's seasonal boost removed." It does not mean only 114 thousand trips were actually taken. Also, seasonally adjusted values can still include temporary shocks and estimation error, so they should not be confused with the trend component.

SECTION 10

What does the rolling standard deviation show?

Besides the moving average, rolling statistics also include the rolling standard deviation.

The rolling standard deviation shows how much the observations have fluctuated over a recent fixed period. For example, if trips over the last 3 months were 110, 123, and 132 thousand, the sample standard deviation is about 11.1 thousand. Unlike the mean, this figure summarizes the size of the fluctuations in that window.

010203020222023202420253-month rolling standard deviationRaw YRemainder
Rolling standard deviation

However, in strongly seasonal data such as bike usage, a high rolling standard deviation of the raw observations does not necessarily mean the service has become more unstable. Volatility may look large simply because of seasonal rises and falls.

If the goal is to spot abnormal fluctuations, it may be more appropriate to look at the rolling standard deviation of the remainder after removing trend and seasonality. Even then, you should also examine the window length and the influence of outliers.

SECTION 11

Which graphs and diagnostics should you look at together?

The structure of a time series decomposition often shows up better in graphs than in tables.

A decomposition plot that stacks the raw series, trend, seasonality, and remainder from top to bottom lets you compare the size of each component and how it changes over time.

Visualization / diagnosticQuestion to check
Raw seriesIs there a long-run rise or decline, or any odd spikes or drops?
Trend plotHas the direction or slope of the trend changed?
Seasonal componentIs there a pattern that repeats at similar times?
Remainder plotDo unexplained outliers or structure remain?
ACF (remainder autocorrelation)Does temporal dependence remain after decomposition?
Rolling standard deviationDoes the level of volatility change over time?

If a clear seasonal pattern or autocorrelation persists in the remainder, the chosen decomposition method may not have adequately explained the structure of the data. However, a descriptive decomposition can be useful even if the remainder is not perfect white noise. How important remainder diagnostics are depends on the purpose of the analysis.

SECTION 12

Points to watch in the analysis

Distinguish the observation frequency from the seasonal period.

A 12-month cycle in monthly data differs from a roughly 52-week cycle in weekly data, and daily data can have multiple patterns, such as day-of-week and annual seasonality. Basic STL, which handles only one seasonal period at a time, cannot explain every kind of complex seasonality.

Check how the moving average is aligned in time.

A centered moving average can use past and future observations together, so in real-time forecasting or policy evaluation, take care that future information does not get mixed in.

Do not interpret trend and seasonality as causes.

High summer usage does not let you conclude that temperature alone is the cause, and a rising trend does not let you conclude that marketing was effective. Causal relationships require a separate study design.

With short data, decomposition results can be unstable.

In 48 months of data, the annual seasonal cycle repeats only four times. To judge in detail whether seasonality has changed, a longer observation period helps.

Distinguish forecasting from descriptive decomposition.

Decomposition is useful for understanding a time series, but by itself it does not prove the performance of a forecasting model. If forecasting is the goal, you need separate time series validation and an evaluation of forecast error.

SECTION 13

How do you report the results?

When reporting a trend and seasonality analysis, it is good to state clearly the subject and period observed, the observation frequency, the seasonal period, the decomposition method, the window lengths of the rolling statistics, and the key figures.

If there were log transformations, outlier treatment, or adjustments for missing values, you should also describe those steps.

Example report

To analyze the monthly usage pattern of a city bike-share service, trip counts for the 48 months from January 2022 to December 2025 were examined. Annual trips increased from 960 thousand in 2022 to 1,400 thousand in 2025, confirming long-run growth in usage. To examine the annually repeating pattern in the monthly data, an additive STL decomposition with a 12-month seasonal period was applied.

Actual trips in July 2024 were 140 thousand, with an estimated trend component of 108 thousand, a seasonal component of +26 thousand, and a remainder of +6 thousand. The resulting seasonally adjusted trips for July were 114 thousand. These results show that the summer increase in usage is related to a recurring seasonal pattern and needs to be interpreted separately from the long-run upward trend in usage.

In real studies, it is good to present the full time series, the decomposition plots, and the remainder diagnostics together.

✓Wrap-up

Change becomes visible only once you separate trend from seasonality

The mere fact that one point in a time series is high or low makes it hard to judge whether a long-run change has occurred.


This is because observations mix trend, seasonality, and temporary fluctuation together.

Moving averages smooth out short-term wobbles to show the overall course, and decomposition methods such as STL help you interpret observations by splitting them into trend, seasonality, and remainder. Seasonal adjustment makes values from different months easier to compare, and the rolling standard deviation summarizes the level of fluctuation over a given period.

However, decomposition describes the patterns that appear in the data; it does not prove the causes of change or accurately predict the future. It is important to choose the period, cycle, and decomposition method that fit the purpose of the analysis and to check the results together with the raw data.

KEY TAKEAWAY

The key is not to take month-to-month differences at face value, but to read them by separating the long-run direction from the recurring seasonal effect.