A time series is a sequence of observations of a variable recorded at successive points or intervals of time (yearly, monthly, weekly, etc.). The order in which the data are recorded is essential.
Examples: annual GDP, monthly rainfall, daily share prices, yearly population.
All three say the same thing: the order in time is part of the data. Shuffle the values and you have lost the information a time series carries.
The value of the variable depends on time, so it is written \(y_t\), and the relationship as
\[ y_t = f(t) . \]Observed at times \(t_1, t_2, \ldots, t_n\), the series is the table of pairs \((t_i, y_{t_i})\). Here \(y_t\) might be agricultural production, population, bank deposits, sales, profits or temperature, and \(t\) might be years, months, weeks or days.
Examples: sales and profits of a company over the years; national income over ten years; monthly bank deposits; daily sales of a milk booth in a month; share prices on each day of a week; paddy production in Andhra Pradesh over seven years; monthly industrial production in a city.
The variation in a time series is decomposed into four components:
The general tendency of the series to increase, decrease or stay level over a long period. Upward: population over a decade; industrial or agricultural production; a company's profits. Downward: deaths in a district, epidemics, or illiteracy, falling with better medical facilities and living standards.
There is no hard and fast rule for what counts as “long”: it depends on the variable. Ten years is a long period for a country's population; ten minutes can be a long period for bacteria in a culture. Nor need the trend keep one direction throughout: it may rise, fall or level off in places, and still have an overall direction for the whole period.
Rhythmic movements that repeat within a year, with the same or almost the same pattern year after year: quarterly, monthly, weekly, daily, even hourly. Two kinds of cause:
Data given only once a year has no seasonal variation to measure: the season is averaged away inside each annual figure.
Oscillations with a period of more than one year. One complete period is a cycle. Cycles are more or less regular but not strictly periodic: no two need repeat exactly. In business they form the business cycle, with four phases: prosperity (boom), recession, depression and recovery, typically lasting seven to eleven years. Prices, income, production, wages and investment all follow it.
Purely random, erratic, unforeseen and non-recurring movements, from floods, wars, earthquakes, famines, epidemics, strikes, lockouts or revolutions. They follow no pattern and cannot be predicted. Usually small, they can occasionally be large enough to set off a cyclical movement.
Seasonal and cyclical variations together are the periodic (short-term) variations; with the irregular ones, they make up everything that is not trend.
The four components are independent and have constant magnitude. Suitable when the seasonal swing has the same absolute size irrespective of the level of the series.
Components are interdependent; seasonal swing increases proportionally with the level. Most common in practice (sales, finance).
Some components combine additively, others multiplicatively. Example: \(Y = T \cdot S + C + I\).
A month's sales of ₹21,110 is explained by: trend \(T=20{,}000\), a seasonal factor (a good sales month) of +₹1,500 in absolute terms or ×1.15 in relative terms, a cyclical downturn of −₹800 (a business slump) or ×0.90, and a random residual of +₹410 or ×1.02.
Additive model \(Y = T + S + C + I\):
\[ Y = 20{,}000 + 1{,}500 + (-800) + 410 = 21{,}110. \]Multiplicative model \(Y = T \times S \times C \times I\):
\[ Y = 20{,}000 \times 1.15 \times 0.90 \times 1.02 = 21{,}114. \]Both reproduce roughly the same figure; the additive version adds fixed rupee amounts, while the multiplicative version scales the trend by factors, so the seasonal/cyclical effects grow with the level of the series — which is why the multiplicative model is preferred for most business data.
Separating a series into its components is called decomposition. A model says how the components combine, and so how to take them apart.
In the additive model \(y_t = T_t + S_t + C_t + I_t\), the components are independent and \(S_t, C_t, I_t\) are absolute deviations about the trend, in the units of \(y\). In the multiplicative model \(y_t = T_t \times S_t \times C_t \times I_t\), only \(T_t\) is in the units of \(y\); \(S_t, C_t, I_t\) are indices (ratios or percentages). Taking logarithms turns the product into a sum,
\[ \log y_t = \log T_t + \log S_t + \log C_t + \log I_t , \]so the multiplicative model is the additive model for \(\log y_t\), and the same decomposition methods apply to the logarithms.
Mixed models combine the two, for example
\[ y_t = T_t + S_t C_t I_t, \qquad y_t = T_t + S_t + C_t I_t, \qquad y_t = T_t S_t + C_t I_t . \]Notation. The irregular component is written \(I_t\) throughout this page; some books write \(R_t\) (residual) for the same thing.
Plot the data and draw a smooth curve through the points by hand, balancing fluctuations on either side.
Merits: Simple, visual.
Demerits: Subjective, depends on judgement, not reproducible.
Sales (₹ lakhs) for 6 years: 20, 22, 25, 23, 28, 30. Plot and draw a smooth rising line through these points.
Daily temperatures over a week: 28, 30, 32, 31, 29, 33, 35. Free-hand line shows a mild upward trend.
If the number of observations is odd, drop the middle value (or include it in both halves).
Sales (in ₹ lakhs) for 8 years:
| Year | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 |
|---|---|---|---|---|---|---|---|---|
| Sales | 10 | 12 | 14 | 16 | 20 | 22 | 24 | 26 |
Split: first half 2018–21 mean = 13 (plotted at 2019.5); second half 2022–25 mean = 23 (plotted at 2023.5). Slope = (23-13)/4 = 2.5 per year.
Production: 20, 24, 28, 32, 36, 40, 44. Drop middle (32). First half avg = 24, second half avg = 40. Trend slope ≈ 4 units per year.
Fit \(Y = a + bX\) where \(X\) is time (coded so that \(\sum X = 0\) if possible — simplifies arithmetic).
If \(\sum X = 0\):
\[ a = \bar Y = \dfrac{\sum Y}{n}, \quad b = \dfrac{\sum XY}{\sum X^2}. \]Else use the general normal equations:
\[ \sum Y = na + b\sum X, \quad \sum XY = a\sum X + b\sum X^2. \]Fit \(Y = a + bX + cX^2\). With \(\sum X = 0, \sum X^3 = 0\):
For the 8-year sales data above, code \(X = -7, -5, -3, -1, 1, 3, 5, 7\) (using year units of 1/2 so \(\sum X = 0\)). Sums: \(\sum Y = 144,\; \sum X^2 = 168,\; \sum XY = (-7)(10)+(-5)(12)+\ldots+(7)(26) = 200\).
\(a = 144/8 = 18;\; b = 200/168 = 1.190\). Trend: \(\hat Y = 18 + 1.190 X\) (\(X\) in half-year units centred on 2021.5). Equivalent to ~2.38 per year — close to the semi-averages slope of 2.5.
Production for 5 years (\(X = -2, -1, 0, 1, 2\)): 5, 7, 11, 17, 25. \(\sum Y = 65, \sum X^2 = 10, \sum X^4 = 34, \sum XY = 50, \sum X^2 Y = 144\).
Solve: \(5a + 10c = 65,\; 10b = 50 \Rightarrow b = 5,\; 10a + 34c = 144\).
From first equation \(a = 13 - 2c\). Substitute: \(10(13 - 2c) + 34c = 144 \Rightarrow 130 + 14c = 144 \Rightarrow c = 1\). Then \(a = 13 - 2 = 11\).
Trend: \(\hat Y = 11 + 5 X + X^2\) (which reproduces the data exactly).
The principle of least squares: choose the constants to minimise the sum of squared deviations between the actual values and the fitted ones. For \(y_t = a + bt\),
\[ E = \sum_t \big[y_t - (a + bt)\big]^2 . \]At a minimum both partial derivatives vanish:
\[ \frac{\partial E}{\partial a} = -2\sum (y_t - a - bt) = 0 \;\Longrightarrow\; \sum y_t = na + b\sum t, \] \[ \frac{\partial E}{\partial b} = -2\sum t\,(y_t - a - bt) = 0 \;\Longrightarrow\; \sum t y_t = a\sum t + b\sum t^2 . \]These are the normal equations. If time is coded as \(x\) with \(\sum x = 0\), they separate: \(a = \sum y/n\) and \(b = \sum xy / \sum x^2\).
For \(y_t = a_0 + a_1 t + \cdots + a_k t^k\), setting \(\partial E/\partial a_j = 0\) multiplies the residual by \(t^j\) before summing, giving the \(k + 1\) equations
\[ \begin{gathered} \sum t^j y_t = a_0 \sum t^j + a_1 \sum t^{j+1} + a_2 \sum t^{j+2} + \cdots + a_k \sum t^{j+k}, \\ j = 0, 1, \ldots, k . \end{gathered} \]For the parabola (\(k = 2\)) these are the three equations of the box above.
Odd \(n\): put \(x = t - (\text{middle year})\), so \(x = \ldots, -1, 0, 1, \ldots\) and \(\sum x = 0\).
Even \(n\): the middle falls between two years, so measure in half-years from it:
\[ x = \frac{t - \tfrac12(t_{n/2} + t_{n/2+1})}{\tfrac12} = 2\big(t - \text{midpoint}\big), \]giving \(x = \ldots, -3, -1, 1, 3, \ldots\). Then \(b\) is the change per half-year, and the change per year is \(2b\).
Least squares is then applied to the logarithms, not to \(y\) itself: the fitted curve minimises the squared relative errors, roughly. That is the usual practice, and the one followed here.
Besides the line, parabola and polynomial: the exponential \(ab^t\) or \(ae^{bt}\); the power curve \(at^b\); the growth curves (modified exponential \(a + bc^t\), Gompertz \(ab^{c^t}\), and logistic \(k/(1 + e^{a + bt})\) with \(b < 0\)); and the second-degree curve fitted to logarithms, \(ab^tc^{t^2}\).
With the forward difference \(\Delta y_t = y_{t+h} - y_t\), a polynomial of degree \(n\) has \(\Delta^n y_t\) constant and \(\Delta^r y_t = 0\) for \(r > n\). So:
| If this is (roughly) constant | fit |
|---|---|
| \(\Delta y_t\) (equal absolute changes) | straight line |
| \(\Delta^2 y_t\) | parabola |
| \(\Delta \log y_t\) (equal percentage changes; straight on semi-log paper) | exponential |
| \(\Delta^2 \log y_t\) | second-degree curve in logarithms |
| \(\Delta y_t / \Delta y_{t-1}\) | modified exponential |
| \(\Delta \log y_t / \Delta \log y_{t-1}\) | Gompertz |
| \(\Delta (1/y_t) / \Delta (1/y_{t-1})\) | logistic |
Each test is the curve's own algebra: for \(y_t = a + bc^t\), \(\Delta y_t = bc^t(c - 1)\), so the ratio of successive differences is \(c\). When \(\Delta y_t\) is skewed like a frequency curve, the Gompertz or logistic is the candidate.
The three growth curves are not linear in their constants even after taking logarithms, so they are not fitted by ordinary least squares; they are fitted by other means (for example the method of selected points, or of partial sums).
A moving average of period \(k\) replaces each data point by the mean of \(k\) successive observations centred on that point.
For even periods (e.g. 4-yearly), one extra step of "centering" is needed by taking 2-period MA of MAs.
Merits: objective, smooths short-term fluctuations.
Demerits: loses data points at the ends; cannot extrapolate; works only when trend is roughly linear.
Data: 10, 12, 14, 16, 20, 22, 24, 26.
| Year (t) | Y | 3-yr MA |
|---|---|---|
| 1 | 10 | — |
| 2 | 12 | (10+12+14)/3 = 12.00 |
| 3 | 14 | (12+14+16)/3 = 14.00 |
| 4 | 16 | (14+16+20)/3 = 16.67 |
| 5 | 20 | (16+20+22)/3 = 19.33 |
| 6 | 22 | (20+22+24)/3 = 22.00 |
| 7 | 24 | (22+24+26)/3 = 24.00 |
| 8 | 26 | — |
Data: 5, 7, 11, 17, 25, 31, 40, 50.
4-yr MAs (placed between years): (5+7+11+17)/4 = 10 (between yr 2 & 3), (7+11+17+25)/4 = 15 (between 3 & 4), ... etc.
Centered MA at yr 3 = (10 + 15)/2 = 12.5. Continue similarly to align with actual years.
A moving average of period \(m\): the first is the mean of terms 1 to \(m\), the second of terms 2 to \(m + 1\), and so on, dropping one term and adding the next. Each is placed at the centre of its period.
Writing out the centred 4-period average shows what it really is: a weighted 5-term average,
\[ \frac12\left[\frac{y_1 + y_2 + y_3 + y_4}{4} + \frac{y_2 + y_3 + y_4 + y_5}{4}\right] = \frac{y_1 + 2y_2 + 2y_3 + 2y_4 + y_5}{8} . \]So in practice: add the 4-period totals in pairs and divide by 8 (for 12 months, by 24).
A moving average removes a regular periodic movement completely provided (1) its period equals the period of the oscillation, or a multiple of it, and (2) the trend is linear.
Why. Over one full period a periodic component measured about the trend sums to zero, so it contributes nothing to any average taken over exactly one period. And the average of a straight line over a period symmetric about its centre is the line's value at the centre: \(\tfrac{1}{m}\sum_{j=-k}^{k}\big(a + b(t + j)\big) = a + bt\). If the cycles have no uniform period, the period of the moving average should be at least the mean length of the cycles; the cyclical movement is then reduced, not removed.
| Method | Merits | Demerits |
|---|---|---|
| Free-hand | simple, flexible, any shape of trend | subjective: different people draw different curves; needs experience; no basis for prediction |
| Semi-averages | objective (one line only); simple | assumes a linear trend; the means are affected by extreme values |
| Least squares | objective; a trend value for every period; an equation for forecasting and interpolation; growth rate per period from \(b\) | arithmetic; a new observation means refitting; the type of curve must be chosen; ignores S, C, I in forecasts |
| Moving averages | simple; objective; adding data does not change earlier values; removes regular cycles | no trend values at the ends; no forecasting; the period is hard to choose; affected by extreme values |
Eight problems: two by semi-averages, four by least squares (a line with an odd and with an even number of years, a parabola, an exponential curve) and two by moving averages, followed by exercises with answers. Every figure is computed from the data in the problem; constants are carried at full precision and rounded only when written, so the trend values here may differ in the second decimal from ones computed with \(a\) and \(b\) rounded first.
Fit a trend line by the method of semi-averages to a firm's output (thousand units).
| Year | 2011 | 2012 | 2013 | 2014 | 2015 |
|---|---|---|---|---|---|
| Output | 54 | 58 | 57 | 63 | 66 |
| Year | 2016 | 2017 | 2018 | 2019 | 2020 |
| Output | 64 | 70 | 73 | 72 | 78 |
\(n = 10\): the halves are 2011–15 and 2016–20.
\[ \bar y_1 = \frac{54 + 58 + 57 + 63 + 66}{5} = \frac{298}{5} = 59.6, \] \[ \bar y_2 = \frac{64 + 70 + 73 + 72 + 78}{5} = \frac{357}{5} = 71.4 . \]Each mean is plotted at the middle of its half, 2013 and 2018. The two points are 5 years apart, so the trend rises \((71.4 - 59.6)/5 = 2.36\) thousand units a year:
\[ y_t = 59.6 + 2.36\,(t - 2013), \]giving, for example, \(54.88\) in 2011 and \(76.12\) in 2020.
Fit a trend line by the method of semi-averages to sales (₹ lakhs), 2012–20: 42, 47, 45, 52, 55, 58, 54, 61, 63.
\(n = 9\) is odd, so the middle year, 2016, is left out, and the halves are 2012–15 and 2017–20:
\[ \begin{gathered} \bar y_1 = \frac{42 + 47 + 45 + 52}{4} = \frac{186}{4} = 46.5, \\ \bar y_2 = \frac{58 + 54 + 61 + 63}{4} = \frac{236}{4} = 59 . \end{gathered} \]They are plotted at 2013.5 and 2018.5, five years apart, so the slope is \((59 - 46.5)/5 = 2.5\) lakhs a year: \(y_t = 46.5 + 2.5\,(t - 2013.5)\).
Deposits in a cooperative bank (₹ crores), 2012–20. Fit a straight line by least squares, find the trend values, and estimate the deposits in 2022.
\(n = 9\), so \(x = t - 2016\).
| Year | \(y\) | \(x\) | \(x^2\) | \(xy\) | Trend |
|---|---|---|---|---|---|
| 2012 | 31 | −4 | 16 | −124 | 31.42 |
| 2013 | 36 | −3 | 9 | −108 | 34.29 |
| 2014 | 34 | −2 | 4 | −68 | 37.16 |
| 2015 | 41 | −1 | 1 | −41 | 40.02 |
| 2016 | 45 | 0 | 0 | 0 | 42.89 |
| 2017 | 43 | 1 | 1 | 43 | 45.76 |
| 2018 | 50 | 2 | 4 | 100 | 48.62 |
| 2019 | 54 | 3 | 9 | 162 | 51.49 |
| 2020 | 52 | 4 | 16 | 208 | 54.36 |
| Total | 386 | 0 | 60 | 172 |
With \(\sum x = 0\) the normal equations give \(386 = 9a\) and \(172 = 60b\):
\[ a = \frac{386}{9} = 42.8889, \qquad b = \frac{172}{60} = 2.8667, \qquad y_t = 42.89 + 2.87\,(t - 2016) . \]For 2022, \(x = 6\): \(\;42.8889 + 6(2.8667) = 60.09\) crores.
Profits (₹ thousands), 2015–20: 62, 75, 58, 81, 77, 90. Fit a straight line and find the trend values.
\(n = 6\) is even, so the origin is the midpoint 2017.5 and time is counted in half-years: \(x = 2(t - 2017.5)\), giving \(x = -5, -3, -1, 1, 3, 5\).
\[ \begin{gathered} \sum y = 443, \quad \sum x^2 = 70, \\ \sum xy = (-5)(62) + (-3)(75) + (-1)(58) + (1)(81) + (3)(77) + (5)(90) = 169, \end{gathered} \] \[ a = \frac{443}{6} = 73.8333, \qquad b = \frac{169}{70} = 2.4143 \text{ per half-year}, \] \[ y_t = 73.83 + 2.4143\,x = 73.83 + 4.83\,(t - 2017.5) . \]Trend values for 2015–20: \(61.76, 66.59, 71.42, 76.25, 81.08, 85.9\). The yearly increase is \(2b = 4.83\).
Sales (₹ thousand), 2014–18: 17, 23, 26, 25, 19. Fit a second-degree parabola.
\(x = t - 2016\), so \(x = -2, \ldots, 2\), and \(\sum x = \sum x^3 = 0\).
| \(x\) | −2 | −1 | 0 | 1 | 2 | Total |
|---|---|---|---|---|---|---|
| \(y\) | 17 | 23 | 26 | 25 | 19 | 110 |
| \(x^2\) | 4 | 1 | 0 | 1 | 4 | 10 |
| \(x^4\) | 16 | 1 | 0 | 1 | 16 | 34 |
| \(xy\) | −34 | −23 | 0 | 25 | 38 | 6 |
| \(x^2y\) | 68 | 23 | 0 | 25 | 76 | 192 |
So \(b = 0.6\). Doubling the first equation, \(220 = 10a + 20c\); subtracting it from the third, \(-28 = 14c\), \(c = −2\); then \(a = (110 - 10c)/5 = 26\).
\[ y = 26 + 0.6x - 2x^2, \qquad x = t - 2016 . \]Trend values: \(16.8, 23.4, 26, 24.6, 19.2\). For 2019 (\(x = 3\)) the curve gives \(9.8\). A parabola carried beyond the data turns down steeply, so an estimate like this is to be treated with caution.
Online sales of a start-up (₹ lakhs), 2012–18: 24, 33, 47, 66, 91, 130, 182. Fit \(y = ab^t\), find the trend values, and estimate the sales in 2019.
Take logarithms: \(u = \log_{10} y = A + Bx\), with \(x = t - 2015\), \(A = \log a\), \(B = \log b\).
| Year | \(y\) | \(x\) | \(u = \log y\) | \(xu\) | Trend |
|---|---|---|---|---|---|
| 2012 | 24 | −3 | 1.3802 | −4.1406 | 23.79 |
| 2013 | 33 | −2 | 1.5185 | −3.037 | 33.38 |
| 2014 | 47 | −1 | 1.6721 | −1.6721 | 46.84 |
| 2015 | 66 | 0 | 1.8195 | 0 | 65.71 |
| 2016 | 91 | 1 | 1.9590 | 1.959 | 92.19 |
| 2017 | 130 | 2 | 2.1139 | 4.2279 | 129.34 |
| 2018 | 182 | 3 | 2.2601 | 6.7802 | 181.46 |
| Total | 0 | 12.7234 | 4.1174 |
\(\sum x^2 = 28\). The normal equations give
\[ A = \frac{12.7234}{7} = 1.8176, \qquad B = \frac{4.1174}{28} = 0.1470, \] \[ \begin{gathered} a = \text{antilog}\,1.8176 = 65.71, \qquad b = \text{antilog}\,0.1470 = 1.403, \\ y = 65.71\,(1.403)^{t - 2015} . \end{gathered} \]For 2019, \(x = 4\): \(\;\log y = 1.8176 + 4(0.1470) = 2.4058\), so \(y = 254.6\) lakhs. The growth factor \(b = 1.403\) says sales grew about 40.3% a year.
Keep four places in the logarithms throughout: one slip in a single logarithm moves both sums, and so \(a\), \(b\) and every trend value.
Paddy production in a district (thousand tonnes), 2005–20. Calculate 5-year moving averages, and the trend-eliminated values under the additive model.
Each total adds five consecutive years and is placed against the middle one; each new total drops the oldest year and adds the next (\(233 - 41 + 43 = 235\), then \(235 - 44 + 46 = 237\), and so on). Under the additive model the trend-eliminated value is \(y - T\): the original value minus the moving average.
| Year | \(y\) | 5-yr total | 5-yr MA \(T\) | \(y - T\) |
|---|---|---|---|---|
| 2005 | 41 | — | — | — |
| 2006 | 44 | — | — | — |
| 2007 | 47 | 233 | 46.6 | 0.4 |
| 2008 | 52 | 235 | 47 | 5 |
| 2009 | 49 | 237 | 47.4 | 1.6 |
| 2010 | 43 | 245 | 49 | −6 |
| 2011 | 46 | 254 | 50.8 | −4.8 |
| 2012 | 55 | 263 | 52.6 | 2.4 |
| 2013 | 61 | 273 | 54.6 | 6.4 |
| 2014 | 58 | 284 | 56.8 | 1.2 |
| 2015 | 53 | 295 | 59 | −6 |
| 2016 | 57 | 304 | 60.8 | −3.8 |
| 2017 | 66 | 310 | 62 | 4 |
| 2018 | 70 | 325 | 65 | 5 |
| 2019 | 64 | — | — | — |
| 2020 | 68 | — | — | — |
A check worth making every time: successive totals must differ by exactly the value added minus the value dropped.
Sales of a chain of stores (₹ lakhs), 2009–20: 210, 232, 225, 238, 246, 251, 240, 236, 258, 249, 262, 270. Calculate 4-year moving averages.
The 4-year totals, each sitting between two years, are
\[ 905,\ 941,\ 960,\ 975,\ 973,\ 985,\ 983,\ 1005,\ 1039 \](\(210 + 232 + 225 + 238 = 905\); then \(905 - 210 + 246 = 941\); and so on). Their non-centred averages are \(226.25, 235.25, 240, 243.75, 243.25, 246.25, 245.75, 251.25, 259.75\). To centre them, add the totals in pairs and divide by 8:
| Year | Sales | Sum of two 4-yr totals | Centred MA |
|---|---|---|---|
| 2009 | 210 | — | — |
| 2010 | 232 | — | — |
| 2011 | 225 | 1846 | 230.75 |
| 2012 | 238 | 1901 | 237.625 |
| 2013 | 246 | 1935 | 241.875 |
| 2014 | 251 | 1948 | 243.5 |
| 2015 | 240 | 1958 | 244.75 |
| 2016 | 236 | 1968 | 246 |
| 2017 | 258 | 1988 | 248.5 |
| 2018 | 249 | 2044 | 255.5 |
| 2019 | 262 | — | — |
| 2020 | 270 | — | — |