Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Chapter 10 — Unit Roots and Differencing

In previous chapters, we studied:

A central question now arises:

The answer lies in the concept of a unit root.

This has major consequences:

This chapter introduces:


Learning Objectives

By the end of this chapter, you should be able to:


10.1 Persistence Revisited

Recall the random walk:

xt=xt1+wtx_t = x_{t-1} + w_t

where:

wtwn(0,σw2)w_t \sim wn(0,\sigma_w^2)

Each new observation equals:


10.2 Simulating a Random Walk

Python Code
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(123)

w = np.random.normal(0, 1, 500)
x = np.cumsum(w)

plt.figure(figsize=(10,4))
plt.plot(x, lw=1)
plt.title("Simulated Random Walk")
plt.xlabel("Time")
plt.ylabel("$x_t$")

plt.savefig("figs/ch7/rw.png", dpi=300, bbox_inches="tight")
plt.close()   # replace with plt.show()
Random Walk

10.3 Why Random Walks Matter

Random walks are central in economics and finance.

Examples include:

The random walk model implies:


10.4 The Unit Root Idea

The random walk can be rewritten as:

xt=ϕxt1+wtx_t = \phi x_{t-1} + w_t

with:

ϕ=1\phi = 1

10.5 Why the Unit Root Matters

Consider:

xt=ϕxt1+wtx_t = \phi x_{t-1} + w_t

Case 1: ϕ<1|\phi| < 1

Case 2: ϕ=1\phi = 1


10.6 Stationary vs Unit Root Processes

Stationary Process

Unit Root Process


10.7 Simulating Different Levels of Persistence

Source
np.random.seed(123)

n = 500
w = np.random.normal(0,1,n)

x1 = np.zeros(n)
x2 = np.zeros(n)
x3 = np.zeros(n)

phi1 = 0.4
phi2 = 0.9
phi3 = 1.0

for t in range(1,n):
    x1[t] = phi1*x1[t-1] + w[t]
    x2[t] = phi2*x2[t-1] + w[t]
    x3[t] = phi3*x3[t-1] + w[t]

fig, ax = plt.subplots(3,1, figsize=(10,8))

ax[0].plot(x1)
ax[0].set_title(r"$\phi = 0.4$")

ax[1].plot(x2)
ax[1].set_title(r"$\phi = 0.9$")

ax[2].plot(x3)
ax[2].set_title(r"$\phi = 1.0$ (Unit Root)")

plt.tight_layout()

plt.savefig("figs/ch10/ar-sim.png", dpi=300, bbox_inches="tight")
plt.close()   # replace with plt.show()
Persistence

10.8 Differencing

A common way to remove unit roots is differencing.


10.9 Differencing a Random Walk

For a random walk:

xt=xt1+wtx_t = x_{t-1} + w_t

Taking first differences:

Δxt=xtxt1=wt\Delta x_t = x_t - x_{t-1} = w_t

10.10 Simulating Differencing

dx = np.diff(x)

plt.figure(figsize=(10,4))
plt.plot(dx, lw=1)
plt.title("First Difference of Random Walk")
plt.xlabel("Time")
plt.ylabel(r"$\Delta x_t$")

plt.savefig("figs/ch10/rw-diff.png", dpi=300, bbox_inches="tight")
plt.close()   # replace with plt.show()
RW Differencing

10.11 Integrated Processes

A unit root process is said to be integrated of order one.

Example

SeriesOrder
White noiseI(0)I(0)
Random walkI(1)I(1)

10.12 Detrending vs Differencing

Nonstationarity may arise for different reasons.

Deterministic Trend

Suppose:

xt=α+βt+utx_t = \alpha + \beta t + u_t

where utu_t is stationary.

Removing the trend may produce stationarity.

Stochastic Trend

For a random walk:

xt=xt1+wtx_t = x_{t-1} + w_t

detrending alone is insufficient.

Differencing is required.


10.13 Visual Comparison

Source
np.random.seed(123)

t = np.arange(500)

trend_stationary = 0.03*t + np.random.normal(0,1,500)

plt.figure(figsize=(10,4))
plt.plot(trend_stationary)
plt.title("Trend-Stationary Series")
plt.xlabel("Time")

plt.savefig("figs/ch10/trend.png", dpi=300, bbox_inches="tight")
plt.close()   # replace with plt.show()
Deterministic Trend

10.14 Why Unit Roots Matter

Unit roots affect:

This problem becomes central later in:


10.15 The Dickey–Fuller Test

We now need a way to test for unit roots.

Consider:

xt=ϕxt1+wtx_t = \phi x_{t-1} + w_t

Subtract xt1x_{t-1} from both sides:

xtxt1=(ϕ1)xt1+wtx_t - x_{t-1} = (\phi - 1)x_{t-1} + w_t

or:

Δxt=θxt1+wt\Delta x_t = \theta x_{t-1} + w_t

where:

