Research question

Two hypothetical 120-month independent random walks: A drifts 0.30 per month with shock SD 1.00; B drifts 0.25 per month with shock SD 1.20. Will a level regression of B on A show a high R² and a significant slope? Why? This article explains trends, nonstationarity and spurious regression, contrasting differenced and detrended diagnostics. Every number comes from scripts/simulate-spurious-regression.mjs: the documented draw uses seed 20261030, and the mechanism is reported over 500 independent draws starting from that seed.

Data

Item Value
A random walk, drift 0.30, shock SD 1.00
B random walk, drift 0.25, shock SD 1.20
Level slope b (median R² basis) -0.069 (SE 0.120) in the documented draw
Level R² (median of 500 draws) 0.793
Level R² (documented draw, seed 20261030) 0.003
Difference slope b 0.052 (SE 0.124) in the documented draw
Difference R² (median of 500 draws) 0.004
Detrended R² (median of 500 draws) 0.091
Residual lag-1 autocorrelation 0.963

A and B are dimensionless teaching series; drift and shock SD are per month, and a slope reads as “the change in B per one-unit change in A”.

Method and assumptions

The level regression B_t = a + b A_t + e_t assumes stationary, independent, homoskedastic errors. With stochastic trends (unit roots), conventional t distributions do not apply; independent trending series can produce falsely significant relationships—spurious regression (Granger & Newbold 1974). Diagnosis includes time plots, autocorrelation, unit-root tests, and comparisons of levels, differences and detrended results. Differences, ΔB_t = a + b ΔA_t + e_t, remove stochastic trends; levels may be meaningful only under cointegration. Autocorrelation detects non-randomness; if randomness fails, use a time-series model (NIST 1.3.5.12).

Results

Start with the documented draw (seed 20261030): levels give b = -0.069, SE = 0.120, t = -0.6, R² = 0.003, p = 0.57, residual lag-1 autocorrelation 0.963. This pair of random walks produced no impressive spurious fit at all - which is exactly why one draw is not evidence. The mechanism lives in the distribution over 500 independent draws: level R² has median 0.793, a 5th percentile of 0.226 and a 95th percentile of 0.938, and 83% of the draws exceed 0.5. The series are independent by construction; the fit comes from their separate random trends drifting in the same direction in a finite sample, not from an economic link.

Across the same 500 draws, difference R² has median 0.004 and a 95th percentile of 0.031, with no draw above 0.5; in the documented draw, differences give b = 0.052, SE = 0.124, t = 0.4, R² = 0.001, p = 0.68, correlation 0.04. Differencing removes the unit root, so the spurious relation disappears. Detrending behaves differently: the documented draw gives b = -0.945, SE = 0.087, t = -10.9, R² = 0.500, p = 0.00, and over 500 draws the median is 0.091 with a 95th percentile of 0.491 and 5% of draws above 0.5. Subtracting a fitted straight line from a random walk leaves a unit root behind - detrending does not remove the unit root - which is precisely the dividing line against trend-stationary series.

Goodness of fit under three specifications Three zero-based bars showing the median R-squared over 500 independent draws, at fifteen pixels per 0.1. Levels 0.793 (118.9 pixels tall); first differences 0.004 (0.7 pixels); detrended 0.091 (13.7 pixels). The first bar towers over the other two. R² (zero baseline, 15 px per 0.1) 0.793 0.004 0.091 levels (median) first difference detrended Two independent random walks each carry a trend ⇒ levels often show high R²; differencing removes it
Figure 1: median R² for the same pair under three specifications over 500 independent draws (zero baseline, 15 pixels per 0.1): levels 0.793, first differences 0.004, detrended 0.091. Both series are random walks (monthly drifts of 0.30 and 0.25) that are independent by construction, so what they share is a time trend rather than an economic link; differencing removes the unit root and the fit collapses, while detrending leaves a unit root behind, which is why its median stays at 0.091 with a 95th percentile of 0.491. Values generated by `scripts/simulate-spurious-regression.mjs`; teaching simulation, not real data.

Robustness

  • With another seed or sample window the level R² is usually high again (83% of 500 draws exceed 0.5) while no differenced draw exceeds 0.5; the documented draw's level R² of 0.003 shows that a single seed proves nothing and must not be chosen for how it looks.
  • Log differences (growth rates) in the documented draw: b = 0.245, SE = 0.093, R² = 0.057 - the sign and size of a single draw are unstable, so report the distribution rather than a picked seed.
  • Putting a time trend directly into the level regression is the same operation as detrending here: after detrending a random walk still has a unit root, so the median R² over 500 draws is 0.091 with a 95th percentile of 0.491 rather than an automatically clean result.
  • If the series are trend-stationary rather than unit-root, detrending may restore a relationship; misclassification leads to over-differencing.
  • Unit-root tests have low power; use economic meaning and multiple diagnostics.

Limitations

