📘 CodingMarble Learn

Time Series: Moving Averages, Trend and Seasonal Variation

A time series is a set of data recorded at equal time intervals, such as sales every quarter or rainfall every month. We plot it as a line graph with time on the horizontal axis. Real series go up and down with the seasons (seasonal variation), in longer waves (cyclic variation) and with random noise. To see the long-term direction (the trend) we smooth the data with moving averages: the mean of each group of consecutive values, for example 4 values for quarterly data. A line of best fit through the moving averages is the trend line. Seasonal variation = actual value − trend value; the mean seasonal variation for each season, added to the trend, gives a forecast.

🎬 Step-by-step story

  1. Each bar is one quarter of a year. Time goes left to right. Join the tops: that is a time series graph.
  2. Look at the colours. Q4 is always high and Q1 is always low. This repeating pattern is called seasonal variation.
  3. The yellow box holds 4 bars. Their mean is a 4-point moving average. Slide the box one step and find the next mean.
  4. The moving averages sit almost on a line. The red line through them is the trend. Here it goes up 1 each quarter.
  5. Seasonal variation = actual − trend. Add the mean seasonal variation to the trend to forecast the next quarter.
  6. Your turn. Slide the box and read each mean. Pick a future quarter and see the forecast.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Why do we join the points with lines if there is no data in between?

The lines help the eye follow the order in time and see patterns. They are not real readings. Step 1 shows the line drawn over the bar tops.

Why is the moving average plotted in the middle?

It is the mean of 4 times, so it belongs to their centre. Watch the yellow dots appear in the middle of the box in step 3.

Why 4 points and not some other number?

The pattern repeats every 4 quarters. 4 points hold one of each colour, so seasons cancel. Count the colours inside the box in step 3.

Why do the moving averages make a smoother line than the data?

Averaging cancels the seasonal highs and lows. In step 4 the yellow dots lie almost on the red line, while the bars jump up and down.

Can seasonal variation be negative?

Yes. A value below the trend gives a negative seasonal variation (Q1 here is −9.5). Step 5 shows the gap between bar and trend.

How do I forecast a future value?

Extend the trend line, read the trend value, then add the mean seasonal variation for that season. Pick a quarter in step 6 to see it.

What is a time series?

A time series is data collected at equal time gaps: every day, month, quarter (3 months) or year. Examples: monthly rainfall, a city's daily temperature, a company's quarterly sales, India's yearly population.

We draw it as a time series graph: time on the x-axis, the value on the y-axis, points joined by straight lines. The lines in between only show the order; they are not real readings.

Trend, seasonal, cyclic and random variation

The seasonal ups and downs hide the trend. Moving averages remove them.

How to calculate a moving average

For quarterly data, use a 4-point moving average (4 quarters = 1 whole year, so each average contains every season once).

  1. Add the first 4 values and divide by 4.
  2. Drop the first value, add the next one, divide by 4 again.
  3. Keep going to the end.

Plot each average at the middle of its 4 time points (between the 2nd and 3rd). For monthly data you would use a 12-point average; for days of a school week, a 5-point average.

From 12 values you get 12 − 4 + 1 = 9 moving averages.

Trend line and seasonal variation (higher)

Draw a line of best fit through the moving-average points. This is the trend line. Its gradient tells how fast the values change per time step.

Seasonal variation for one point = actual value − trend value. Work it out for every Q1 (or every Q4 …) and take the mean: this is the mean seasonal variation for that season.

Forecast = trend value read from the extended trend line + mean seasonal variation. Forecasts are only estimates, and the further into the future, the less reliable.

Try it

In the 3D, slide the yellow box from start to end and write down all 9 moving averages. What is the difference between each? At home: write down your family's electricity bill (or phone data use) for each of the last 8 months. Find the 4-point moving averages. Is the trend rising or falling?

Key formulas and definitions

Worked examples

1. Quarterly sales (₹ thousand): 20, 32, 28, 44, 24. Find the first two 4-point moving averages.

1st: (20 + 32 + 28 + 44) ÷ 4 = 124 ÷ 4 = 31. 2nd: drop 20, add 24: (32 + 28 + 44 + 24) ÷ 4 = 128 ÷ 4 = 32.

2. Where do you plot the first 4-point moving average for quarters 1 to 4?

At the middle of quarters 1, 2, 3, 4, which is 2.5 (halfway between quarter 2 and quarter 3).

3. How many 4-point moving averages can be found from 3 years of quarterly data?

3 years = 12 values. 12 − 4 + 1 = 9 moving averages.

4. Monthly visitors to a museum for one week (Mon–Sun) are recorded for 3 weeks. What size moving average should you use and why?

A 7-point moving average, because the pattern repeats every 7 days; each average then contains every day of the week once.

5. The trend line gives 40.5 for quarter 12, and the actual value is 52. Find the seasonal variation.

Seasonal variation = actual − trend = 52 − 40.5 = +11.5. The value is 11.5 above the trend.

6. The trend for quarter 13 is 41.5. The Q1 seasonal variations were −9.5, −9.5 and −9.5. Forecast quarter 13 (a Q1).

Mean seasonal variation for Q1 = −9.5. Forecast = 41.5 + (−9.5) = 32.

Common mistakes

Practice quiz

1. A time series is data recorded:
2. For quarterly data the usual moving average is:
3. The 4-point moving average of 10, 14, 12, 16 is:
4. A pattern that repeats every year is called:
5. Seasonal variation equals:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

What is a time series in statistics?

Data recorded at equal time intervals, such as monthly sales, drawn as a line graph with time on the x-axis.

How do you calculate a 4-point moving average?

Add 4 consecutive values and divide by 4; then move along one value and repeat until the end of the data.

What is the difference between seasonal and cyclic variation?

Seasonal variation repeats in a fixed period such as a year; cyclic variation comes in longer waves of changing length, like economic booms and slumps.

Where this is taught

CBSE (India)Class 12Time-based Data
England (GCSE, A level)Year 112. Processing, representing and analysing data (part 2)

Learn first

Learn next

Related lessons

All Maths lessons