Time-Series ForecastingIntroduction and ContextTime-series forecasting estimates future values from observations ordered in time. Businesses use forecasts to plan inventory, staffing, cash, production capacity, marketing, and service operations. Examples include weekly sales, daily website traffic, monthly revenue, hourly electricity demand, loan defaults, and quarterly cash flows. Forecasting differs from ordinary predictive modelling in one central respect: the order of observations matters. A model trained using information from the future can appear highly accurate while being unusable in practice. Therefore, a sound forecasting process must represent temporal dependence, preserve chronological order, reproduce the information available at the forecast date, and evaluate predictions on genuinely future observations. A time series is commonly written as yt, where t identifies a time period. A forecast made at time t for h periods ahead is written \hat{y}t+h|t, meaning the predicted value at t+h using information available through t. Learning ObjectivesBy the end of this chapter, you should be able to: - Distinguish trend, seasonality, cycles, irregular variation, and temporal dependence.
- Construct appropriate naive and seasonal-naive baselines.
- Explain and apply moving averages and exponential-smoothing models.
- Describe ARIMA modelling, differencing, autocorrelation, and model diagnostics.
- Prepare time-dependent data for machine-learning models without leakage.
- Compare forecasts using suitable accuracy measures and backtesting.
- Select forecasting methods for sales, finance, inventory, staffing, and capacity planning.
- Recognize uncertainty, ethical, governance, and operational limitations.
1. The Structure of a Time SeriesA useful conceptual decomposition is: yt = Tt + St + Ct + It Here, Tt is the underlying trend, St is seasonal variation repeating at a known frequency, Ct is longer-term cyclical movement, and It is irregular or unexplained variation. This is an additive decomposition, appropriate when the size of seasonal fluctuations is approximately constant. A multiplicative decomposition is often more suitable when variation increases with the level: yt = Tt × St × Ct × It The multiplicative model requires positive observations. Taking logarithms converts multiplication into addition: \log(yt)=\log(Tt)+\log(St)+\log(Ct)+\log(It), provided yt>0. TrendTrend is a persistent long-run direction. It may be approximately linear, curved, or interrupted by structural breaks. A rising trend in online orders may result from market expansion; a declining trend in a product may indicate substitution or obsolescence. Trend should not be confused with a short sequence of increases. SeasonalitySeasonality is a systematic pattern tied to the calendar or a fixed operational cycle. Retail sales may rise every December; call-centre demand may peak every Monday morning. If monthly data have annual seasonality, the seasonal period is m=12. For hourly data with daily repetition, m=24 may be appropriate, although working-day effects can require additional variables. CyclesCycles are medium- or long-term fluctuations without a fixed, known period. Economic expansions and contractions are cyclical, but their duration is not exactly predictable. Seasonal patterns are calendar-based; cycles are not. Temporal DependenceTemporal dependence means that observations close in time, or observations separated by a meaningful lag, are statistically related. The lag-1 autocorrelation is the correlation between yt and yt-1. Strong dependence means that recent observations or past errors may improve prediction. Dependence can concern the level, trend, seasonality, or residuals. A stationary series has statistical properties such as mean and variance that are stable over time, and dependence that does not change merely because the calendar advances. Many ARIMA methods require stationarity after transformation or differencing; raw sales data often are not stationary. 2. Data Preparation and ExplorationA forecasting project begins with a clear forecast target, time frequency, horizon, and decision use. The analyst should establish whether the data are transactional or already aggregated, whether time intervals are regular, and whether missing periods represent zero demand or missing measurement. Important preparation tasks include: - sorting records chronologically;
- standardizing time zones and period definitions;
- aggregating transactions consistently;
- identifying duplicated timestamps;
- recording promotions, prices, holidays, stockouts, strikes, and system changes;
- distinguishing true zero demand from unavailable inventory;
- treating outliers according to business cause rather than automatically deleting them.
Exploratory analysis should use a time plot, seasonal summaries, rolling means and variances, and autocorrelation plots. A rolling mean over a window of k observations is: MAt = (1/k) × ∑i=0k-1 yt-i It smooths short-term noise but creates fewer usable observations near the beginning and can obscure abrupt changes. The window must be compatible with the data frequency and analytical purpose. The sample autocorrelation at lag k is commonly calculated as: rk = [∑t=k+1n(yt − ȳ)(yt-k − ȳ)] / [∑t=1n(yt − ȳ)2] where n is the number of observations and ȳ is the sample mean. This statistic describes linear association at lag k; it does not prove causation. 3. Forecasting BaselinesA sophisticated model is valuable only if it improves on a simple alternative. Baselines provide a benchmark and reveal whether apparent complexity adds predictive value. Mean and Drift MethodsThe mean forecast uses the historical average: \hat{y}t+h|t = ȳt = (1/t) × ∑i=1t yi It is useful for stable series but reacts slowly to trend. A drift forecast extends the average historical change: \hat{y}t+h|t = yt + h × (yt − y1)/(t−1) This assumes a roughly linear average movement between the first and latest observations. Naive and Seasonal-Naive MethodsThe naive forecast uses the most recent observation: \hat{y}t+h|t = yt For seasonal data, the seasonal-naive forecast repeats the value from the corresponding previous season: \hat{y}t+h|t = yt+h−m where m is the seasonal period. For monthly data with annual seasonality, December forecasts use the previous December. This method is often difficult to beat when seasonality is strong and stable. 4. Exponential SmoothingExponential-smoothing methods assign greater weight to recent observations while retaining information from the past. Simple Exponential SmoothingFor data with no systematic trend or seasonality, level [[MATH;\ell_t]] is updated as: ℓt = αyt + (1−α)ℓt−1, 0 < α < 1 The one-step forecast is: \hat{y}t+1|t = ℓt A larger α reacts rapidly to recent changes; a smaller value produces smoother forecasts. Initial level selection affects early estimates, so software commonly estimates it or evaluates alternatives. Holt’s Linear Trend MethodHolt’s method models level and trend: ℓt = αyt + (1−α)(ℓt−1+bt−1) bt = β(ℓt−ℓt−1) + (1−β)bt−1 \hat{y}t+h|t = ℓt + hbt Here, bt is the estimated trend, and β satisfies 0<β<1. The method can produce unrealistic long-horizon values when a trend cannot continue indefinitely. Holt–Winters Seasonal MethodFor additive seasonality, a common formulation is: ℓt = α(yt−st−m) + (1−α)(ℓt−1+bt−1) bt = β(ℓt−ℓt−1) + (1−β)bt−1 st = γ(yt−ℓt) + (1−γ)st−m \hat{y}t+h|t = ℓt + hbt + st−m+1+((h−1) mod m) The parameters α, β, and γ lie between 0 and 1. The additive formulation assumes seasonal amplitude is approximately constant. Multiplicative seasonality instead uses ratios such as yt/ℓt and requires positive data. Parameter estimation commonly minimizes in-sample error, but final selection must rely on time-ordered validation. 5. ARIMA ModelsARIMA combines autoregression, differencing, and moving-average error terms. An ARIMA(p,d,q) model has autoregressive order p, differencing order d, and moving-average order q. Seasonal ARIMA extends this notation to ARIMA(p,d,q)(P,D,Q_m). An AR(p) model is: yt = c + φ1yt−1 + φ2yt−2 + … + φpyt−p + εt where εt is a zero-mean, uncorrelated innovation with constant variance under the basic model, and φi are coefficients. An MA(q) model uses past shocks: yt = μ + εt + θ1εt−1 + … + θqεt−q A practical ARIMA model is usually expressed after differencing. First differencing is: Δyt = yt − yt−1 Seasonal differencing is: Δm yt = yt − yt−m Differencing should remove nonstationary trend or seasonality without being excessive. Over-differencing can increase noise and produce poor forecasts. The Box–Jenkins workflow is iterative: - Identify structure using plots and domain knowledge.
- Transform or difference when necessary.
- Propose orders using autocorrelation and partial autocorrelation patterns, while respecting parsimony.
- Estimate parameters.
- Diagnose residuals.
- Compare candidate models using time-based validation and business consequences.
A good residual series should have little remaining autocorrelation, approximately stable variance, and no systematic pattern. The Ljung–Box test can assess whether a group of residual autocorrelations is jointly different from zero, but a non-significant result is not proof that the model is correct. Residual plots and operational knowledge remain essential. 6. Machine-Learning ForecastingMachine-learning models treat forecasting as supervised learning. A time series is converted into predictors such as lags, rolling statistics, calendar variables, prices, promotions, weather, holidays, and competitor information. For example, a feature vector might contain yt−1, yt−7, a seven-day rolling mean, day-of-week indicators, and a promotion flag. A regression model then estimates demand from these features. Tree ensembles can represent nonlinear interactions; regularized linear models are often more interpretable; neural networks may be useful with large, complex, multivariate datasets but are not automatically superior. Critical safeguards include: - create lag and rolling features using past values only;
- fit transformations using training data only;
- use chronological train, validation, and test sets;
- avoid random shuffling;
- ensure every external predictor is actually known at forecast time;
- distinguish recursive multi-step forecasting from direct horizon-specific models.
Recursive forecasting predicts one step, feeds that prediction back as a future lag, and repeats. Errors can accumulate. Direct forecasting estimates a separate model for each horizon, which may be more stable but requires more models. A global model can train across many related products or locations, using product and location identifiers as features. 7. Forecast Evaluation and UncertaintyLet et=yt−\hat{y}t be the forecast error. Common measures include: MAE = (1/n) × ∑|et| RMSE = √[(1/n) × ∑et2] MAPE = (100/n) × ∑|et/yt| MAE is in the same units as the target and is easy to interpret. RMSE penalizes large errors more heavily. MAPE is scale-free but is undefined when yt=0 and unstable for values near zero. For intermittent or zero-heavy demand, use MAE, RMSE, weighted absolute percentage error, or scaled measures such as MASE rather than relying on MAPE. A forecast should also provide an interval, not only a point estimate. A nominal 95% prediction interval is intended to contain the future observation in approximately 95% of repeated comparable cases. It is not a guarantee for one particular observation. Intervals should widen with horizon and account for parameter, innovation, and model uncertainty. Time-series cross-validation uses rolling-origin evaluation. For example, train on periods 1–24 and test period 25, then train on periods 1–25 and test period 26. Expanding windows retain all prior data; sliding windows retain a fixed recent history. The design should match the business process. A model that wins on average may still be unsuitable if it fails catastrophically during peak demand. 8. Worked Example: Weekly Store DemandSuppose weekly demand for a product over five weeks is 100, 110, 105, 115, and 120 units. A naive forecast for week 6 is 120 units. A three-week moving-average forecast is: (105 + 115 + 120)/3 = 113.33 units The naive method follows the latest level; the moving average smooths fluctuations. If the product has a strong seven-week operational pattern, a seasonal-naive method would require at least one prior complete seasonal cycle and should be preferred over an arbitrary moving average when the seasonal relationship is credible. Assume actual demand in week 6 is 125 units. The naive absolute error is |125−120|=5 units, whereas the moving-average absolute error is approximately |125−113.33|=11.67 units. On this single observation, naive forecasting is better. One observation cannot establish general superiority; rolling-origin evaluation is required. 9. Illustrative Case: Retailer Capacity PlanningBackgroundA fictional online retailer sells household goods and must schedule warehouse labour weekly. Demand rises before holidays, promotions create sudden peaks, and stockouts cause recorded sales to understate true demand. ProblemThe retailer used last month’s total sales as next month’s forecast. This ignored weekly seasonality and promotional campaigns, producing excess labour in quiet periods and shortages during peaks. AnalysisThe analytics team plotted weekly demand, marked promotions and holidays, and found strong annual seasonality, a gradual upward trend, and several stockout weeks. It separated observed sales from estimated unconstrained demand where inventory records showed lost sales. A seasonal-naive model, Holt–Winters model, ARIMA model, and gradient-boosted model using lagged demand, promotion indicators, price, holiday flags, and product category were compared. Approach and SolutionThe team used expanding-window backtesting with a four-week forecast horizon. Models were evaluated using MAE and a weighted service-risk measure that penalized under-forecasting more than over-forecasting during peak weeks. Features were generated only from information available before each forecast origin. Prediction intervals were converted into staffing scenarios: baseline staffing at the point forecast and contingency staffing at an upper quantile. OutcomeThe selected model was not the most complex model in every category. The machine-learning model performed best during promotions, while Holt–Winters was more stable for ordinary seasonal weeks. The retailer therefore adopted a segmented approach: machine learning for promoted products and exponential smoothing for stable products, with human review for exceptional campaigns. Forecasts were monitored weekly using error, bias, interval coverage, and stockout outcomes. Learning PointsThe case demonstrates that model selection is a business decision, not a contest based on one accuracy score. Data quality, known future variables, asymmetric costs, forecast horizons, and operational constraints determine value. It also illustrates why hybrid or segmented forecasting can be more appropriate than forcing one algorithm onto every series. 10. Applications Across Business FunctionsSales and marketing: Forecast revenue, units, campaign response, and customer traffic. Include promotions and price changes only when their future values are known or scenario-planned. Finance: Forecast cash flows, liquidity, interest-related measures, and transaction volumes. Financial series may exhibit volatility, regime changes, and dependence in variance; forecasts should not be interpreted as investment guarantees. Inventory: Forecast demand at the item-location level. Separate demand from sales constrained by stock availability. Forecast distributions are particularly valuable because inventory decisions depend on service levels and shortage costs. Staffing: Forecast workload, arrivals, handling time, and absenteeism. Daily or intraday seasonality and labour rules may be operationally important. Capacity planning: Forecast machine utilization, energy demand, logistics volumes, or server traffic. Scenario analysis is essential when capacity decisions are costly or irreversible. 11. Limitations, Governance, and Contemporary PracticeForecasts are conditional statements, not facts. Structural breaks, pandemics, regulatory changes, competitor actions, new products, and data-system failures can invalidate historical relationships. Forecasts can also reinforce bias: staffing models based on historically unequal service allocation may reproduce that inequality. Governance should document the target, horizon, data sources, transformations, model version, forecast origin, assumptions, responsible owner, and approval process. Monitor data drift, residual bias, forecast revision, interval coverage, and performance by product, region, or customer group. Access controls and privacy protections are necessary when forecasts use customer or employee data. Explainability matters when forecasts influence employment, credit, resource access, or public services. Human review should be meaningful rather than merely ceremonial. Overrides should be logged and evaluated, since intuition can improve forecasts when it incorporates genuine new information but can also introduce inconsistent bias. Contemporary practice increasingly combines statistical models with machine learning, uses hierarchical forecasting to reconcile product and regional totals, and produces probabilistic forecasts rather than only point predictions. Automated systems can improve scale, but automation does not remove the need for sound time definitions, leakage prevention, monitoring, and managerial judgment. Best-Practice Workflow- Define the decision, target, frequency, horizon, and cost of errors.
- Audit timestamps, missingness, outliers, stockouts, and structural changes.
- Plot level, trend, seasonality, rolling variation, and autocorrelation.
- Establish mean, naive, drift, and seasonal-naive baselines.
- Fit candidate exponential-smoothing, ARIMA, and machine-learning models.
- Use chronological backtesting with horizon-appropriate metrics.
- Check residuals, bias, interval coverage, stability, and subgroup performance.
- Select a model or ensemble based on predictive and operational value.
- Deploy with versioning, monitoring, override controls, and retraining rules.
- Review forecasts against actual decisions and outcomes, not accuracy alone.
Chapter SummaryTime-series forecasting uses ordered historical observations to estimate future outcomes. Trend describes long-run movement, seasonality repeats at a known frequency, cycles fluctuate over less predictable periods, and temporal dependence links observations across time. Baselines such as naive and seasonal-naive forecasts are essential benchmarks. Exponential smoothing provides adaptive level, trend, and seasonal models, while ARIMA represents autoregression, differencing, and moving-average errors. Machine-learning methods can incorporate nonlinear relationships and external predictors, but they require careful lag construction and strict prevention of data leakage. Forecasts should be evaluated through rolling-origin backtesting using metrics suited to the target and business costs. Prediction intervals, monitoring, governance, and human interpretation are as important as point accuracy. Effective forecasting connects statistical modelling to decisions in sales, finance, inventory, staffing, and capacity planning. Key TermsTime series: Observations indexed in chronological order. Forecast origin: The latest time point whose information is available when producing a forecast. Forecast horizon: Number of periods between the forecast origin and the predicted period. Trend: Persistent long-run direction in a series. Seasonality: Repeating variation associated with a fixed calendar or operational period. Cycle: Medium- or long-term fluctuation without a fixed period. Stationarity: Approximate stability of a series’ statistical properties over time. Autocorrelation: Correlation between observations separated by a specified lag. Lag: A prior observation or predictor at a defined time distance. Baseline: A simple benchmark forecast used for comparison. Naive forecast: Forecast that repeats the latest observed value. Seasonal-naive forecast: Forecast that repeats the value from the corresponding previous season. Exponential smoothing: Forecasting approach that weights recent observations more heavily. ARIMA: Model combining autoregression, differencing, and moving-average errors. Differencing: Subtracting an earlier observation to reduce nonstationarity. Residual: Observed value minus fitted or forecast value. Backtesting: Simulated historical forecasting used to evaluate models. Data leakage: Use of information unavailable at the forecast origin. Prediction interval: Range intended to contain a future observation with stated coverage. Hierarchical forecasting: Forecasting related series while maintaining coherent aggregate totals. Review QuestionsShort Answer Questions- What distinguishes seasonality from a cycle?
- Why is a seasonal-naive forecast a useful benchmark?
- What does the smoothing parameter α control in simple exponential smoothing?
- Why can MAPE be inappropriate when actual values are zero?
- What is data leakage in time-series forecasting?
Long Answer Questions- Explain additive and multiplicative decomposition and identify situations appropriate for each.
- Compare Holt–Winters and ARIMA models in terms of structure, assumptions, and use cases.
- Describe a rigorous rolling-origin backtesting process for a four-period forecast horizon.
- Explain how a business should combine point forecasts, prediction intervals, and asymmetric decision costs.
- Discuss governance requirements for a forecasting system used to schedule employees.
Analytical / Application Questions- A retailer has weekly demand with strong annual seasonality and frequent promotions. Design a forecasting and evaluation strategy, including baselines, features, validation, and decision metrics.
- A machine-learning model has lower average MAE but produces severe under-forecasts during peak periods. Should it be selected? Justify your answer using operational and statistical reasoning.
- A monthly series shows increasing seasonal amplitude and strictly positive values. Recommend transformations or model classes, explain the assumptions, and describe how you would test the recommendation.
Multiple Choice Questions with AnswersQuestion 1Which pattern is associated with a known, repeating calendar frequency? A. Trend B. Seasonality C. Cycle D. Irregular variation Correct Answer: B. Seasonality Question 2A seasonal-naive forecast for a monthly series with annual seasonality uses which observation? A. The overall historical mean B. The immediately preceding month only C. The observation 12 months earlier D. The first observation in the series Correct Answer: C. The observation 12 months earlier Question 3In simple exponential smoothing, increasing α generally makes the forecast: A. More responsive to recent observations B. Independent of recent observations C. More dependent on annual seasonality D. Unable to use previous estimates Correct Answer: A. More responsive to recent observations Question 4Which metric is undefined when an actual value equals zero? A. MAE B. RMSE C. MAPE D. Median absolute error Correct Answer: C. MAPE Question 5What is the primary purpose of differencing in ARIMA modelling? A. To increase the number of observations B. To reduce nonstationarity C. To remove all outliers automatically D. To guarantee zero forecast error Correct Answer: B. To reduce nonstationarity Question 6Which validation design is most appropriate for ordinary time-series forecasting? A. Randomly shuffle all observations before splitting B. Use only the first observation as the test set C. Use chronological rolling-origin evaluation D. Train and test on the same observations Correct Answer: C. Use chronological rolling-origin evaluation Question 7A forecast error is defined in this chapter as: A. Forecast minus the time index B. Observed value minus forecast value C. Observed value divided by forecast value D. Forecast plus observed value Correct Answer: B. Observed value minus forecast value Question 8Which practice prevents a common form of forecasting leakage? A. Creating rolling means using future observations B. Using only information available at the forecast origin C. Randomly shuffling dates D. Replacing all missing values with future actuals Correct Answer: B. Using only information available at the forecast origin Question 9If a business heavily penalizes under-forecasting during peak demand, model selection should: A. Use only an unweighted average error B. Ignore peak periods C. Include asymmetric operational costs D. Choose the model with the longest name Correct Answer: C. Include asymmetric operational costs Question 10Prediction intervals are intended to: A. Guarantee the exact future value B. Describe a plausible range for a future observation C. Replace all point forecasts D. Eliminate structural breaks Correct Answer: B. Describe a plausible range for a future observation
|