How to forecast with linear regression
Enter pairs of numbers with Σ+, then gŷ,r2 predicts y for any x along the best-fitting line.
Monthly sales for six months were 112, 118, 127, 131, 140 and 146 units. If the trend continues, what are sales in month 7, and how well does a straight line fit?
Keystrokes
- fΣSST
Clears the statistics registers.
- 112ENTER1Σ+
Each pair is y, ENTER, then x.
- 118ENTER2Σ+
- 127ENTER3Σ+
- 131ENTER4Σ+
- 140ENTER5Σ+
- 146ENTER6Σ+
Six pairs entered.
- 7gŷ,r2
The forecast for month 7.
- x≷y
The correlation coefficient.
- f4
Four decimals, to see r more precisely.
- f2
Back to two decimals.
The forecast for month 7 is 153.00 units, and the correlation coefficient is 0.9969.
Why it works
gŷ,r2 fits the least-squares line through the pairs and evaluates it at the x you key. The correlation coefficient r is left in Y. Close to 1 means the points lie almost on a straight line.
gx̂,r1 works the other way: key a y value to find the x where the line reaches it, such as the month sales will pass 180.
Questions
How do I get the slope and intercept?
0 g ŷ,r gives the intercept, the forecast at x = 0. The forecast at x = 1, 1 g ŷ,r, minus the intercept is the slope.