The simulation illustrates a mechanism, not a real-data test. Real data have breaks, seasonality, measurement error and common shocks; spurious and genuine trends are hard to distinguish. The charts and data snapshots on this site show co-movement and correlation: they are associational evidence, the caution drawn here applies to them, and no causal or forecasting conclusion follows from them. A high R² is not evidence of a correct model; residual analysis informs adequacy (NIST 4.4.4). Unit-root or cointegration tests, robust SEs and out-of-sample validation are needed. Numbers are simulated, not real data.

Reproduction

  1. Plot both series against time.
  2. Compute the level and difference regressions, with R² and t.
  3. Check residual autocorrelation and unit roots.
  4. Add a trend or use differences.
  5. Report all specifications, not only significant ones.
  6. Reproduce with the fixed seed.
node scripts/simulate-spurious-regression.mjs          # documented draw (seed 20261030) plus the 500-draw distribution
node scripts/simulate-spurious-regression.mjs --check   # asserts that every number quoted in the body comes from the script
node scripts/simulate-spurious-regression.mjs --selftest # determinism, OLS and t-distribution known answers

Model, drawn once per month, A before B, so one seed fixes the whole sample:
A[t] = A[t-1] + 0.30 + N(0, 1.00), A[0] = 0
B[t] = B[t-1] + 0.25 + N(0, 1.20), B[0] = 0
levels: B ~ A   changes: diff(B) ~ diff(A)   detrended: B ~ A after removing each series' fitted linear trend

Every number in the article comes from the script above, and no seed was chosen because it looked good. The old pseudocode is dropped so that two model descriptions do not compete.

Strength of conclusions

Mechanically, level R² has a median of 0.793 across 500 independent draws - 83% exceed 0.5 - even though the walks are independent by construction, and differencing collapses the median to 0.004 with no draw above 0.5. The documented draw inverts the easy story: its level R² is only 0.003 while the detrended R² reaches 0.500, which shows both that a single seed is not evidence and that detrending does not remove the unit root. Level significance alone is therefore not evidence of a relationship; trends and nonstationarity must be handled, and results reported as a distribution. This is not a causal or forecasting claim about real markets.

Knowledge-point review

trend stationarity

Definition: Trend stationarity means a series fluctuates around a deterministic trend and is stationary after detrending, unlike a unit-root process where shocks persist.

Mechanism: Trend-stationary series can be detrended, unit roots need differencing; wrong handling causes spurious correlation or overdifferencing.

Example: For example, real GDP is modelled as trend-stationary or unit-root, and the choice affects forecasts and causality.

Boundary: Trend stationarity is not a visual judgment; unit-root tests have low power, structural breaks mislead, trends and random walks are hard to distinguish, and model choice affects long forecasts.

differencing

Definition: Differencing subtracts the previous value from the current one to remove trend and unit roots and make a series more stationary.

Mechanism: First differences give changes, seasonal differencing removes seasonal patterns; overdifferencing introduces negative autocorrelation and noise.

Example: For example, differencing price levels gives returns and differencing GDP gives growth.

Boundary: More differencing is not better; it loses level information, amplifies noise, treats unit roots and trend stationarity differently, and changes model interpretation.

lags

Definition: Lags use past values of variables as regressors or instruments to capture dynamics, expectations and timing.

Mechanism: Lag order follows information criteria, theory and sample; lags address autocorrelation and reverse causality but can add omission and overfitting.

Example: For example, past quarterly investment forecasts current GDP, or lagged policy identifies effects.

Boundary: Lags are not causal proof; selection, look-ahead and lag-length manipulation matter, lagged variables can correlate with other factors, and dynamic models need stability checks.

cointegration

Definition: Cointegration means a linear combination of non-stationary series is stationary, indicating a long-run equilibrium.

Mechanism: Engle-Granger or Johansen tests identify it, and error-correction models capture long-run relation and short-run adjustment.

Example: For example, house prices and income may trend but a price-to-rent or income ratio can be in long-run equilibrium.

Boundary: Cointegration is not any correlation; spurious regression, breaks and sample periods create false cointegration, the relation can shift, and strategies need adjustment speed and costs.

seasonality

Definition: Seasonality is a pattern repeating at fixed intervals such as months, quarters or weeks, driven by weather, holidays, production and behaviour.

Mechanism: Seasonal models use dummies, Fourier terms, seasonal differencing or decomposition; adjustment and forecasting must separate true seasonality from one-offs.

Example: For example, retail rises before Spring Festival and electricity peaks in summer.

Boundary: Seasonality is not fixed; moving holidays, climate and structure change patterns, over-adjustment removes real signal, and seasonal and cyclical effects are easily confused.

rolling analysis

Definition: Rolling analysis re-estimates or backtests over moving windows to see how parameters, returns and risk change.

Mechanism: Window length trades stability for adaptability; rolling backtests detect overfitting and regime shifts but create multiple comparisons and boundary effects.

Example: For example, a 36-month rolling window estimates beta and shows drift.

Boundary: Rolling is not out-of-sample proof; window choice affects results, overlapping windows correlate, rolling backtests can still snoop, and breaks invalidate historical windows.

structural change and volatility

Definition: Structural change is a persistent shift in the data-generating process at some point, and volatility is variance clustering and changing over time.

