Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

When Models Lie: The Stationarity Problem
Far too many time series projects collapse long before the first line of training code is executed. This isn't due to memory leaks or syntax errors; it’s a failure to respect the fundamental prerequisite of the field: stationarity.
Analysts often fall into a trap where they produce "successful" models—complete with professional-looking regression coefficients and convincing forecasts—that are fundamentally hollow. Because the underlying data is non-stationary, these models are essentially chasing ghosts, mistaking structural instability for predictive power. If your data-generating process is shifting, your model is likely just reacting to drift rather than learning a mechanism.
To demonstrate this, we will move past academic toy datasets and analyze the Consumer Price Index for All Urban Consumers (CPIAUCSL). Provided by the U.S. Bureau of Labor Statistics and hosted on the FRED database, this index is the gold standard for tracking U.S. inflation. Since institutional network restrictions can often block live API calls, this analysis relies on a local CSV export of the series.
Our objective is to move beyond the technical jargon and understand why stationarity is a hard constraint. We will demonstrate how standard transformations—like differencing and log-differencing—are not merely data-cleaning exercises, but critical steps to ensure your model isn't reporting artifacts as insights.
The transformation does more than just massage the numbers; it fundamentally alters the statistical nature of the series. By moving to a log-differenced format, we force a series previously defined by drift and trend into a mean-reverting space. While the result isn't perfectly serene—it still harbors the occasional volatility spike—the data now functions as a stationary process.
Distinguishing between these views is a matter of intent. The raw index provides the "what," but the log-difference identifies the "how much." When you shift from tracking levels to analyzing month-over-month log-differences, you aren't just cleaning a dataset; you are pivotally changing the economic question you’re posing.
9. Re-test after transformation
A second pass with the Augmented Dickey-Fuller (ADF) test yields a significantly different result than the initial run on the raw CPI levels:
adf_dlog <- cpi_log_tbl %>% filter(!is.na(dlog_cpi)) %>% pull(dlog_cpi) %>% tseries::adf.test() adf_dlog
Augmented Dickey-Fuller Test data: . Dickey-Fuller = -4.3862, Lag order = 9, p-value = 0.01 alternative hypothesis: stationary
Previously, we failed to reject the null hypothesis, confirming the raw CPI series suffered from a unit root. Now, with a p-value hovering near 0.01, the evidence points decisively toward stationarity. This isn't merely a statistical victory; it’s a verification that our transformation successfully purged the persistent trend. Never rely on the p-value in a vacuum, though. The real "aha" moment arrives when the formal test aligns with the visual reality of a series that finally stays tethered to a stable mean.
10. Interpretation as a deliberate choice
Preprocessing is often treated as a mindless chores list, but it is actually a series of analytical trade-offs. Each decision redefines your target:
- Levels track absolute index evolution.
- First differences capture raw, period-to-period shifts.
- Log differences isolate proportional shifts, the bedrock of inflation metrics.
If you don't acknowledge that these transformations change the underlying economic question, you’re flying blind. You aren't just "fixing" data; you are choosing what you want to measure.
11. Beyond the ARIMA checklist
The standard ARIMA workflow—inspect, difference, estimate, check—often lulls practitioners into thinking that differencing is just a procedural box to tick. It is not. It is an active modeling decision. Fail to difference when the trend demands it, and you invite unreliable inference. Over-difference, and you strip the model of its structural substance, leaving only noise. Stop asking, "Should I difference?" and start asking, "What signal am I isolating, and what question does this answer?"
12. Summary of Transformations
| Series Version | Representation | Typical Flaw | Utility |
|---|---|---|---|
| CPI Level | Raw Index | Unit root / Trend | Minimal for stationary modeling |
| First Difference | Absolute change | Scale-dependent | Reduces trend, limits depth |
| Log Difference | Proportional change | Volatility clusters | Optimal for inflation dynamics |
| YoY Change | Annualized shift | High latency | Better for broad communication |
13. Where analysis goes off the rails
Most failures in this space are conceptual, not computational. Watch for these common pitfalls:
- The "Looks Smooth" Fallacy: Visual smoothness does not equal stationarity. A trending line is still a problem, no matter how clean it looks.
- Default Differencing: Never treat transformation as a harmless habit. It actively shapes your output.
- Test Fetishism: Use the ADF test as one data point, not the ultimate authority. Context, domain knowledge, and visual intuition remain paramount.
- Ignoring the Economics: Never lose sight of the objective. If you are modeling inflation, ensure your transformation actually represents inflation.
Time series analysis is not a sequence of steps; it is a sequence of informed decisions.
14. Final Takeaway
Most models perish before they start because we fail to define the correct object of study. The raw CPI is a cautionary tale: it is almost never ready for prime time. By properly transforming the data, you aren't just preparing a model—you are ensuring your input is fit for purpose. Before you burn cycles on hyperparameter tuning, ask the only question that matters: Are you modeling a stable process, or are you just chasing the drift?
15. Further Reading
Data Sources
Core References
- Box, Jenkins, et al. (2015). Time Series Analysis: Forecasting and Control.
- Hyndman & Athanasopoulos: Forecasting: Principles and Practice
- Hamilton (1994). Time Series Analysis.
R-bloggers.com provides daily updates on R tutorials. Find R jobs here.
Share your own blog or submit posts.