Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

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,])
share|improve this question
What did you try – Elvis Dec 23 '12 at 21:44

What about this?

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,])

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.