Two correlated AR(1) series

48 Views Asked by At

I have two AR(1) series that are correlated. $$X_{t,1} = \rho_1X_{t-1,1} + e_{t,1}$$ $$X_{t,2} = \rho_2X_{t-1,2} + e_{t,2}$$ and $corr(X_{t,1}, X_{t,2}) = \rho.$

I want to generate at each time $t$ a certain number of simulated values of each series. So far I did this:

calcrho<-function(rho,rho1,rho2){
rho*(1-rho1*rho2)/sqrt((1-rho1^2)*(1-rho2^2))
}
T <- 100
rho<-0.8
n <-1000
rho1<-0.6
rho2<-0.7
q12<-calcrho(rho,rho1,rho2)
m_new <- matrix(nrow = n, ncol = 2*T)
x_01 <- rep(200, 1000)
x_02 <- rep(150, 1000)
for (i in 1:T) {
m_new[,2*i-1] <- x_01
m_new[,2*i] <- x_02 
eps<-mvrnorm(n,mu=c(0,0),Sigma=cbind(c(1,q12),c(q12,1)))
x_01 <- rho1*x_01+eps[,1]
x_02 <- rho2*x_02 + eps[,2] 
}

However, my $X_{t,1}$ and $X_{t,2}$ series are decreasing and I have a feeling that I am doing something wrong. I wanted to use arima.sim function, however, could not figure out how to generate at each given time 1000 values.

Any helps is appreciated.

Thanks.

1

There are 1 best solutions below

2
On BEST ANSWER

You initialize $x_{1}$ and $x_2$ to $250$ and $150.$ An AR-1 process mean-reverts toward zero, so it is no surprise you are seeing both series decrease toward zero. If you want to center the process around $(250,150)$ instead of $(0,0)$, you should add that in at the end (i.e. shift all paths by that amount), not put it as an initial condition.