Time Series interview question

Machine LearningTime Seriesmedium

Both series below rise at a similar average rate. Series A was generated as a linear trend plus stationary noise; Series B is a random walk with drift. Which statement about them is correct?

20406080020406080100TimeValueSeries ASeries BTrend 20 + 0.5t
  1. ABoth should be first-differenced, since any visible upward trend implies a unit root, and differencing a trend-stationary series leaves its residual structure unchanged.
  2. BA shock to Series A fades as the series returns to its trend line, so detrend it; a shock to Series B shifts its whole future path permanently, so difference it.
  3. CA shock to Series A shifts its whole future path permanently, so difference it; a shock to Series B fades as the series returns to its trend line, so detrend it.
  4. DBoth should be detrended by a regression on time, since once the fitted linear trend is removed, the residuals of a random walk with drift are stationary as well.
Show the answer and explanation

Correct answer: B, A shock to Series A fades as the series returns to its trend line, so detrend it; a shock to Series B shifts its whole future path permanently, so difference it.

Explanation Time Series

Two very different processes can both look like "a series going up":

Trend-stationaryDifference-stationary
Modelyₜ = a + b·t + uₜ, with uₜ stationaryyₜ = b + yₜ₋₁ + εₜ (unit root)
Effect of a shocktemporary: decays back to the trendpermanent: shifts the whole future path
Remedyregress on time (detrend)first difference
Forecast interval widthboundedgrows with √h

In the chart, Series A keeps crossing the dashed trend line: deviations die out. Series B sits far below the line around t ≈ 30 and ends well above it. It has no line to return to, because every shock accumulates.

Why the wrong options fail:

  • Detrending a random walk leaves a random walk around the fitted line: the residuals are still non-stationary, and regressions on them can be spurious.
  • Differencing a trend-stationary series does change the residual structure: Δuₜ = uₜ − uₜ₋₁ has an MA unit root (over-differencing), so the differenced model is non-invertible, which complicates estimation and forecasting.
  • Swapping the two mixes up which process has permanent shocks.

In practice, test with ADF including a trend term (H0: unit root) and KPSS with a trend (H0: trend-stationary). Many business series are borderline; differencing is the safer default for short horizons, while detrending gives tighter long-range intervals when it is truly justified.

Interview tip: the phrase interviewers want is "shocks are transitory versus permanent". Then tie it to the remedy and to how the prediction intervals behave.

Practice it as a quiz

Answer this and the other free questions with instant grading, streaks and weak-topic tracking, or unlock all 4,000 questions.

More Machine Learning questions

  1. A churn model produced this confusion matrix on 10,000 customers, and a manager celebrates its 98.8% accuracy. What is the model's balanced accuracy, and what…
  2. For the query "waterproof hiking boots", assessors graded four products as relevant: Boot-X (3), Boot-Y (3), Boot-Z (2) and Sock-K (1); every other product is…
  3. A gradient-boosted tree model was trained on months 1–36 of demand, using month_index as a feature. Its forecast for months 37–48 is the flat line in the…
  4. A telecom churn model (3% churners) is evaluated with the code below and reports a mean CV recall of 0.99. On customers that were set aside before any…
  5. An insurer has 3,000 claims confirmed as fraud and 120,000 claims nobody has investigated. A calibrated classifier trained to separate confirmed (s = 1) from…