0
$\begingroup$

I'd like to use R to generate two correlated series that follow IMA(1,1) process. rho is a correlation between the error terms, but when I changed the rho the plot does not change. Is it wrong if I use d[i,] <- d[i-1,] - theta*(e[i-1,]+e[i,]) ?

rho < 0.1
mu <- c(400,400)
theta <- c(0.1,0.1)
d <- ts(matrix(0,ncol=2,nrow=1001))
e <- ts(rmvnorm(1001,sigma=cbind(c(400,rho*400),c(rho*400,400))))
for(i in 2:1001)
  d[i,] <- mu + d[i-1,] - theta*(e[i-1,]+e[i,])

plot(d)

enter image description here

$\endgroup$
1
$\begingroup$

Change your mean to something smaller than 400 like 0.01 to see the time series more clearly. Then try the following code with rho <- 0.1 and rho <- 0.9 to see the effect of rho.

rho <- 0.1
#rho <- 0.9
mu <- c(0.01,0.01)
theta <- c(0.1,0.1)
d <- ts(matrix(0,ncol=2,nrow=1001))
e <- ts(rmvnorm(1001,sigma=cbind(c(400,rho*400),c(rho*400,400))))
for(i in 2:1001)
 d[i,] <- mu + d[i-1,] - theta*(e[i-1,]+e[i,])

par(mfrow=c(1,2))
plot(d[,1]);plot(d[,2])

Here are some plots: enter image description here

$\endgroup$

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.