Week 15: Forecasting II: Linear Trend & Regression

This week’s big question: moving averages and smoothing always lag a trend. When the data is clearly climbing (or falling), how do you forecast the trend itself, and how do you predict one quantity from another, like demand from the unemployment rate?

Before the week

  • Read: Taylor, Introduction to Management Science (13e): Chapter 15, “Forecasting,” pp. 737–742 and 750–759 (focus: adjusted exponential smoothing and seasonal factors, then linear trend and linear-regression forecasting; interpreting fit / R², which the book calls the coefficient of determination).
  • Warm-up self-check, slopes, lines, and last week’s smoothing:

Reminder. The course synthesis. The term ends in two weeks. If you haven’t picked a real problem for the course-synthesis submission (14 pts) yet, choose one this week: you present it in Week 16 and submit it Sun Dec 13.

Session 1: Mon, Nov 30 · Trend, season, and fitting a line (TBD)

🧩 Puzzle

The program that keeps growing. Quarterly enrollment over two years was 120, 128, 135, 141, 150, 158, 163, 172, a steady climb. A moving average would forecast below the trend every time. How do you forecast a number that keeps rising?

Build the skill 1: the two patterns a plain smoother misses

Week 13 ended on a warning: a moving average or a plain smoother ignores trend and season. Before fitting a line, it is worth seeing how much that costs, and that each problem has a cheap repair you can bolt onto last week’s method.

A trend leaves the forecast permanently behind. Here is the same demand series you smoothed last week. Start with the trend dial at \(\beta = 0\), which is exactly the exponential smoothing you already know, and watch the forecast sit stubbornly below a climbing series:

At \(\alpha = 0.3\) and \(\beta = 0\) the next forecast is 30.2 while the series just printed 35. The smoother is averaging history, and history is lower than now. Adjusted exponential smoothing fixes this by carrying a second running quantity, a trend factor \(T\), and adding it to the ordinary forecast:

\[T_{t+1} = \beta\,(F_{t+1} - F_t) + (1-\beta)\,T_t, \qquad AF_{t+1} = F_{t+1} + T_{t+1}.\]

\(T\) is a smoothed estimate of how much the forecast itself is moving each period, and \(\beta\) says how quickly that estimate reacts. Slide \(\beta\) up: at \(\beta = 0.3\) the forecast rises to 31.51 and MAD falls from 3.90 to 3.41; at \(\beta = 0.9\) it reaches 32.2 with MAD 3.29. The lag shrinks but never fully closes, because the correction is still built from past movement.

A season makes the average wrong in a predictable rhythm. A city parks department logged quarterly program registrations (in hundreds) over three years: 12, 18, 26, 16 · 14, 21, 30, 19 · 16, 24, 34, 22. Summer (Q3) towers over winter every single year, so any single flat number is wrong four times a year.

The repair is a seasonal factor for each quarter: its share of the grand total across all the years you have. Q3 takes \((26 + 30 + 34)/252 = 0.357\) of the annual total, Q1 only \(0.167\). The four factors sum to 1 by construction, which is the arithmetic check to run before you trust them. Then forecast the next year’s total (registrations grew 72 → 84 → 96, so 108 is the natural next), and split it by the factors: Q1 \(= 0.167(108) = 18\), Q2 \(= 27\), Q3 \(= 38.57\), Q4 \(= 24.43\). Those four sum back to 108, and the forecast now has the same shape as the history instead of flattening it.

Both of these are patches bolted onto a smoother. The rest of today takes the other route: stop patching and model the trend itself.

Build the skill 2: draw the best straight line through the data

A linear trend fits a straight line \(y = a + b\,t\) to the data by least squares. The line that makes the total squared miss as small as possible. Its slope \(b\) is “how much per period,” the intercept \(a\) is the fitted starting value at \(t = 0\), and you forecast the future by reading the line forward. Press Fit trend line and watch the line, its equation, and the next-quarter forecast appear:

Because the line follows the trend instead of averaging old values, it doesn’t lag. That’s why trend models beat moving averages on climbing data.

A second worked example (coffee-chain app downloads). A regional coffee chain logged quarterly app downloads (in thousands) over two years: 18, 21, 23, 22, 27, 30, 29, 34. Fitting the least-squares trend gives \(y = 15.96 + 2.12\,t\) with \(R^2 = 0.93\): a slope of about +2.1 thousand downloads per quarter, and a forecast for the next quarter (\(t = 9\)) of \(15.96 + 2.12(9) \approx 35\) thousand. Same machinery, different domain: name the predictor (here, the quarter number \(t\)), let least squares pick \(a\) and \(b\), then read the line forward.

