Skip to content
All library documents

Simulating Cointegrated Series from a Shared Random Walk

Article Quant Q&A · Author: Lukas

Summary

The document explains a simple way to generate two non-stationary time series that are cointegrated. Start with a series containing a unit root, such as a random walk, then form a second series by adding a stationary process. The shared stochastic trend causes the two levels to move together, while their difference remains stationary under this construction.

It also outlines examples of generating random walks, random walks with drift, and trend-stationary data in R. These examples illustrate different kinds of non-stationarity, but they do not by themselves establish cointegration; the key construction is the shared unit-root component plus stationary variation. The suggested approach is introductory and does not cover choices such as drift structure, dependence between innovations, or formal tests for cointegration, all of which may matter in a research simulation.

Key ideas

  • A cointegrated pair can share a common unit-root component while retaining stationary deviations.
  • One construction simulates a random walk and adds a stationary process to create the second series.
  • Random walks with drift and trend-stationary series are distinct examples of non-stationary behavior.
  • Simulation details such as innovation dependence and drift can affect the properties of the generated pair.

Tags

Full text
# Simulate non-stationary time series with cointegration


# Simulate non-stationary time series with cointegration












how can I simulate/generate two non-stationary time series (with unit root) so that they can be also cointegrated (using R or Matlab).

Thanks in advance.

## Answer by Drew (score 1, accepted)

https://quant.stackexchange.com/a/14345

Two cointegrated series contain a single unit root. Each series can be formulated as the sum of a common unit root plus a stationary component. Most textbooks covering cointegration will cover such formulations - see Hamilton's (1994) discussion of Phillips' "triangular representation" of a cointegrated vector, for example.

Simulating is likely to be easy (depending on other features you may need, of course). For example, simulate one non-stationary series, and construct a second series as the sum of the first and a stationary variable. Viola! Cointegrated.

## Answer by Muhammad Jawad (score 1)

https://quant.stackexchange.com/a/58118

Simulate Random Walk Series We can now simulate a random walk series in R as shown below:

RW <- arima.sim(model= list(order = c(0, 1, 0)), n=200) We can plot the newly generated series as well using the plot.ts() function.

> plot.ts(RW,main="Random Walk", col=4)

Random Walk with Drift

> RW_drift <- arima.sim(model= list(order = c(0, 1, 0)), n=200, mean=1,sd=5) plot.ts(RW_drift, main="Random Walk with Drift")

or you can use by installing the package "extraDistr"

> library(extraDistr)

> random_walk<-cumsum(rsign(10000)) plot(random_walk,type='l',xlab='Time',ylab=expression('x'[t]),main='Random Walk')

Trend Stationary Process using following commands

> white_noise<-rnorm(100,0,40) trend<-3*(1:100) x_t<-trend+white_noise plot(x_t,type='l',xlab='Time',ylab=expression('x'[t]),main='Trend Stationary Process')

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.