notesonly.in

One notebook for every subject — open it anywhere.

Log in

Moving Averages and Trend Fitting: A Simple Explanation

A moving average smooths a time series by replacing each value with the average of its neighbours, wiping out short-term noise so the underlying trend becomes visible. Trend fitting goes one step further: it finds the straight line that best describes the long-term movement, usually by least squares.

Raw time series are noisy — daily sales jump around, but the business needs to know the direction. A moving average reveals the trend in seconds; a fitted trend line additionally gives an equation you can extend into the future.

Key Concepts

  • Moving average (MA): each smoothed value is the mean of a sliding window of observations, for example 3 or 5 periods.
  • Centred vs trailing: a centred MA places the average at the middle of the window (needs odd window or double-smoothing for even windows); a trailing MA uses only past values, which is what you need for live forecasting.
  • Window size trade-off: a longer window gives a smoother line but reacts slowly and loses end points; a shorter window follows the data closely but stays noisy.
  • Trend line by least squares: fit ŷ = a + bt with time as the x-variable, minimising squared deviations.

Formulas

  • 3-period centred moving average: Mt = (Y(t−1) + Yt + Y(t+1)) / 3.
  • Trend slope: b = Σ(t − t̄)(y − ȳ) / Σ(t − t̄)², with t = 1, 2, 3, … as the time index.
  • Trend intercept: a = ȳ − b·t̄, giving the trend line ŷ = a + bt.
  • Forecast: plug a future t into ŷ = a + bt.

Yearly sales (₹ lakh): 2019: 120, 2020: 135, 2021: 128, 2022: 150, 2023: 162. Smooth with a 3-year moving average and fit a trend line.

  1. 3-year MAs: 2020: (120+135+128)/3 = 383/3 ≈ 127.67; 2021: (135+128+150)/3 = 413/3 ≈ 137.67; 2022: (128+150+162)/3 = 440/3 ≈ 146.67. (No MA for 2019 or 2023 — the window runs out.)
  2. Read the smoothed series: 127.67 → 137.67 → 146.67, a clean upward staircase — the 2021 dip in raw data was noise.
  3. Trend line: let t = 1..5; t̄ = 3, ȳ = (120+135+128+150+162)/5 = 695/5 = 139.
  4. Slope: Σ(t−t̄)² = 4+1+0+1+4 = 10; Σ(t−t̄)(y−ȳ) = (−2)(−19) + (−1)(−4) + 0 + (1)(11) + (2)(23) = 38 + 4 + 0 + 11 + 46 = 99. So b = 99/10 = 9.9.
  5. Intercept: a = 139 − 9.9 × 3 = 139 − 29.7 = 109.3. Trend: ŷ = 109.3 + 9.9t.
  6. Forecast 2024 (t = 6): ŷ = 109.3 + 59.4 = 168.7 ≈ ₹169 lakh.

Common Misconceptions

  • A moving average lags behind turns. Because it averages the past, it signals a trend reversal late — it describes, it does not predict.
  • A fitted trend does not guarantee the future. Extending ŷ = a + bt assumes the same forces keep operating — fine for next year, fantasy for next decade.

Real-World Applications

  • Stock charts: the 50-day and 200-day moving averages are the most-watched trend signals in technical analysis.
  • Retail planning: deseasonalised moving averages guide inventory orders for the coming quarter.
  • Climate science: multi-year moving averages reveal global warming trends beneath noisy annual temperatures.
  • Public health: 7-day moving averages of case counts smooth weekend reporting gaps.

Moving averages let your eyes find the trend; least-squares trend fitting lets your calculator find it and project it forward. Use both — smooth first to see, fit second to forecast — and always remember that the forecast is only as stable as the trend itself.