Regression and Business Forecasting — Quantitative Investigations

These original investigations extend the existing six-unit course, its published companions and assigned readings. Reproduce a worked result, solve the changed record without the answer, then inspect the failure assumptions. The executable laboratory provides independent calculations and transactional failure tests.

Open the course · Run and modify the laboratory

COURSE UNIT 2

Derive least squares, sampling uncertainty and a future observation

Let S(b0,b1)=Σ[yi−b0−b1xi]². At an interior minimum, setting the derivative with respect to b0 to zero gives Σei=0 and b0=ybar−b1xbar. Substituting that relation into the derivative with respect to b1 gives b1=Sxy/Sxx, provided Sxx>0. If all x values are identical, slope is not identified by these data. This is a geometric fitting result; it does not require normal errors to calculate the line.

Inference requires additional assumptions. In the classical fixed-design model, the conditional error mean is zero and errors are independent with common variance σ². Then Var(b1|X)=σ²/Sxx. Estimate σ² using s²=SSE/(n−2) when there are two fitted coefficients. The lost degrees of freedom reflect estimating the intercept and slope from the same observations. Normal conditional errors supply an exact Student-t reference for the usual small-sample intervals; asymptotic or robust approaches make different claims. Serial dependence, heteroskedasticity or selection can invalidate a naive standard error even when the fitted coefficients were computed correctly.

For an input x0, the fitted mean has estimated standard error s√[1/n+(x0−xbar)²/Sxx]. A new individual outcome adds its own unexplained variability, producing s√[1+1/n+(x0−xbar)²/Sxx] under the same independent-error model. The extra 1 distinguishes prediction of a future observation from estimation of an average. A narrower confidence interval for the mean cannot honestly be presented as a range for every new job.

Distance from the observed center increases both intervals through the leverage term. This mathematical widening does not account for every extrapolation risk: a structurally wrong linear relationship outside the observed range can fail more severely. Report the predictor support, sampling design and intended use. A precise coefficient is not permission to make a causal claim; the zero-conditional-error assumption must be defended in the context of how the predictor and outcome were generated.

Work from this record

Use x=(1,2,3,4,5,6) and y=(2,4,3,4,7,7). The means are 3.5 and 4.5; Sxx=17.5 and Sxy=17.5, giving slope 1 and intercept 1. Predictions are 2,3,4,5,6,7, with residuals 0,1,−1,−1,1,0. SSE=4 and s²=4/4=1. At x0=3.5 the fitted mean is 4.5. Its standard error is √(1/6)=0.408248; a new observation has standard error √(1+1/6)=1.080123. Using the supplied two-sided 95% critical multiplier 2.776 for four degrees of freedom, margins are about 1.1333 and 2.9984. The multiplier is stipulated for this exercise, not estimated from six observations.

Independent transfer

Calculate the fitted mean and both standard errors at x0=7 using the same record. Explain which assumptions the larger prediction interval still does not test.

Compare the reasoning after your attempt

The fitted mean is 8. The leverage term is (7−3.5)²/17.5=0.7. Mean standard error is √(1/6+0.7) = 0.930949; prediction standard error is √(1+1/6+0.7) = 1.366260. The intervals do not establish linearity beyond x=6, independence, constant variance or a causal interpretation.

Continue in the course reader

COURSE UNIT 6

Rolling-origin validation and a forecast that cannot borrow the future

A time-series evaluation must reproduce the information available when a forecast is made. An ordinary random train/test split can put later outcomes into training for an earlier prediction. Even chronological rows are not enough if a feature uses a revised value, a centered moving average or a label unavailable at the forecast origin. Record the observation time, availability time, prediction time and target horizon.

Rolling-origin evaluation refits or updates using only the allowed past, predicts the next specified horizon and records the error before moving the origin. Expanding windows retain all previous observations; sliding windows keep a bounded recent history. The choice reflects a tradeoff between more data and adaptation to change. Use the same origins and horizons when comparing methods so a difficult period does not disappear from one candidate's denominator.

A naive last-observation forecast is a serious baseline for some short-horizon tasks. A seasonal naive baseline can be appropriate when calendar seasonality is present. Compare errors using a loss aligned with the decision. Mean absolute error measures average absolute deviation. Root mean squared error penalizes large errors more strongly. Percentage errors become undefined or unstable near zero and can distort comparisons across scales. A cost function with different over- and under-forecast penalties may be more directly relevant to staffing or inventory.

Forecast uncertainty includes future shocks as well as coefficient uncertainty. Errors over multiple horizons may be correlated, and overlapping targets share outcomes. Treating every horizon-origin pair as an independent replication can overstate precision. Prediction intervals should be evaluated for coverage and width on a relevant holdout, with separate checks for unusual periods. A nominal 95% label does not demonstrate actual coverage after a distribution change.

Model selection belongs inside the historical information boundary. If the analyst chooses the best window after inspecting all test errors, that period has become development data. Freeze the choice and retain a later evaluation block. Keep the original failed forecasts; replacing them with a refitted hindsight estimate erases the evidence the test was intended to collect.

Work from this record

For the fictional sequence 10,12,11,14,13,15, compare one-step forecasts at times 4,5,6. A last-observation method predicts 11,14,13, giving actual-minus-forecast errors 3,−1,2 and MAE=2. A trailing-three mean predicts 11,37/3,38/3, giving errors 3,2/3,7/3 and MAE=2. Both have MAE 2, but the sums of squared errors are 14 and 134/9≈14.8889 respectively. The methods tie under absolute loss and differ under squared loss. A centered three-point mean would use the target or later data and is not a valid alternative at those forecast origins.

Independent transfer

If under-forecasting costs 3 units per unit and over-forecasting costs 1, calculate each method's total loss over the three origins. Explain why three errors are insufficient to establish broad forecasting superiority.

Compare the reasoning after your attempt

The last-observation losses are 9,1,6, totaling 16. The trailing-mean errors are all positive, so losses are 9,2,7, totaling 18. The preferred method depends on the stipulated cost. Three selected origins provide little evidence about seasonality, change or rare large errors; retain a wider predeclared evaluation and examine dependency.

Continue in the course reader

Sources and reading boundary

The existing course readings remain assigned. New formulas, fictional datasets and solutions above are original Academy teaching. The links below provide primary technical references; MIT examples are used only in the separate review to inspect instructional demands.