inst/book-ex/Rcode-6-1.R

set.seed(123456)
e <- rnorm(500)
## trend
trd <- 1:500
S <- c(rep(0, 249), rep(1, 251))
## random walk with drift
y1 <- 0.1*trd + cumsum(e)
## random walk with drift and shift
y2 <- 0.1*trd + 10*S + cumsum(e)

Try the vars package in your browser

Any scripts or data that you put into this service are public.

vars documentation built on March 31, 2023, 10:30 p.m.