I'd like to generate more than two (i.e 3) correlated series, take an example when the series follows an IMA(1,1) process, at first I want to generate three correlated random errors
e[i] and then I use the following equation to build the series:
d[i,] <- mu + d[i-1,] - theta*(e[i-1,])+e[i,]
this is what we need to do for two series, how can we develop it for more than two series?
library(mvtnorm) rho <- 0.5 mu <- c(10,10) phi <- c(0.2,0.8) theta <- c(0.3,-0.7) d <- ts(matrix(0,ncol=2,nrow=50)) e <- ts(rmvnorm(50,sigma=cbind(c(1,rho),c(rho,1)))) for(i in 2:50) d[i,] <- mu + phi*d[i-1,] - theta*(e[i-1,]+e[i,]) plot(d)