θ=ϕ1\theta = \phi - 1

Hypotheses

H0:θ=0(unit root)H_0: \theta = 0 \quad \text{(unit root)}
H1:θ<0(stationary)H_1: \theta < 0 \quad \text{(stationary)}

10.16 Augmented Dickey–Fuller (ADF) Test

Real-world data often exhibit serial correlation.

The Augmented Dickey–Fuller (ADF) test extends the Dickey–Fuller test by including lagged differences:

Δxt=α+θxt1+i=1pγiΔxti+ut\Delta x_t = \alpha + \theta x_{t-1} + \sum_{i=1}^p \gamma_i \Delta x_{t-i} + u_t

10.17 Interpreting the ADF Test

Reject H0H_0

Fail to Reject H0H_0


10.18 ADF Testing in Gretl

Variable → Unit root tests → Augmented Dickey-Fuller

Typical Steps

  1. Choose variable

  2. Include constant and/or trend if appropriate

  3. Select lag length

  4. Interpret test statistic and p-value

[GRETL Screenshot Placeholder: ADF test dialog]
[GRETL Screenshot Placeholder: ADF test output]

10.19 KPSS Test (Optional)

The KPSS test reverses the hypotheses.

KPSS Hypotheses

H0:stationaryH_0: \text{stationary}
H1:unit rootH_1: \text{unit root}

10.20 Looking Ahead

In this chapter, we introduced:

We are now ready to build formal stochastic models for stationary time series.

In the next chapters, we study:

Key Takeaways

Concept Check

Basic

  1. What is a unit root?

  2. What does it mean for a time series to be nonstationary?

  3. What is a random walk?


Intuition

  1. Why do shocks have permanent effects in a unit root process?

  2. Why does a random walk not return to a stable level?

  3. Why is nonstationarity problematic for modeling?


Intermediate

  1. What is the purpose of differencing a time series?

  2. What is the difference between:

    • a stationary process

    • a unit root process

  3. What is the difference between:

    • deterministic trend

    • stochastic trend


Finance Insight

  1. Why are stock prices often modeled as random walks?

  2. Why are returns typically stationary?


Challenge

  1. Suppose a series becomes stationary after differencing once.


Interpretation & Practice

  1. A time series shows a strong upward trend and does not return to a stable level.

    • What does this suggest?

    • What might be an appropriate transformation?


  1. A series appears to “wander” over time.

    • What type of process might this be?

    • What does this imply about shocks?


  1. After differencing, a series fluctuates around zero.

    • What does this suggest?

    • Why is this useful?


  1. A regression between two trending series shows a strong relationship.

    • Why might this be misleading?

    • What concept does this illustrate?


  1. A series has a deterministic upward trend.

    • Would differencing or detrending be more appropriate?

    • Why?


Finance Interpretation

  1. A stock price series is nonstationary.

    • Why is modeling prices directly problematic?

    • Why are returns preferred?


  1. A return series appears stable over time.

    • What does this suggest?

    • Why is this important?


Challenge

  1. Suppose you difference a stationary series.

    • What might happen?

    • Why is over-differencing a problem?


Numerical Practice

Random Walk and Differencing

  1. Suppose a random walk is defined as:

xt=xt1+wtx_t = x_{t-1} + w_t

with:



  1. Compute the first differences:

Δxt=xtxt1\Delta x_t = x_t - x_{t-1}


Identifying Nonstationarity

  1. Consider the series:

    10, 12, 15, 19, 24



Trend vs Difference

  1. Suppose:

xt=5+0.5t+utx_t = 5 + 0.5t + u_t


ADF Interpretation (Applied)

Consider the following output from an Augmented Dickey–Fuller (ADF) test:

Augmented Dickey-Fuller Test

Test Statistic:   -1.85
p-value:           0.67
Lags Used:         2
Observations:      197

Critical Values:
  1% level:       -3.46
  5% level:       -2.88
 10% level:       -2.57
  1. What is the null hypothesis of the ADF test?

  2. Compare the test statistic with the critical values.

    • Is the test statistic more negative than the 5% critical value?

  3. Based on the p-value and test statistic:

    • Do you reject the null hypothesis?

    • What does this imply about the series?

  4. What would you do next before modeling this series?


Second Example

Now consider:

Augmented Dickey-Fuller Test

Test Statistic:   -3.25
p-value:           0.02
Lags Used:         1
Observations:      198

Critical Values:
  1% level:       -3.46
  5% level:       -2.88
 10% level:       -2.57
  1. Do you reject the null hypothesis at the 5% level?

  2. What does this imply about stationarity?

  3. Why might the test statistic be compared with critical values rather than relying only on the p-value?


Challenge

  1. Suppose the test statistic is close to the critical value.

    • Why might conclusions be uncertain?

    • What additional checks could you perform?


  1. Suppose you difference a series twice.


  1. Suppose two nonstationary series are regressed on each other.