Build the skill 3: how well does the line fit, and what does it mean? (r and R²)

A line can be drawn through any data; the question is whether it fits. Two numbers report that.

The correlation coefficient \(r\) runs from \(-1\) to \(+1\) and carries both the direction and the strength of the relationship: \(r\) near \(+1\) is a tight upward line, \(r\) near \(-1\) a tight downward line, \(r\) near \(0\) a shapeless cloud. The coefficient of determination \(R^2 = r^2\) then always sits between \(0\) and \(1\). It keeps the strength but drops the sign, so a steep downhill line and a steep uphill line can both have \(R^2 = 0.95\). (Watch for this once your predictor is a real driver that can move the opposite way, like price: a strong negative relationship still gives a high \(R^2\).)

\(R^2\) is the share of the ups-and-downs the line explains. Near 1 means the points hug the line; near 0 means the line tells you little. The widget reports \(R^2\) alongside the equation. Here it rounds to \(R^2 = 1\) on screen (the exact value is \(0.998\)), almost a perfect line.

Say it in one sentence (this is exactly what gets graded). Translate the two numbers into plain English:

  • Slope: “each additional quarter adds about 7.3 students to predicted enrollment”. The slope is the change in \(y\) per one-unit change in \(t\), in the real units of the problem.
  • \(R^2\): “the line explains about 99.8% of the variation in enrollment; the remaining 0.2% is noise or other factors.” That X% explained, (100 − X)% left over template is the canonical reading of \(R^2\).

High \(R^2\) + a slope you can state in real units = a forecast you can defend.

In practice: a trend line is a promise the future may not keep

  • Extrapolation is risky. The line assumes the trend continues. Forecasting 10 quarters out, or through a policy change or a recession, can be badly wrong. The further you extend, the shakier it gets.
  • A trend line keeps the SAME slope even after the real trend bends. This is the deeper version of the point above: if the program saturates, a recession hits, or admissions caps the class, the slope itself becomes wrong, not just the far-out points. The line happily keeps climbing at +7.3 per quarter long after reality has flattened, so a structural break breaks the model near-term, not only at the horizon. That limits a plain trend line to short forecast windows.
  • Look at the residuals. The residuals are the misses (actual − fitted). If they curve or fan out, a straight line is the wrong shape. And if they cycle up and down (high every Q4, low every Q3) the line is missing a seasonal pattern, the same within-year wave you met in Week 13 (think a farm stand that spikes every summer). A straight line cannot see seasonality; residuals that swing on a regular beat are the tell.
  • R² isn’t everything. A high \(R^2\) on a short, smooth series can still mislead; few data points = a fragile fit, and the same \(R^2\) says nothing about whether you should be extrapolating at all.

Back to the puzzle

The trend line is \(y = 112.82 + 7.35\,t\) with \(R^2 = 0.998\), so it forecasts about 179 for the next quarter (\(t = 9\)) and keeps pace with the climb, no lag. In words: enrollment is rising about 7 students a quarter, and the line explains nearly all of the variation. But that only holds if enrollment keeps growing linearly; the moment the program saturates, the slope is stale and the line over-promises.

In-class group practice (wrap-up)

To close Session 1, fit a trend line by hand in your group. Write your group’s names on the sheet and hand it to your TA before you leave. It counts toward participation.

🧩 Puzzle

A food bank notices its monthly demand seems to track local unemployment. If next month’s unemployment is forecast at 7%, what demand should it expect, and how much should it trust that number?

A trend model uses only one predictor: the clock. Regression is its explanatory cousin: instead of “forecast over time,” it relates the forecast to a factor that actually drives it. That’s the leap this session makes: from predicting the future because time passes to predicting an outcome from something we can measure and reason about, like the unemployment rate. Same least-squares line, a far more useful predictor.

Build the skill 1: regression is the same line, with any predictor

A linear regression fits \(y = a + b\,x\) just like the trend line, but the independent variable \(x\) can be any predictor, not just time (here, the unemployment rate), and the dependent variable \(y\) is the outcome being predicted. The slope \(b\) says “demand per point of unemployment,” and you predict \(y\) by plugging in an \(x\). The mechanics (least squares, \(r\), \(R^2\)) are identical; only the meaning of \(x\) changes. The trend animation in Session 1 is a regression, on the predictor “time.”

This widget still plots against time so you can see the fit, but the regression idea has nothing to do with time, so here is a genuine non-time example, drawn below as an actual scatter plot, to make \(x\) concrete.

Worked example (smoothie bar vs. temperature). A campus smoothie bar tracked eight days. The predictor \(x\) is the day’s high temperature (°F); the outcome \(y\) is that day’s sales (in hundreds of dollars):

