Time Series Trend Calculator Formula

Understand the math behind the time series trend calculator. Each variable explained with a worked example.

Formulas Used

Trend Slope (per period)

trend_slope = slope

Trend Intercept

trend_intercept = intercept

Forecast Period 6

next_forecast = intercept + slope * 6

Average Value

avg_value = sum_y / 5

Variables

VariableDescriptionDefault
y1Period 1 Value100
y2Period 2 Value108
y3Period 3 Value115
y4Period 4 Value120
y5Period 5 Value130
sum_yDerived value= y1 + y2 + y3 + y4 + y5calculated
sum_xyDerived value= 1*y1 + 2*y2 + 3*y3 + 4*y4 + 5*y5calculated
sum_xDerived value= 15calculated
sum_x2Derived value= 55calculated
nDerived value= 5calculated
slopeDerived value= (5 * sum_xy - 15 * sum_y) / (5 * 55 - 225)calculated
interceptDerived value= (sum_y - slope * 15) / 5calculated

How It Works

How to Estimate a Time Series Trend

Method

Fit a least-squares regression line Y = a + b*t where t is the time period (1, 2, 3, ...). The slope b is the average change per period. The intercept a is the estimated value at t=0. Extrapolating the line gives forecasts for future periods.

Slope b = [n*Sum(t*y) - Sum(t)*Sum(y)] / [n*Sum(t^2) - (Sum(t))^2]

Worked Example

Five periods with values 100, 108, 115, 120, 130.

y1 = 100y2 = 108y3 = 115y4 = 120y5 = 130
  1. 01Sum(y) = 573, Sum(t) = 15, Sum(t^2) = 55
  2. 02Sum(t*y) = 1*100 + 2*108 + 3*115 + 4*120 + 5*130 = 1791
  3. 03Slope = (5*1791 - 15*573) / (5*55 - 225) = (8955-8595)/50 = 7.2
  4. 04Intercept = (573 - 7.2*15)/5 = (573 - 108)/5 = 93
  5. 05Forecast for period 6: 93 + 7.2*6 = 136.2

Ready to run the numbers?

Open Time Series Trend Calculator