
Linear regression is used in forecasting: it estimates, from historical data, how a dependent variable such as sales or cost relates to one or more independent variables such as machine hours or marketing spend, then uses that relationship to estimate new values. Microsoft describes Excel's FORECAST.LINEAR function as predicting a future value from existing values by using linear regression, and lists predicting future sales, inventory requirements and consumer trends among its uses.
This article sets out the method precisely: the least-squares slope and intercept, R² and residuals, assumptions and the limits of extrapolation, multiple regression and time series, with a fully worked example showing the sums, a comparison with the high-low method, the Excel functions, and where forecasts meet accounting estimates under IFRS.
What is simple linear regression?
The model assumes:
Y = a + bX + e
- Y is the dependent variable to be forecast and X the independent variable (the driver).
- b is the slope: the expected change in Y when X rises by one unit.
- a is the intercept: the estimated value of Y when X is zero.
- e is the residual: the difference between the actual value and the value on the line.
The least-squares method chooses the a and b that make the sum of squared residuals, Σe², as small as possible. Microsoft states that LINEST uses this method to calculate the straight line that best fits the data.
The slope and intercept formulas
With x̄ and ȳ as the means:
- Slope: b = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)²
- Intercept: a = ȳ − b·x̄
- Equivalent slope formula: b = (nΣxy − ΣxΣy) ÷ (nΣx² − (Σx)²), where n is the number of observations.
The coefficient of determination R² = 1 − (sum of squared residuals ÷ sum of squared deviations of y from its mean); in simple regression it equals the square of the correlation coefficient r.
Worked example: power cost and machine hours (illustrative figures)
A factory wants to forecast its monthly power cost (Y) from machine hours (X), using six months of data:
| Month | X | Y | x − x̄ | y − ȳ | (x − x̄)(y − ȳ) | (x − x̄)² | ŷ | e = y − ŷ | e² |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 400 | 5,400 | −250 | −1,800 | 450,000 | 62,500 | 5,200 | 200 | 40,000 |
| 2 | 500 | 5,800 | −150 | −1,400 | 210,000 | 22,500 | 6,000 | −200 | 40,000 |
| 3 | 600 | 6,600 | −50 | −600 | 30,000 | 2,500 | 6,800 | −200 | 40,000 |
| 4 | 700 | 7,800 | 50 | 600 | 30,000 | 2,500 | 7,600 | 200 | 40,000 |
| 5 | 800 | 8,400 | 150 | 1,200 | 180,000 | 22,500 | 8,400 | 0 | 0 |
| 6 | 900 | 9,200 | 250 | 2,000 | 500,000 | 62,500 | 9,200 | 0 | 0 |
| Total | 3,900 | 43,200 | 0 | 0 | 1,400,000 | 175,000 | 0 | 160,000 |
- Means: x̄ = 3,900 ÷ 6 = 650 hours; ȳ = 43,200 ÷ 6 = 7,200.
- Slope: b = 1,400,000 ÷ 175,000 = 8 per machine hour.
- Intercept: a = 7,200 − 8 × 650 = 2,000 a month.
- Forecasting equation: ŷ = 2,000 + 8X, which gives the ŷ column; the residuals sum to zero.
- Sum of squared deviations of y: 1,800² + 1,400² + 600² + 600² + 1,200² + 2,000² = 11,360,000.
- R² = 1 − 160,000 ÷ 11,360,000 = 0.9859: about 98.6% of the variation in cost in this sample goes with the variation in machine hours.
- Standard error of the estimate: √(160,000 ÷ (6 − 2)) = √40,000 = 200.
- Forecast: for a month expected to run 750 hours, 2,000 + 8 × 750 = 8,000.
Check with the equivalent formula: Σxy = 29,480,000 and Σx² = 2,710,000, so b = (6 × 29,480,000 − 3,900 × 43,200) ÷ (6 × 2,710,000 − 3,900²) = 8,400,000 ÷ 1,050,000 = 8.
Two cautions on this example:
- The 2,000 intercept corresponds to X = 0, a point outside the data (400 to 900 hours). Reading it as "fixed cost" is an estimate valid only within that range.
- A forecast at 1,200 hours gives 11,600, but it is an extrapolation beyond the observed range that assumes the linear relationship continues where no data supports it.
For fixed, variable and mixed costs, see Cost behavior.
How to read the results
- R² ranges from 0 to 1. Microsoft's RSQ page says it can be interpreted as the proportion of the variance in y attributable to the variance in x, and its LINEST page says that at 0 the regression equation is not helpful in predicting y. A high R² does not prove causation; both variables may move with a third factor.
- Residuals should look random around zero. A pattern, such as positive residuals at both ends and negative ones in the middle, suggests the relationship is not linear.
- The standard error of the estimate measures the amount of error in predicting y for an individual x, per the STEYX page. It is in the units of the dependent variable, which makes it easy to present to management.
- The F statistic, per the LINEST page, is used to determine whether the observed relationship between the dependent and independent variables occurs by chance.
Assumptions and limits
Least-squares results are reliable for inference only under well-known statistical conditions:
- Linearity: the relationship is roughly linear within the data range.
- Independent residuals: one period's residual is not related to the previous one's.
- Constant variance: residuals scatter similarly across the values of X.
- Normally distributed residuals: needed for significance tests and confidence intervals, not for fitting the line itself.
- A stable relationship: changes in technology, prices or the business can make old data unrepresentative of the future.
The most serious mistakes in practice are extrapolating far beyond the data, relying on very few observations and leaving outliers unexamined.
Multiple regression
When more than one variable explains Y:
Y = a + b₁X₁ + b₂X₂ + … + bₖXₖ + e
- Each coefficient bᵢ measures the expected change in Y for a one-unit change in its variable, with the other variables held constant.
- R² does not fall when a variable is added, even a useless one, which is why adjusted R², which accounts for the number of variables, is used.
- Multicollinearity: when the independent variables are highly correlated with each other, the coefficients become unstable. Microsoft notes that LINEST checks for collinearity and removes redundant columns, which then show a zero coefficient and a zero standard error.
Regression on time series
When X is time itself (a month number, say), regression estimates a trend. Particular cautions apply:
- Seasonality: where monthly or quarterly patterns recur, dummy variables (0 or 1) for seasons can be added instead of a single line.
- Residuals correlated over time: this can occur in time series and weakens statistical inference.
- Spurious correlation: two series that both rise can give a high R² with no real link between them.
- Structural breaks: a new product or a pricing change can break the historical relationship.
For building and maintaining forecast assumptions, see Building financial forecasting assumptions and Rolling forecasts.
High-low method vs regression
The high-low method uses only two observations, the highest and lowest activity levels. On the example data:
- Slope = (9,200 − 5,400) ÷ (900 − 400) = 3,800 ÷ 500 = 7.6 per hour.
- Fixed element = 9,200 − 7.6 × 900 = 2,360.
- Forecast at 750 hours = 2,360 + 7.6 × 750 = 8,060, against 8,000 by regression.
| High-low | Regression | |
|---|---|---|
| Observations used | 2 of 6 | 6 of 6 |
| Slope | 7.6 | 8 |
| Fixed element | 2,360 | 2,000 |
| Measure of fit | None | R² and standard error |
The high-low method is quicker but is driven by any anomaly in the two months chosen; regression uses all the data and measures how well the line fits.
Excel functions for regression
Assume X is in A2:A7 and Y in B2:B7. Note that the known y-values come before the known x-values in these functions:
| Function | Formula | Returns | Result in the example |
|---|---|---|---|
| SLOPE | =SLOPE(B2:B7,A2:A7) | Slope of the regression line | 8 |
| INTERCEPT | =INTERCEPT(B2:B7,A2:A7) | Point where the line crosses the y-axis | 2000 |
| RSQ | =RSQ(B2:B7,A2:A7) | Square of the Pearson correlation coefficient | 0.9859 |
| STEYX | =STEYX(B2:B7,A2:A7) | Standard error of the predicted y-value | 200 |
| FORECAST.LINEAR | =FORECAST.LINEAR(750,B2:B7,A2:A7) | Predicted y for a given x | 8000 |
| LINEST | =LINEST(B2:B7,A2:A7,TRUE,TRUE) | Coefficients and additional statistics as an array | 8 and 2000 in the first row |
Notes from Microsoft's documentation:
- In Excel 2016, FORECAST was replaced with FORECAST.LINEAR; syntax and usage are the same. FORECAST will eventually be deprecated and remains available for backward compatibility.
- LINEST returns the array {mn,…,m1,b}: the variable coefficients in reverse order, then the constant. const set to FALSE forces the constant to zero; stats set to TRUE adds the standard errors of the coefficients and constant, R², the standard error of the y estimate, the F statistic, degrees of freedom, and the regression and residual sums of squares.
- SLOPE and INTERCEPT use a different algorithm from LINEST, which can give different results when the data is undetermined and collinear.
For other functions accountants use, see Key Excel functions for accountants.
From forecasts to accounting estimates
When a forecast feeds a figure in the financial statements, the Standards set conditions, including:
- Value in use for impairment testing: an entity shall base cash flow projections on reasonable and supportable assumptions representing management's best estimate of the range of economic conditions over the asset's remaining useful life, with greater weight given to external evidence; on the most recent budgets or forecasts approved by management, excluding cash flows expected to arise from future restructurings or from improving or enhancing the asset's performance, over a maximum of five years unless a longer period can be justified. Beyond that, projections are extrapolated with a steady or declining growth rate unless an increasing rate can be justified, and the rate shall not exceed the long-term average growth rate for the products, industries, country or countries, or market unless a higher rate can be justified (IAS 36.33).
- Testing past forecasts: management assesses the reasonableness of its assumptions by examining the causes of differences between past cash flow projections and actual cash flows, and shall ensure current assumptions are consistent with past actual outcomes, provided the effects of subsequent events or circumstances that did not exist when those cash flows were generated make this appropriate (IAS 36.34). The idea is close to examining residuals. For ongoing tracking, see Financial variance analysis.
- Estimation technique: an entity uses measurement techniques and inputs, including estimation techniques, to develop an accounting estimate (IAS 8.32A). If a regression model is the technique behind an accounting estimate and the technique or its inputs change, the effect is a change in accounting estimate unless it results from correcting a prior period error (IAS 8.34A), recognised prospectively, other than a change to which paragraph 37 applies (IAS 8.36). See Accounting estimate vs accounting policy.
- Fixed and variable costs in inventory: IAS 2 distinguishes fixed production overheads, which remain relatively constant regardless of the volume of production, from variable ones, which vary directly or nearly directly with it (IAS 2.12). Fixed overheads are allocated on normal capacity and variable overheads on actual use of the production facilities (IAS 2.13). Regression is one statistical way to estimate the fixed and variable parts of a mixed cost.
A practical tool
Once you have estimated the fixed and variable parts of factory overheads, the Cost Accounting for Small Factories (Process Costing) Excel file, in Arabic, absorbs fixed overheads on normal capacity and variable overheads on actual hours, and calculates unit cost and work in process. It does not perform regression or estimate the fixed and variable split, and it has no job-order cost register.
Sources
- Microsoft Support: SLOPE, INTERCEPT, RSQ, STEYX, FORECAST and FORECAST.LINEAR and LINEST.
- IFRS Foundation: IAS 36 Impairment of Assets, IAS 8 and IAS 2 Inventories. References in brackets are to paragraphs of the Standards.
