Rolling Statistics
A way to follow a time series by repeatedly calculating the mean and spread over the most recent stretch of time.
Orders jump in one month and drop again the next. Can you tell whether sales are growing just by looking at numbers that go up and down like this? Can you tell whether the swings have gotten bigger lately?
Time series data mix long-term change with short-term wobbles. If you look only at one overall mean, it's easy to miss when a change began or what's happening recently.
Rolling statistics calculate a mean or standard deviation from only the data in a recent stretch of time, then shift that stretch forward through time to see how things change. They are useful for smoothing out the flow of observations or comparing recent spread.
In this guide we'll use monthly order counts for an online store as an example and go step by step through how moving averages and rolling standard deviations work, how window length changes the results, and how to read the charts and results table.
What are rolling statistics?
You repeat the same calculation while moving the time point forward bit by bit.
Imagine calculating a mean once every month. In March you use January–March, in April February–April, and in May March–May. A statistic calculated while moving a fixed window forward one time point at a time is called a rolling statistic.
The most widely used are the moving average and the rolling standard deviation. The moving average smooths out short-term swings so you can see the overall direction, and the rolling standard deviation shows how much recent values vary.
Why do you need rolling statistics?
They focus on recent changes that an overall mean easily hides.
If you calculate only the mean order volume over three years, the low early volumes and the high recent volumes are merged into a single number. A moving average, on the other hand, lets you see whether the level rose at a particular point and whether an upward trend is continuing.
A rolling standard deviation shows which of two periods with similar means was more unstable. But it is only a descriptive summary; it doesn't automatically tell you about statistical significance or the causes of variation.
How are the moving average and rolling standard deviation calculated?
At each time point, only a fixed number of observations are used.
3-month trailing moving average
The moving average for March is the mean of the January, February and March order counts, and the moving average for April is the mean of the February, March and April counts. A trailing moving average generally uses only current and past observations.
If January has 182 orders, February 188 and March 194, the 3-month moving average for March is (182 + 188 + 194) ÷ 3 = 188 orders.
Rolling standard deviation
It calculates how far the values in the same window are from their mean. This guide uses the sample standard deviation (ddof = 1) of each window. With a 3-month window, three valid observations must accumulate before the first result appears.
Worked example: monthly orders at an online store
We use 36 months of data to look at both the recent trend and the wobbles.
Suppose an online store recorded its order count every month from January 2023 to December 2025. Monthly orders don't rise smoothly. Some months, such as the vacation season or the end of the year, have more or fewer orders than usual.
First, treat the monthly order counts as the original series and calculate the 3-month moving average and rolling standard deviation. The data are hypothetical monthly data created to explain the method.
| Item | Setting |
|---|---|
| Observation period | January 2023 – December 2025 |
| Observations | Monthly order counts (36 in total) |
| Default window length | 3 months |
| Comparison window length | 6 months |
| Window alignment | Trailing (includes current month, uses past values) |
| Missing data | No missing values in this example |
How do you read a moving average chart?
Look at movement over several months rather than the ups and downs of individual months.
The gray line is the actual monthly order count, and the blue line is the 3-month moving average. The blue line softens sharp rises and falls in individual months, but it doesn't directly tell you in which month an increase actually started.
Because a moving average includes past observations, a change may show clearly only after the direction has already turned. Allow for this lag in the average line and check the original series as well.
How do you interpret a rolling standard deviation?
Look for periods when the spread of recent values grew.
If the rolling standard deviation increased, the values in that window were farther apart from each other. But the standard deviation can also grow in stretches where orders are rising quickly. So don't jump to calling it "rising risk" or "rising uncertainty."
For a time series whose level itself changes a lot, you can also look at the standard deviation of the rate of change or the coefficient of variation alongside the rolling standard deviation. Depending on your purpose, first decide what you are measuring the volatility of.
What if you change the window from 3 months to 6 months?
A longer window is smoother but responds to changes more slowly.
A 3-month moving average is relatively sensitive to recent changes. A 6-month moving average averages more months at once, so it smooths short-term ups and downs more strongly. Neither one can be declared "more accurate."
To see whether product sales change a lot from month to month, a short window can be useful; to see a gentle trend over half a year or so, a long window may be easier to read. Choose the window length to fit the analysis question and the observation frequency.
How do you read the numbers in the results table?
Even at the same time point, the statistics differ with the window length.
| Month | Orders | 3-month average | 3-month SD | 6-month average |
|---|---|---|---|---|
| 2025-07 | 318 | 299.7 | 19.0 | 280.2 |
| 2025-08 | 305 | 308.0 | 8.9 | 289.5 |
| 2025-09 | 294 | 305.7 | 12.0 | 295.2 |
| 2025-10 | 319 | 306.0 | 12.5 | 302.8 |
| 2025-11 | 339 | 317.3 | 22.5 | 312.7 |
| 2025-12 | 367 | 341.7 | 24.1 | 323.7 |
The 3-month moving average for December 2025 is calculated from the October–December values, and the 6-month moving average from the July–December values. The difference between the averages is not a calculation error; it's because they cover different observation periods.
There are no 3-month rolling statistics for the first two months, and no 6-month rolling statistics for the first five months. Filling them in with 0 would distort the chart and the summary values.
How is this different from other time series analyses?
Rolling statistics are local summaries, not a forecasting model in themselves.
| Method | Main purpose | Focus of interpretation |
|---|---|---|
| Rolling statistics | Summarize the mean and spread of a recent window | Window length and movement over time |
| Trend analysis | Identify a persistent direction over the whole period | Direction and size of increase or decrease |
| Seasonal decomposition | Separate trend, seasonality and remainder | Recurring periodic patterns |
| ARIMA | Forecasting using the stochastic structure of the series | Coefficients, residuals, prediction intervals |
A rising moving average doesn't mean values will necessarily keep rising. To forecast future values, you may need a separate model that accounts for autocorrelation, seasonality and so on.
What should you check before the analysis?
The observation interval, missing values and how the window is aligned all change the results.
Time interval and ordering
For monthly data, check that there is one row per month and that the dates are in the correct order. If a month is missing and you simply treat the rows before and after it as neighboring months, the meaning of a "3-month" window changes.
Missing values and minimum number of observations
Decide whether to stop calculating in a window that contains missing values or to calculate from the values available. Carelessly comparing rolling standard deviations calculated from different numbers of observations leads to misunderstandings.
Trailing vs. centered windows
For operational monitoring and point-in-time decisions, trailing rolling statistics, which don't use future observations, are appropriate. A centered moving average uses values both before and after each time point, so it's useful for describing past trends, but using it as a real-time forecasting input can let future information leak in.
What to watch out for when interpreting results
Tell the smooth movement of the numbers apart from actual changes in the data.
Lag in the moving average: even if the level changes suddenly, the change shows up slowly in the average line. Overlapping windows: moving averages at neighboring time points share most of the same observations, so they are not independent of each other.
Edge periods: at the beginning, results may not be calculated, or values may differ depending on the calculation method. Periodic patterns: if seasonality is pronounced, a moving average alone can't easily explain the cause. Interpret it together with the original series and use seasonal decomposition if needed.
You can't say a statistical change point has been detected just because the rolling standard deviation has increased. Formal tests or evaluations of forecasting performance require separate procedures.
Reporting rolling statistics in writing
Present the period, the window length and the calculation method together.
A report should state the units of the original series, the calculation windows for the moving average and rolling standard deviation, the window alignment and the rule for handling missing data. Here is a sentence describing the hypothetical example above.
A trailing 3-month moving average and sample rolling standard deviation were calculated for monthly order counts from January 2023 to December 2025 (36 months). The moving average showed an overall upward trend, and short-term ups and downs in monthly orders appeared smoothed in the average line. These results were interpreted as a descriptive summary of the observed trend.
In an actual analysis, you can describe the observed changes more concretely by citing specific periods and figures from the results table.
Where can rolling statistics be used?
They can be used with most time series data where you want to understand the recent trend.
| Field | Question | Statistic to look at |
|---|---|---|
| Retail | Has the sales trend over the last 3 months changed? | Moving average |
| Operations | Has daily inquiry volume become more variable? | Rolling standard deviation |
| Public health | What is the short-term trend in weekly patient counts? | Moving average |
| Manufacturing | Has the defect rate been fluctuating more lately? | Rolling standard deviation |
Rolling statistics can be a starting point for exploring data before building a complex model. Most important is to state how the window was chosen and to read the smoothed line together with the original observations.
Rolling statistics are a yardstick for reading recent trends.
By moving the observation period along, you can see changes that an overall mean easily hides.
A moving average smooths out small ups and downs, and a rolling standard deviation shows the wobble within a window. But the results depend on the window you use, so checking the numbers alone isn't enough.
Only by looking at the original series and the rolling statistics side by side, and checking the window length, alignment and missing-data rule, can you read the movement of a time series correctly.
Rolling statistics are calculated over a fixed period of observations that moves forward in time, to show a time series' recent average level and degree of variation. A moving average shows the trend smoothly and a rolling standard deviation shows the spread of recent values, but the results depend on the window length and calculation method, so they should be interpreted together with the original series.