How to generate more than two correlated series in R?

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)

-
What did you try –  Elvis Dec 23 '12 at 21:44

library(mvtnorm)
rho1 <- 0.5
rho2 <- 0.3
rho3 <- -0.1
mu <- c(10,10,10)
phi <- c(0.2,0.8,0.6)
theta <- c(0.3,-0.7,0.1)
d <- ts(matrix(0,ncol=3,nrow=50))
e <- ts(rmvnorm(50,sigma=cbind(c(1,rho1,rho2),c(rho1,1,rho3),c(rho2,rho3,1))))
for(i in 2:50)
d[i,] <- mu + phi*d[i-1,] - theta*(e[i-1,]+e[i,])
plot(d)


Frankly, judging by the questions you’ve been asking lately, you need to take some time to review some basic probability theory, and learn R, before addressing time series, which is not easy stuff.

-