Forecasting and Time-Series Analysis Questions
Analyzing and projecting data that moves over time. Covers trend and seasonality decomposition, forecasting approaches, demand modeling, and anomaly detection on time series. Emphasizes reasoning about baselines, drivers, and forecast reliability.
Explain the Holt-Winters (triple exponential smoothing) method for time-series forecasting. Describe its components (level, trend, seasonality), the difference between additive and multiplicative seasonality, how smoothing parameters (alpha, beta, gamma) affect responsiveness, and give business scenarios where Holt-Winters is an appropriate choice.
Sample Answer
Direct answer
Holt-Winters (triple exponential smoothing) forecasts a series by maintaining three continuously-updated smoothed components: level, trend, and seasonality, each with its own smoothing parameter (alpha, beta, gamma). It comes in additive and multiplicative seasonal variants depending on whether the seasonal swings stay a constant size or scale with the series' level.
Structured elaboration
- Level: the smoothed "current baseline" value of the series, updated each period the same way simple exponential smoothing updates its single smoothed value.
- Trend: the smoothed estimate of the period-over-period change in level, so the model can extrapolate a rising or falling baseline rather than a flat one.
- Seasonality: a smoothed multiplier or additive offset per position in the seasonal cycle (e.g. one value per day-of-week), re-estimated each time that position in the cycle recurs.
- Additive vs multiplicative seasonality: additive assumes the seasonal swing is a roughly CONSTANT absolute amount regardless of the series' level (e.g. "+200 units every December, whether the trend level is 1,000 or 5,000"); multiplicative assumes the swing SCALES with the level (e.g. "+20% every December"). Use additive when seasonal amplitude looks flat over time on a raw plot; use multiplicative when the seasonal swings visibly widen as the series grows (a classic tell: plot the series, and if the peaks-to-troughs gap grows alongside the trend, it's multiplicative).
- Smoothing parameters: alpha controls how fast the level reacts to new observations (high alpha = very responsive, more noise passed through; low alpha = smoother, slower to react to a real shift); beta similarly controls how fast the trend estimate updates; gamma controls how fast the seasonal profile itself is allowed to drift over time. All three are typically chosen by minimizing in-sample or backtested forecast error rather than set by hand.
- When Holt-Winters is a good choice: a business series with a clear, stable trend and a clear, stable seasonal period (retail sales with weekly or yearly seasonality, subscription-metric series with weekly cycles), especially when you want something simple, fast to fit, and easy to explain (three interpretable smoothed components) rather than the heavier machinery of SARIMA or a gradient-boosted model.
Worked example
A retailer's weekly sales show a steady 2%/quarter growth trend and a consistent seasonal bump every week 51-52 (holiday shopping) of roughly the same ABSOLUTE size in dollar terms regardless of the year's overall sales level in the recent data - that constant-absolute-size signature is the additive case, so additive Holt-Winters is the natural fit. If instead the December bump had been growing proportionally as the store's overall sales grew year over year (e.g. always about 40% above the trend level, not a fixed dollar amount), multiplicative seasonality (or a log-transform plus additive smoothing) would be the better-fitting choice.
Trade-offs & pitfalls
Holt-Winters assumes a single, fixed seasonal period known in advance - it doesn't naturally handle multiple overlapping seasonalities (e.g. both weekly AND yearly patterns in daily data) the way STL-with-multiple-periods or Prophet's Fourier terms can, and it has no native way to incorporate external regressors like promotions. It's also purely extrapolative: if the underlying regime genuinely changes (a step-change in trend), Holt-Winters adapts only as fast as its smoothing parameters allow, which can mean a lagging response right when it matters most.
Explain the ARIMA model components: AR(p), I(d), MA(q). For each component give intuition about what it captures, how you would identify appropriate orders using ACF/PACF and stationarity tests, and when to include seasonal terms (SARIMA).
Sample Answer
Direct answer
ARIMA(p,d,q) models a series as a combination of three pieces: AR(p), autoregression on the series' own past p values; I(d), the number of times you difference the series to make it stationary; and MA(q), a moving average of the past q forecast errors. You identify p and q by reading the ACF and PACF plots of the (differenced) series, and you add seasonal terms (SARIMA) when the ACF/PACF still show a repeating spike pattern at the seasonal lag after ordinary differencing.
Structured elaboration
- AR(p): today's value is a linear function of the last p values plus noise. A PACF that cuts off sharply after lag p (with earlier lags significant) points to an AR(p) term, because the PACF isolates the direct effect of each lag after removing the effect of the lags in between.
- I(d): the number of times you difference yt (i.e. work with yt−yt−1, or the second difference) before the series is stationary. You determine d with a stationarity test (ADF/KPSS) rather than by eye: difference until the test says stationary, and stop as soon as it does. Over-differencing (d too large) introduces artificial negative autocorrelation and inflates forecast variance.
- MA(q): today's value depends on the last q forecast errors, not raw values. An ACF that cuts off sharply after lag q (while the PACF decays slowly) points to an MA(q) term.
- Order identification in practice: plot ACF and PACF of the differenced series. AR signature = PACF cuts off, ACF tails off. MA signature = ACF cuts off, PACF tails off. Mixed ARMA signatures (both tail off) are common in practice, so analysts usually also compare a small grid of candidate (p,d,q) by AIC/BIC rather than trusting the plots alone.
- When to add seasonal terms (SARIMA): if, after taking the ordinary difference, the ACF/PACF still show significant spikes at the seasonal period (e.g. lag 7 for daily-with-weekly-seasonality data, lag 12 for monthly-with-yearly-seasonality), a plain ARIMA hasn't captured the seasonal structure. SARIMA adds seasonal AR/MA/differencing terms (P,D,Q)s operating at multiples of the seasonal period s, on top of the ordinary (p,d,q) terms.
Worked example
Take daily retail sales with a weekly pattern. Fitting an ARIMA(1,1,1) leaves a residual ACF with a clear spike at lag 7 (and 14, 21) - the model has removed the trend (via d=1) but not the weekly repetition. Adding a seasonal term, e.g. SARIMA(1,1,1)(1,0,1)7, lets the seasonal AR/MA terms absorb that lag-7 structure; after refitting, the residual ACF should show no significant spikes at multiples of 7. Concretely: raising d from 0 to 1 changes what "capturing p and q" even means, since AR(p)/MA(q) are now fit on the differenced series, not the raw one - a common early mistake is reading ACF/PACF on the raw series and getting orders that don't apply once differencing is applied.
Trade-offs & pitfalls
Adding seasonal terms multiplies the number of parameters and the search space (p,d,q,P,D,Q,s); over-specifying any one of them (especially D, seasonal differencing) can remove real signal along with the seasonality. A senior candidate will also flag that pure ACF/PACF reading is a starting point, not a final answer: automated order search guided by AIC/BIC (or pmdarima.auto_arima) is standard practice once the visual signature is ambiguous, and the final choice should always be checked with a residual diagnostic (no significant autocorrelation left, e.g. a Ljung-Box test) rather than trusted from the identification step alone.
Write pseudocode or Python code to detect anomalies (spikes or drops) in a Daily Active Users time series using seasonal decomposition and Median Absolute Deviation (MAD) on residuals. Explain how you would select thresholds to control false positives and how to handle known holidays or seasonal events.
Sample Answer
Direct answer
A practical decomposition-residual anomaly detector: run seasonal decomposition, compute the Median Absolute Deviation (MAD) of the residual, flag points whose residual is more than a chosen number of MADs from the median (a robust z-score), and treat known holidays as either excluded from threshold-fitting or modeled explicitly rather than left to trip the same generic threshold as an unexplained anomaly.
Structured elaboration and worked example (executed)
Against a synthetic 180-day daily series (seed=0: linear trend + weekly sinusoidal seasonality + Gaussian noise) with 3 known injected anomalies (two +300 spikes at indices 60 and 120, one -300 drop at index 150):
import numpy as np, pandas as pd
from statsmodels.tsa.seasonal import seasonal_decompose
np.random.seed(0)
n = 180
t = np.arange(n)
y = 1000 + 2*t + 50*np.sin(2*np.pi*t/7) + np.random.normal(0, 15, n)
y[60] += 300; y[120] += 300; y[150] -= 300
result = seasonal_decompose(pd.Series(y), model="additive", period=7, extrapolate_trend="freq")
resid = result.resid.dropna()
mad = np.median(np.abs(resid - np.median(resid)))
robust_z = 0.6745 * (resid - np.median(resid)) / mad
flagged = resid.index[np.abs(robust_z) > 3.5]
Executed result:
Injected anomaly indices: [60, 120, 150]
MAD-flagged indices (threshold 3.5): [60, 120, 121, 150, 151]
True positives: [60, 120, 150]
False positives: [121, 151]
All 3 injected anomalies were correctly detected at threshold 3.5, with 2 false positives immediately adjacent to two of the true anomalies - a real and expected pattern: weekly seasonal decomposition can partially "smear" a sharp anomaly's effect into an adjacent day's residual through the seasonal-averaging step, which is a genuine practical trade-off (a tighter threshold reduces these adjacent false positives but risks missing smaller genuine anomalies).
- Selecting thresholds to control false positives: MAD-based robust z-scores are preferred over plain standard-deviation z-scores because the SD itself is inflated by the very anomalies you're trying to detect, while the median-based MAD is robust to them; the threshold (here 3.5) trades off sensitivity vs false-positive rate, and should be tuned against a labeled historical set of known true/false anomalies where available, rather than picked by convention alone.
- Handling known holidays or seasonal events: a fixed weekly-seasonal decomposition has no way to represent a one-off holiday's effect, so a holiday will look like a large residual and either get flagged as a false-positive "anomaly" or, if severe enough, distort the fitted seasonal profile itself. Two practical fixes: exclude known holiday dates from the data used to FIT the seasonal profile (so they don't contaminate the baseline), and either give holidays their own separate explicit effect (as Prophet's holiday component does) or accept they'll always need to be checked against a holiday calendar before treating a flagged residual as unexplained.
Trade-offs & pitfalls
MAD-on-residuals is a solid default but is still a GLOBAL threshold across the whole series - if residual variance itself changes over time (heteroskedasticity), a single global MAD will be too loose during low-variance periods and too tight during high-variance ones; a rolling-window MAD, recomputed locally rather than once over the whole history, addresses this at the cost of needing enough local history to estimate a stable MAD in each window. Always validate any chosen threshold against a small set of known true anomalies (as done above) rather than trusting a textbook multiplier (like "3 sigma") without checking it against your own data's behavior.
Discuss responsible AI and governance considerations specific to forecasting systems. Cover detection and mitigation of bias across regions or product lines, fairness when forecasts drive allocation decisions, data retention and privacy of training data, and what operational governance practices you would put in place to keep the system auditable and correctable over time.
Sample Answer
Direct answer
Responsible AI and governance for forecasting systems means checking whether the model treats different regions or product lines fairly (not just accurately on average), protecting the privacy of training data, and running the operational governance machinery - model cards, periodic audits, defined remediation processes - that make the whole system auditable and correctable rather than a black box that only gets scrutinized after something visibly goes wrong.
Structured elaboration
- Detecting bias across regions or product lines: check forecast accuracy and, separately, forecast BIAS (systematic over- or under-prediction) broken out BY segment (region, product line), not just in aggregate - a model that's unbiased on average can still systematically under-forecast one region while over-forecasting another, which is invisible to an aggregate accuracy check but very real in its downstream consequences.
- Mitigating detected bias: once a segment-specific bias is confirmed (not just suspected from a single period, but validated the way any bias-detection exercise should be, with a proper statistical check), remediation options range from a segment-specific recalibration correction to retraining with segment-balanced data or segment-aware features, chosen based on WHY the bias exists (a data-representation issue vs a genuine, harder-to-model difference in that segment's underlying dynamics).
- Fairness when forecasts drive allocation decisions: when a forecast feeds directly into an ALLOCATION decision (inventory, staffing, incentive dollars distributed across regions), a systematic forecasting bias against one region translates directly into that region being under-served - this is the concrete mechanism by which a "purely technical" forecasting bias becomes a real fairness issue, and it's the reason bias detection here needs to be checked specifically against WHATEVER downstream decision the forecast drives, not evaluated as an abstract accuracy statistic alone.
- Data retention and privacy: forecasting models trained on customer-level or location-level transaction data inherit the same retention-limits and privacy-handling obligations as any other system using that data - define and enforce a retention policy for training data, and ensure the model itself (and any cached intermediate features) doesn't become an unintended long-term store of data that should have been deleted under the organization's stated retention policy.
- Operational governance practices: model cards (a standardized, versioned document describing a model's intended use, known limitations, training-data characteristics, and validated performance across segments) make a model's fairness/bias characteristics legible to anyone who needs to evaluate or approve its use, rather than requiring a fresh investigation each time; periodic audits (a scheduled, recurring re-check of segment-level bias and accuracy, not just a one-time pre-launch check) catch drift into unfairness that emerges only after deployment; a defined remediation process (what happens, and who's accountable, once an audit finds a problem) ensures a detected issue actually gets fixed rather than merely documented.
Worked example
An automated demand-allocation system that systematically under-forecasts demand in lower-income neighborhoods (perhaps because those areas have historically been served by fewer marketing dollars, and the model has learned that pattern as if it were an accurate reflection of true underlying demand rather than a historical resourcing artifact) would, if left unchecked, perpetuate and even reinforce that under-service through the forecast-driven allocation decision itself - detecting this requires deliberately checking bias BY neighborhood income level (not something an aggregate accuracy metric would surface on its own), and the mitigation needs to address the root cause (the historical resourcing pattern baked into the training data) rather than just a numeric recalibration that treats the symptom.
Trade-offs & pitfalls
The most consequential governance gap is treating fairness/bias review as a one-time, pre-launch checklist item rather than an ongoing, periodically-repeated audit - a model that was checked and cleared at launch can still drift into segment-specific bias over time as the underlying data and business context evolve, and only a recurring audit cadence (not a single point-in-time check) catches that drift before it compounds into a real, sustained allocation harm.
You are asked to implement a monitoring metric that measures business value of forecasts and not just accuracy. Propose specific KPIs such as stockouts prevented, holding cost reduction, or revenue uplift, explain how to compute them from historical forecasts and actuals, and describe attribution challenges when multiple operational changes occurred simultaneously.
Sample Answer
Direct answer
Moving beyond raw accuracy, a forecast's business value can be measured through KPIs like stockouts prevented, holding-cost reduction, and revenue uplift - each computed by comparing what actually happened (with the forecast-driven decision in place) against a credible counterfactual of what would have happened under a naive or prior approach, with attribution challenges handled by isolating the forecast's specific contribution from other simultaneous operational changes.
Structured elaboration
- Stockouts prevented: compare the actual stockout rate under the current (forecast-informed) inventory policy against a counterfactual - either the stockout rate the OLD policy would have produced on the same demand realization (if you can simulate it), or a controlled holdout where a subset of SKUs/stores continued using the old approach as a genuine comparison group.
- Holding-cost reduction: compute the excess inventory carried under the old policy versus the new forecast-informed one, valued at the business's actual holding-cost rate (capital cost, storage, spoilage/obsolescence risk) - this requires the SAME kind of counterfactual comparison as stockouts, not just "inventory went down," since inventory could fall for unrelated reasons (a demand drop, say).
- Revenue uplift: the incremental revenue attributable to better availability/staffing/allocation decisions the improved forecast enabled, computed similarly by comparison against a credible counterfactual rather than simply period-over-period revenue growth (which conflates many causes).
- Computing these from historical forecasts and actuals: requires not just the forecast and the actual outcome, but a record of what DECISION the forecast drove (the resulting inventory order, staffing level, allocation) so you can quantify the downstream operational consequence, not just the raw forecast error - a forecast can be numerically accurate yet drive a poor decision if the decision rule built on top of it (e.g. the safety-stock formula) is miscalibrated.
- Attribution challenges when multiple changes happen simultaneously: if inventory policy, pricing, AND the forecasting model all changed in the same quarter, isolating the forecast's specific contribution to any observed improvement requires either staggering the rollouts (so each change's effect window is at least partially separable), a genuine holdout/control group that kept the old forecast while everything else changed identically, or, at minimum, an honest acknowledgment in the reporting that the estimate is a joint effect of several changes rather than the forecast's alone.
Worked example
A holding-cost-reduction claim of "$500K saved this quarter" is only credible if it's benchmarked against a stated counterfactual (e.g. "versus the safety-stock levels the prior policy would have required for the same realized demand") - reported without that counterfactual, the number is really just "inventory happened to be lower," which could equally reflect a demand slowdown having nothing to do with forecast quality.
Trade-offs & pitfalls
The recurring failure mode across all three KPIs is presenting a raw before/after comparison as if it were the forecast's isolated causal contribution, when in a real operating business, demand, pricing, promotions, and policy all move simultaneously - treat any business-value number without an explicit counterfactual or control group as a directional estimate, not a precise measurement, and say so plainly when reporting it.
Unlock Full Question Bank
Get access to all 30 Forecasting and Time-Series Analysis interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.