Correlation, Regression and Time Series
Statistics
Correlation, Regression and Time Series
Syllabus tag: KASNEB CPA | Foundation Level | CA15 Quantitative Analysis | Topic 9 Correlation, Regression and Time Series
Lesson objectives
By the end of this topic, you will be able to:
- Compute and interpret the correlation coefficient
- Compute the least squares regression line
- Interpret the coefficient of determination
- Compute a moving average and isolate the seasonal variation
- Forecast, and state the limitations of doing so
Why this matters
Businesses forecast constantly — sales next quarter, costs at a higher output. These are the techniques for doing so from historical data, and for knowing how much weight the result deserves.
One dataset throughout
Advertising spend x and sales y, in KES hundred thousands:
| x | 2 | 4 | 5 | 7 | 9 | 11 | 12 | 14 |
|---|---|---|---|---|---|---|---|---|
| y | 18 | 23 | 27 | 32 | 40 | 46 | 49 | 55 |
The totals needed: n = 8, Σx = 64, Σy = 290, Σxy = 2,711, Σx² = 636, Σy² = 11,748.
Set the table out and total the columns before substituting. Almost every error in this topic is an arithmetic slip in these sums rather than a misremembered formula.
Correlation
r = [nΣxy − ΣxΣy] / √{[nΣx² − (Σx)²][nΣy² − (Σy)²]}
= 0.9990
Interpreting r:
| Value | Meaning |
|---|---|
| +1 | Perfect positive linear relationship |
| 0 | No linear relationship |
| −1 | Perfect negative linear relationship |
Here r is almost +1, indicating a very strong positive linear association.
Two warnings that carry marks.
Correlation is not causation. A strong r shows two variables move together, not that one causes the other. Both may be driven by a third factor, or the association may be coincidence.
r measures LINEAR association only. Variables related by a strong curve can produce an r near zero. Plotting the data first is the guard against this, and takes a moment.
Spearman's rank correlation is used for ranked or non-numeric data:
rs = 1 − 6Σd² / [n(n² − 1)]
With five ranked pairs and Σd² = 4: rs = 1 − 24/120 = 0.8
Least squares regression
b = [nΣxy − ΣxΣy] / [nΣx² − (Σx)²] = 3.1532
a = (Σy − bΣx) / n = 11.0242
Regression line: y = 11.0242 + 3.1532x
Interpretation matters more than the arithmetic. The slope says that each extra unit of advertising is associated with 3.15 units of additional sales. The intercept says sales would be 11.02 with no advertising at all — which may or may not be meaningful, since x = 0 lies outside the observed range of 2 to 14.
Which variable goes where. x is the independent variable, the one being used to predict; y is the dependent variable being predicted. Regressing x on y gives a different line, and choosing the wrong direction is a standard error.
Coefficient of determination
r² = 0.9979, or 99.79%
This is the proportion of the variation in y explained by the variation in x. The remaining 0.21% is due to other factors.
It is the more honest figure to quote. An r of 0.7 sounds impressive until squared: only 49% of the variation is explained, and the majority is not.
Forecasting
At x = 10: y = 11.0242 + 3.1532(10) = 42.5565
Interpolation — forecasting within the observed range of x, here 2 to 14 — is reasonably reliable.
Extrapolation — forecasting outside it — is not. The relationship observed over that range may not continue, and the further out the forecast, the weaker it becomes. Predicting sales at an advertising spend of 40 from this data is not supported by it.
:::checkpoint A manager uses this line to forecast sales at an advertising spend of 35 and presents the figure as reliable. Set out two separate objections. :::
Time series
A series decomposes into four components:
- Trend — the long-term direction
- Seasonal — regular short-term variation within a year
- Cyclical — longer swings with the economic cycle
- Random — irregular, unpredictable movements
The additive model: Y = T + S + C + R The multiplicative model: Y = T × S × C × R
Use the multiplicative model where the seasonal swing grows with the trend — a business whose December peak is 20% above trend whether it turns over 10 million or 50 million. Use the additive model where the swing is a roughly constant amount.
Moving averages
Quarterly sales: 120, 148, 166, 132, 138, 166, 186, 150.
A four-quarter moving average removes the seasonal effect, because each average contains one of every quarter:
| Average | Working | Result |
|---|---|---|
| First | (120 + 148 + 166 + 132) / 4 | 141.5 |
| Second | (148 + 166 + 132 + 138) / 4 | 146.0 |
| Third | 150.5 | |
| Fourth | 155.5 |
Centring is needed for an even-numbered period, because a four-quarter average falls between two quarters rather than on one. Averaging consecutive pairs re-aligns it:
Centred value at quarter 3 = (141.5 + 146.0) / 2 = 143.75
Seasonal variation at quarter 3 = actual − trend = 166 − 143.75 = +22.25
Averaging that seasonal figure across several years gives the seasonal adjustment used in forecasting: project the trend forward, then add the seasonal factor for the quarter concerned.
:::checkpoint A company's seasonal variations for the four quarters average +22, +8, −15 and −13. Explain what the near-zero total tells you and what it would mean if the four averaged +10. :::