Hi Everyone,

I am a new comer to R circle. I am trying to simulate a VAR estimation. The problem is given above in the image. Assume that the errors are iid and normally distributed. Here the number of observations x1=x2=64.

I've written the code below. Not sure if it is correct.

pi=matrix(c(0.9,0.1,-0.1,0.7),nrow=2,ncol=2)

# errors

error1=rnorm(64,mean=0,sd=1)

error2=rnorm(64,mean=0,sd=1)

#variables x1 and x2

x1=sample(64)

x2=sample(64)

#VAR simulation#

obs = 64

set.seed(123)

E=matrix(c(error1,error2),nrow=2,ncol=64)

pi=matrix(c(0.9,0.1,-0.1,0.7),nrow=2,ncol=2)

X=matrix(c(x1,x2),nrow=2,ncol=64)

for (i in 2:obs) {

X[,i] = pi%*%X[,i-1]+E[,i]

}

I would appreciate if you could comment whether I've correctly simulated it or not.

Thank you,

lphd