Mechanism: Chow, Bai-Perron and ARCH/GARCH models identify them; policy, technology and crises often create breaks.

Example: For example, volatility rose and clustered after the financial crisis, and regulatory reform changed market structure.

Boundary: Structural change is not an outlier; break location and number are uncertain, volatility clustering can have confounders, and historical windows no longer represent the future after breaks.

Related

  • Required prerequisite: Introduction to Linear Regression (RES-013).
  • Related reading: Indexing, Logarithms and Growth Rates (RES-006), Introduction to Linear Regression (RES-013), Causality and Identification (RES-015).

Figures in plain language

The three figures below check the mechanism, boundary and comparison in this article; labels come from its own sections, not new data.

Trends, Nonstationarity and Spurious Regression: mechanism chain Trends, Nonstationarity and Spurious Regression — three-step structure: problem, mechanism, judgment. Labels come from the article's sections, not new data. Trends, Nonstationarity and Spurious Regression: mechanism chain Labels come from the article's sections; all three steps matter. Problem Two nonstationary series with… Two nonstationar y series with their own trends can produce a high… Reproduction Reproduction: 1. Reproduction: 1. Data | Item | Value | | --- | ---: | |… | Item | Value | | --- | ---: | | A | random walk, drift 0.30, shock SD… Reading order: test the problem, then the mechanism, then whether the judgment overreaches. If a middle step lacks evidence, later conclusions are hypotheses, not facts. Structural illustration, not a new data chart; sample is the article's own argument.
Figure 2: Trends, Nonstationarity and Spurious Regression — mechanism chain: problem, mechanism, judgment. Sample: the article's own argument; units as stated in the text.
Trends, Nonstationarity and Spurious Regression: boundary Separates conditions where the claim holds from those where it fails; a local example is not universal. Trends, Nonstationarity and Spurious Regression: when does it hold? Check the conditions before the conclusion If conditions, definitions or samples change, recompute the conclusion Holds The simulation illustrates a mechanism, not a real-data test. Fails / rewrite Two hypothetical 120-month independent random walks: A drifts 0.30 per month with shock SD 1.00; B drifts… Boundary illustration; sample is the article's own argument; units as stated in the text.
Figure 3: Trends, Nonstationarity and Spurious Regression — boundary: when the claim holds, and when it fails. Sample: the article's own argument; units as stated in the text.
Trends, Nonstationarity and Spurious Regression: object, conditions and common mistakes Three rows compare the concept, its conditions and common mistakes; comparison is not equivalence and does not replace a definition. Trends, Nonstationarity and Spurious Regression: object, conditions and common mistakes at a glance This article Commonly confused Object Two nonstationary series with their… Adjacent concepts / common claims Conditions The simulation illustrates a… Two hypothetical 120-month independent random walks: A… Check Define first, then compare; never judge labels only Correlation is not causation; a local case is not universal Comparison illustration; sample is the article's own argument; units as stated in the text.
Figure 4: Trends, Nonstationarity and Spurious Regression — comparison of object, conditions and common mistakes. Sample: the article's own argument; units as stated in the text.

Exercises

  1. Why do two independent trending series produce a significant slope, and why is detrending not a cure?
  2. What is the difference between differencing and detrending?
  3. Why is a high R² not proof?
Suggested answers
  1. Both rise over time, so the regression mistakes a common trend for a common movement; residuals are autocorrelated and SEs too small.
  2. Differencing removes a stochastic trend and works on changes; detrending only removes a fitted deterministic trend, so for a random walk it leaves the unit root in place (detrending does not remove the unit root: median R² 0.091 and a 95th percentile of 0.491 over 500 draws). The choice depends on whether the series is difference-stationary or trend-stationary.
  3. R² measures in-sample fit only; residual autocorrelation, heteroskedasticity or omitted variables can make a high-R² model invalid.

Sources

  1. NIST/SEMATECH. e-Handbook of Statistical Methods, “1.3.5.12 Autocorrelation.” U.S. Government work (public domain). https://www.itl.nist.gov/div898/handbook/eda/section3/eda35c.htm (accessed 2026-10-30)
  2. NIST/SEMATECH. e-Handbook of Statistical Methods, “4.4.4 How can I tell if a model fits my data?” U.S. Government work (public domain). https://www.itl.nist.gov/div898/handbook/pmd/section4/pmd44.htm (accessed 2026-10-30)
  3. Granger, C. W. J., and P. Newbold. “Spurious regressions in econometrics.” Journal of Econometrics 2, no. 2 (1974): 111–120. License unknown. https://ideas.repec.org/a/eee/econom/v2y1974i2p111-120.html (accessed 2026-10-30)

Worked demo

Read-through check: can you say three things?

No recitation needed. Tick each sentence below and see whether you can explain the mechanism, one worked example and one boundary in your own words.

Ticked 0 / 3

The numbers are teaching assumptions that show relationships, not forecasts or investment advice.

This article has passed the current publication gate. Factual, calculation and translation revisions update both language versions together.

Back to station