High temp \(x\) (°F) 60 64 68 72 76 80 84 88
Sales \(y\) (\$100s) 28 33 37 44 49 54 60 65

These are not in time order. They are a cloud of \((x, y)\) points, a scatter plot, not a series marching left to right. Least squares fits \(y = -52.86 + 1.34\,x\) with \(r = 0.999\) and \(R^2 = 0.998\). Now say it in one sentence each:

  • Slope: “each extra degree of high temperature raises predicted sales by about \$134 (1.34 hundred dollars).”
  • \(R^2\): “temperature explains about 99.8% of the day-to-day variation in sales.”

To predict, plug in: on a forecast 85°F day, expected sales \(= -52.86 + 1.34(85) \approx 61\) hundred, i.e. about \$6,100. That is the whole move. Pick a real driver, fit the line, read off a prediction.

Here is that same data as an actual scatter plot: a cloud of \((x, y)\) points with no time axis anywhere. Press Fit least-squares line to drop the best line through the cloud and read its slope and \(R^2\):

Build the skill 2: interpret the slope and R², then mind causation

Two habits separate a defensible regression from a number that just looks scientific.

First, always interpret the coefficients in plain words (it’s worth points, and it’s the honest thing to do). For a fitted \(y = 12.4 + 1.8\,x\) with \(R^2 = 0.91\): “each extra unit of \(x\) raises predicted \(y\) by 1.8, and 91% of the variation in \(y\) is explained by \(x\) (the other 9% is noise or other factors).” If you can’t write that sentence, you don’t yet understand your own model.

Second, regression finds a relationship, not a cause. Unemployment may predict food-bank demand, but a high \(R^2\) doesn’t prove one drives the other. A third factor (a recession) could move both. This is the correlation ≠ causation trap, and it bites hardest exactly when the fit is good. Use regression to forecast; be careful before you claim “X causes Y.”

Beyond the book. Taylor 13e introduces regression as a forecasting method and defines \(r\)/\(R^2\), but the correlation-vs-causation caution, the residual-pattern diagnostics, and the out-of-range/extrapolation warning below are standard statistical practice we add on top. Sound habits that go a little past the chapter’s own treatment.

In practice: the classic regression traps

  • Correlation ≠ causation. A predictive relationship can vanish if you act on it as if it were causal. A high \(R^2\) measures how tightly two things move together, never why.
  • A negative slope is still a real relationship. If you regressed daily sales on price instead of temperature, the slope would be negative and the \(R^2\) could still be high. Don’t read “negative” as “weak”. Sign and strength are different facts (\(r\) carries the sign, \(R^2\) only the strength).
  • Out-of-range predictions. Predicting demand at 20% unemployment from data that never exceeded 9% is extrapolation. The relationship may not hold there, exactly as a trend line can’t be trusted far past its data.
  • One predictor is rarely the whole story. Real outcomes have many drivers; a single-variable regression is a useful first cut, not the final word. If the residuals still show a pattern, a second predictor is probably missing.

Back to the puzzle

Regression turns “demand seems to track unemployment” into a number. Fit \(y = a + b\,x\) on past months, plug in the forecast 7% unemployment, and read off the predicted demand, with \(R^2\) telling you how tight the relationship has been (and the slope telling you how many extra meals each point of unemployment has meant). Just don’t mistake a good predictor for a proven cause.

Last five minutes: rehearse your synthesis story

Week 16 draws names for the course-synthesis presentations, so this is the rehearsal and you want to be ready either day. Pair up and run your story once, using the five beats: problem, method, result, recommendation, caveat and what-if.

Then hand your partner the test: can they restate your recommendation and name your biggest caveat, unprompted? If not, the fix is a simpler story, never another slide.

After-class check

Questions spanning linear trend, slope and forecasting, interpreting \(r\) / \(R^2\), and regression vs. causation. Retry freely; nothing is submitted.

Weekly take-home (graded: submit on Canvas)

Everything for the take-home goes in one Excel workbook, and it fits the same line twice, once on time and once on a real driver. First a transit agency’s eight months of boardings: slope, intercept, \(R^2\), correlation and two forecasts at very different distances from the data, plus what the intercept actually describes once you say which month sits at t = 0. Then the same five functions on a fit where \(x\) is snow days and the slope is negative, with a correlation close to minus one. A relationship that is strong, not weak, and the case students most often misread. Neither fit tells you anything about cause. Three short responses plus the required AI-use disclosure go on the Free responses sheet, and the Instructions tab has the full step-by-step. Upload the completed .xlsx on Canvas. That one file is your entire submission.