How can I generate two correlated ARMA(1,1) data series where



and $\rho_{12}$ is desired correlation between $e_1$ and $e_2$?

  • $\begingroup$ I changed the formatting - please check that the formulas still are correct! $\endgroup$ – MånsT Jul 24 '12 at 9:57
  • $\begingroup$ Thank you, it's not ϕ11 AND ϕ22, just ϕ1 and ϕ2 $\endgroup$ – Roji Jul 24 '12 at 10:00
  • 2
    $\begingroup$ Are $e_1$ and $e_2$ the same in each equation? I think you need to use a different symbol for the errors in the second equation. And do you want $\rho_{12}$ to be the correlation between $d_{1,2}$ and $d_{2,t}$ or between the two error series? $\endgroup$ – Rob Hyndman Jul 24 '12 at 11:22
  • $\begingroup$ e1 and e2 are not the same, ρ12 is the correlation between the two error series. $\endgroup$ – Roji Jul 24 '12 at 12:01

The following R code will do what you want. I have used $\rho_{12}=0.5$, $\mu=10$, $\phi_1=0.2$, $\phi_2=0.8$, $\theta_1=0.3$, $\theta_2=-0.7$ and I have assumed that the errors have mean zero and variance 1.

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,])
  • $\begingroup$ Thank you very much for your answer, If I change the variance of errors, is it correct to write sigma=cbind(c(Variance1,rho),c(rho,Variance2))))? May I substitute 1 with variance of error or standard deviation of error? $\endgroup$ – Roji Jul 25 '12 at 11:47
  • $\begingroup$ You would also need to change the covariance terms (i.e., replace rho by the covariance). $\endgroup$ – Rob Hyndman Jul 25 '12 at 11:59
  • $\begingroup$ I did and it works properly, many many thanks, just one more question please! Is it correct if I generate the series as follows d[1,]=mu+e[1,] and then d[i,] <- phi*d[i-1,] - theta*(e[i-1,]+e[i,])? $\endgroup$ – Roji Jul 25 '12 at 14:58
  • $\begingroup$ You have to start the simulation somewhere and I started it at zero. Probably a better choice would be to start at the mean which is mu/(1-phi). It is common to use a burn-in period where you simulate more data than you need and throw the first part away. Then the effect of starting values should be negligible. $\endgroup$ – Rob Hyndman Jul 25 '12 at 22:47
  • $\begingroup$ Could you please tell me what is the R code when ρ12 is the correlation between d1,2 and d2,t instead of two error series? $\endgroup$ – Roji Jul 26 '12 at 14:41

I will assume that the e1 and e2 terms are iid noise terms with 0 mean and constant variance. If that is the right way to interpret the model you can compute the correlation between d$_1$ and d$_2$ as a function of the correlations between e$_1$ and e$_2$. Since you now have clarified that ρ$_1$$_2$ is the correlation between e$_1$ and e$_2$ it is simpler than what I said originally. Again you haven't said whether you want to specify the entire cross correlation or just the zero lag crosscorrelation. One way to do this is to generate a bivariate normal distribution with mean vector (0,0)$^T$ and specified covariance martix having diagonal elements 1 and off diagonal elements ρ$_1$$_2$. There should be routines to do this. If you can't find one generate two independent normals a$_1$ and a$_2$ and let e$_1$=a$_1$ and e$_2$ = ρ$_1$$_2$ a$_1$ + a$_2$ where a$_2$ is chosen to have the variance that makes the variance of e$_2$ = 1 and a$_1$ has variance 1.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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