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.
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It only takes a minute to sign up.Sign up to join this community
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.
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"
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')