# Process A example: A is distributed as N(1,4) n <- 50 a <- rnorm(1, 1, 2) xt <- rep(a, n) plot(xt, ylim=c(-5,7)) lines(xt) #run after the first part par(new=TRUE) a <- rnorm(1, 1, 2) xt <- rep(a, n) plot(xt, ylim=c(-5,7)) lines(xt) # Process B example: IID N(1,4) n <- 50 xt <- ts(rnorm(n, 1, 2)) plot(xt, ylim=c(-5,7)) #run after the first part par(new=TRUE) xt <- ts(rnorm(n)) plot(xt, ylim=c(-5,7)) # Process C example: Cauchy location 0, scale 1 n <- 50 xt <- ts(rcauchy(n, 0, 1)) plot(xt, ylim=c(-100,100)) # run after running the first part par(new=TRUE) xt <- ts(rcauchy(n, 0, 1)) plot(xt, ylim=c(-100,100)) # Process D: A1 is N(1,4), A2 is N(0,9) n <- 50 theta <- 0.5 a1 <- rnorm(1, 1, 2) a2 <- rnorm(1, 0, 3) xt <- ts(a1*cos(theta*(1:n)+a2)) plot(xt, ylim=c(-3,3)) # run after the first part par(new=TRUE) a1 <- rnorm(1, 1, 2) a2 <- rnorm(1, 0, 3) xt <- ts(a1*cos(theta*(1:n)+a2)) plot(xt, ylim=c(-3,3)) # Process E a <- sample(c(-1,1), 1, replace=TRUE, prob=c(1/2,1/2)) xt <- (-1)^(1:n) * a plot(xt) lines(xt) # MA(1) n <- 500 theta <- 0 zt <- ts(rnorm(n)) xt <- zt+theta*lag(zt,-1) # or use arima.sim # arima.sim(n = 50, list(order=c(0,0,1), ma = 0.5), innov = rnorm(50)) plot(xt, ylim=c(-3,3)) #run after the first part par(new=TRUE) zt <- ts(rnorm(n)) xt <- zt+theta*lag(zt,-1) plot(xt, ylim=c(-3,3)) # Random walk with IID N(0,1) errors n <- 50 xt <- ts(cumsum(rnorm(n))) plot(xt, ylim=c(-10, 10)) # run after running the first part par(new=TRUE) xt <- ts(cumsum(rnorm(n))) plot(xt, ylim=c(-10, 10)) # abline(v=20, col="red") # Trend stationary process with IID N(0,1) errors n <- 50 alpha0 <- 1 alpha1 <- 0.1 xt <- alpha0+alpha1*(1:n)+rnorm(50) # adjust this part accordingly plot(1:n, xt, ylim=c(0,10)) lines(xt) # run after running the first part par(new=TRUE) xt <- alpha0+alpha1*(1:n)+rnorm(50) plot(1:n, xt, ylim=c(0,10)) lines(xt)